| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/content_layer_updater.h" | 5 #include "cc/resources/content_layer_updater.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "cc/debug/rendering_stats_instrumentation.h" | 9 #include "cc/debug/rendering_stats_instrumentation.h" |
| 10 #include "cc/resources/layer_painter.h" | 10 #include "cc/resources/layer_painter.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 canvas->scale(SkFloatToScalar(contents_width_scale), | 55 canvas->scale(SkFloatToScalar(contents_width_scale), |
| 56 SkFloatToScalar(contents_height_scale)); | 56 SkFloatToScalar(contents_height_scale)); |
| 57 | 57 |
| 58 layer_rect = gfx::ScaleToEnclosingRect( | 58 layer_rect = gfx::ScaleToEnclosingRect( |
| 59 content_rect, 1.f / contents_width_scale, 1.f / contents_height_scale); | 59 content_rect, 1.f / contents_width_scale, 1.f / contents_height_scale); |
| 60 } | 60 } |
| 61 | 61 |
| 62 SkRect layer_sk_rect = SkRect::MakeXYWH( | 62 SkRect layer_sk_rect = SkRect::MakeXYWH( |
| 63 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height()); | 63 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height()); |
| 64 | 64 |
| 65 canvas->clipRect(layer_sk_rect); |
| 66 |
| 65 // If the layer has opaque contents then there is no need to | 67 // If the layer has opaque contents then there is no need to |
| 66 // clear the canvas before painting. | 68 // clear the canvas before painting. |
| 67 if (!layer_is_opaque_) | 69 if (!layer_is_opaque_) { |
| 68 canvas->clear(SK_ColorTRANSPARENT); | 70 TRACE_EVENT0("cc", "Clear"); |
| 69 | 71 canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode); |
| 70 canvas->clipRect(layer_sk_rect); | 72 } |
| 71 | 73 |
| 72 gfx::RectF opaque_layer_rect; | 74 gfx::RectF opaque_layer_rect; |
| 73 painter_->Paint(canvas, layer_rect, &opaque_layer_rect); | 75 painter_->Paint(canvas, layer_rect, &opaque_layer_rect); |
| 74 canvas->restore(); | 76 canvas->restore(); |
| 75 | 77 |
| 76 gfx::Rect opaque_content_rect = gfx::ToEnclosedRect(gfx::ScaleRect( | 78 gfx::Rect opaque_content_rect = gfx::ToEnclosedRect(gfx::ScaleRect( |
| 77 opaque_layer_rect, contents_width_scale, contents_height_scale)); | 79 opaque_layer_rect, contents_width_scale, contents_height_scale)); |
| 78 *resulting_opaque_rect = opaque_content_rect; | 80 *resulting_opaque_rect = opaque_content_rect; |
| 79 | 81 |
| 80 content_rect_ = content_rect; | 82 content_rect_ = content_rect; |
| 81 } | 83 } |
| 82 | 84 |
| 83 void ContentLayerUpdater::SetOpaque(bool opaque) { | 85 void ContentLayerUpdater::SetOpaque(bool opaque) { |
| 84 layer_is_opaque_ = opaque; | 86 layer_is_opaque_ = opaque; |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace cc | 89 } // namespace cc |
| OLD | NEW |