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

Unified Diff: cc/resources/content_layer_updater.cc

Issue 23484005: Skip clearing the canvas before painting the contents of opaque layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed virtual OVERRIDE Created 7 years, 4 months 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/resources/content_layer_updater.h ('k') | cc/resources/skpicture_content_layer_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/content_layer_updater.cc
diff --git a/cc/resources/content_layer_updater.cc b/cc/resources/content_layer_updater.cc
index c9c2eccf31c2bb257db05b020a0b3209d6d80b2b..8ab29190f14879f11d5c42d6cb595ca33f9fe7c6 100644
--- a/cc/resources/content_layer_updater.cc
+++ b/cc/resources/content_layer_updater.cc
@@ -9,6 +9,7 @@
#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/resources/layer_painter.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkDevice.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkScalar.h"
@@ -23,7 +24,8 @@ ContentLayerUpdater::ContentLayerUpdater(
int layer_id)
: rendering_stats_instrumentation_(stats_instrumentation),
layer_id_(layer_id),
- painter_(painter.Pass()) {}
+ painter_(painter.Pass()),
+ layer_is_opaque_(false) {}
ContentLayerUpdater::~ContentLayerUpdater() {}
@@ -52,12 +54,24 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
content_rect, 1.f / contents_width_scale, 1.f / contents_height_scale);
}
- SkPaint paint;
- paint.setAntiAlias(false);
- paint.setXfermodeMode(SkXfermode::kClear_Mode);
SkRect layer_sk_rect = SkRect::MakeXYWH(
layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height());
- canvas->drawRect(layer_sk_rect, paint);
+
+ // If the layer has opaque contents then there is no need to
+ // clear the canvas before painting.
+ if (!layer_is_opaque_) {
+ SkDevice* device = canvas->getDevice();
+ if (content_rect.width() == device->width() &&
+ content_rect.height() == device->height()) {
+ canvas->clear(SK_ColorTRANSPARENT);
+ } else {
+ SkPaint paint;
+ paint.setAntiAlias(false);
+ paint.setXfermodeMode(SkXfermode::kClear_Mode);
+ canvas->drawRect(layer_sk_rect, paint);
enne (OOO) 2013/08/27 17:13:04 Could you just have the first branch of this if/el
+ }
+ }
+
canvas->clipRect(layer_sk_rect);
gfx::RectF opaque_layer_rect;
@@ -71,4 +85,8 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
content_rect_ = content_rect;
}
+void ContentLayerUpdater::SetOpaque(bool opaque) {
+ layer_is_opaque_ = opaque;
+}
+
} // namespace cc
« no previous file with comments | « cc/resources/content_layer_updater.h ('k') | cc/resources/skpicture_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698