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 |