Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: cc/region.h

Issue 11369103: Compare SkRegion and android::Region performance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/cc.gyp ('k') | cc/region.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/region.h
diff --git a/cc/region.h b/cc/region.h
index ec21c65fc9ff2248dff15f9007269ee795cc74fc..db622096f90c0d9450004122789030db15fd77a2 100644
--- a/cc/region.h
+++ b/cc/region.h
@@ -9,9 +9,16 @@
#include "base/logging.h"
#include "cc/cc_export.h"
-#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/rect.h"
+#define USE_ANDROID_REGION
+
+#ifdef USE_ANDROID_REGION
+#include "cc/android_region.h"
+#else
+#include "third_party/skia/include/core/SkRegion.h"
+#endif
+
namespace cc {
class CC_EXPORT Region {
@@ -40,10 +47,14 @@ class CC_EXPORT Region {
void Intersect(gfx::Rect rect);
void Intersect(const Region& region);
- bool Equals(const Region& other) const { return skregion_ == other.skregion_; }
+ bool Equals(const Region& other) const;
gfx::Rect bounds() const {
+#ifdef USE_ANDROID_REGION
+ SkIRect r = droidregion_.bounds();
+#else
SkIRect r = skregion_.getBounds();
+#endif
// TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
return gfx::Rect(r.x(), r.y(), r.width(), r.height());
}
@@ -56,24 +67,45 @@ class CC_EXPORT Region {
~Iterator();
gfx::Rect rect() const {
+#ifdef USE_ANDROID_REGION
+ SkIRect r = *it_;
+#else
SkIRect r = it_.rect();
+#endif
// TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
return gfx::Rect(r.x(), r.y(), r.width(), r.height());
}
void next() {
+#ifdef USE_ANDROID_REGION
+ ++it_;
+#else
it_.next();
+#endif
}
bool has_rect() const {
+#ifdef USE_ANDROID_REGION
+ return it_ != droidregion_.end();
+#else
return !it_.done();
+#endif
}
private:
+#ifdef USE_ANDROID_REGION
+ const android::Region& droidregion_;
+ android::Region::const_iterator it_;
+#else
SkRegion::Iterator it_;
+#endif
};
private:
+#ifdef USE_ANDROID_REGION
+ android::Region droidregion_;
+#else
SkRegion skregion_;
+#endif
};
inline bool operator==(const Region& a, const Region& b) {
« no previous file with comments | « cc/cc.gyp ('k') | cc/region.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698