Chromium Code Reviews| Index: cc/resources/content_layer_updater.cc |
| diff --git a/cc/resources/content_layer_updater.cc b/cc/resources/content_layer_updater.cc |
| index 92cabf2c66da9175da7cde477688eb4e353224e1..4a0fbf2605ff5bd7c0ac33d0ab3e6ae883514b76 100644 |
| --- a/cc/resources/content_layer_updater.cc |
| +++ b/cc/resources/content_layer_updater.cc |
| @@ -62,12 +62,24 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas, |
| SkRect layer_sk_rect = SkRect::MakeXYWH( |
| layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height()); |
| + canvas->clipRect(layer_sk_rect); |
| + |
| // 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); |
| + if (!layer_is_opaque_) { |
| + TRACE_EVENT0("cc", "Clear"); |
| + |
| + // If the canvas is substantially larger than the area that will be painted |
| + // then it's faster to clear only the pixels within the clipRect. |
| + const float kClearFasterThanDrawRatio = 0.8f; |
| + int canvasArea = |
|
enne (OOO)
2013/11/06 01:59:45
canvasArea => canvas_area
|
| + canvas->getDevice()->width() * canvas->getDevice()->height(); |
| + int clipArea = layer_rect.width() * layer_rect.height(); |
|
enne (OOO)
2013/11/06 01:59:45
clipArea => clip_area
|
| + if (kClearFasterThanDrawRatio * canvasArea < clipArea) |
| + canvas->clear(SK_ColorTRANSPARENT); |
| + else |
| + canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode); |
| + } |
| gfx::RectF opaque_layer_rect; |
| painter_->Paint(canvas, layer_rect, &opaque_layer_rect); |