diff options
author | ccameron <ccameron@chromium.org> | 2015-08-10 18:41:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-11 01:42:49 +0000 |
commit | aae371ca10e047d9b192acf869f8ff9601d3cdf7 (patch) | |
tree | e769084bff1f212d7e076e0b0c6eba1dbe9c1122 /ui/gfx | |
parent | c1b891418bbfafcc620ca50805c0b7d610ba4cff (diff) | |
download | chromium_src-aae371ca10e047d9b192acf869f8ff9601d3cdf7.zip chromium_src-aae371ca10e047d9b192acf869f8ff9601d3cdf7.tar.gz chromium_src-aae371ca10e047d9b192acf869f8ff9601d3cdf7.tar.bz2 |
Mac: Enable partial swap
This is pretty trivial when using the overlay path. Just create a
new layer for the damage. The partial damage layer can be created,
removed, or resized with basically no cost, because its backing is the
already-existing IOSurface.
As each partial swap comes in, union the existing overlay layer's
rect with the rect of the new partial swap. If this grows "too big",
then do a full swap (which clears the accumulated union). The
constants here are pretty arbitrary.
BUG=474299
Review URL: https://codereview.chromium.org/1271123002
Cr-Commit-Position: refs/heads/master@{#342771}
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/geometry/rect_f.cc | 16 | ||||
-rw-r--r-- | ui/gfx/geometry/rect_f.h | 10 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ui/gfx/geometry/rect_f.cc b/ui/gfx/geometry/rect_f.cc index c87ea3d..a15bdf3 100644 --- a/ui/gfx/geometry/rect_f.cc +++ b/ui/gfx/geometry/rect_f.cc @@ -6,6 +6,12 @@ #include <algorithm> +#if defined(OS_IOS) +#include <CoreGraphics/CoreGraphics.h> +#elif defined(OS_MACOSX) +#include <ApplicationServices/ApplicationServices.h> +#endif + #include "base/logging.h" #include "base/strings/stringprintf.h" #include "ui/gfx/geometry/insets_f.h" @@ -24,6 +30,16 @@ static void AdjustAlongAxis(float dst_origin, *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; } +#if defined(OS_MACOSX) +RectF::RectF(const CGRect& r) + : origin_(r.origin.x, r.origin.y), size_(r.size.width, r.size.height) { +} + +CGRect RectF::ToCGRect() const { + return CGRectMake(x(), y(), width(), height()); +} +#endif + void RectF::Inset(const InsetsF& insets) { Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); } diff --git a/ui/gfx/geometry/rect_f.h b/ui/gfx/geometry/rect_f.h index dc233a7..3b132667e 100644 --- a/ui/gfx/geometry/rect_f.h +++ b/ui/gfx/geometry/rect_f.h @@ -12,6 +12,10 @@ #include "ui/gfx/geometry/size_f.h" #include "ui/gfx/geometry/vector2d_f.h" +#if defined(OS_MACOSX) +typedef struct CGRect CGRect; +#endif + namespace gfx { class InsetsF; @@ -27,6 +31,12 @@ class GFX_EXPORT RectF { RectF(const PointF& origin, const SizeF& size) : origin_(origin), size_(size) {} +#if defined(OS_MACOSX) + explicit RectF(const CGRect& r); + // Construct an equivalent CoreGraphics object. + CGRect ToCGRect() const; +#endif + ~RectF() {} float x() const { return origin_.x(); } |