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

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: Remove unecessary newline 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..50ea86bd35c68d868bde8c59de677c49184aafad 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() {}
@@ -33,14 +35,17 @@ void ContentLayerUpdater::set_rendering_stats_instrumentation(
}
void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
- gfx::Rect content_rect,
+ gfx::Point origin,
float contents_width_scale,
float contents_height_scale,
gfx::Rect* resulting_opaque_rect) {
TRACE_EVENT0("cc", "ContentLayerUpdater::PaintContents");
canvas->save();
- canvas->translate(SkFloatToScalar(-content_rect.x()),
- SkFloatToScalar(-content_rect.y()));
+ canvas->translate(SkFloatToScalar(-origin.x()),
+ SkFloatToScalar(-origin.y()));
+
+ SkDevice* device = canvas->getDevice();
+ gfx::Rect content_rect(origin, gfx::Size(device->width(), device->height()));
gfx::Rect layer_rect = content_rect;
@@ -52,12 +57,14 @@ 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_)
+ canvas->clear(SK_ColorTRANSPARENT);
+
canvas->clipRect(layer_sk_rect);
gfx::RectF opaque_layer_rect;
@@ -71,4 +78,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