| 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 19 matching lines...) Expand all Loading... |
| 30 ContentLayerUpdater::~ContentLayerUpdater() {} | 30 ContentLayerUpdater::~ContentLayerUpdater() {} |
| 31 | 31 |
| 32 void ContentLayerUpdater::set_rendering_stats_instrumentation( | 32 void ContentLayerUpdater::set_rendering_stats_instrumentation( |
| 33 RenderingStatsInstrumentation* rsi) { | 33 RenderingStatsInstrumentation* rsi) { |
| 34 rendering_stats_instrumentation_ = rsi; | 34 rendering_stats_instrumentation_ = rsi; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ContentLayerUpdater::PaintContents(SkCanvas* canvas, | 37 void ContentLayerUpdater::PaintContents(SkCanvas* canvas, |
| 38 const gfx::Rect& content_rect, | 38 const gfx::Rect& content_rect, |
| 39 float contents_width_scale, | 39 float contents_width_scale, |
| 40 float contents_height_scale, | 40 float contents_height_scale) { |
| 41 gfx::Rect* resulting_opaque_rect) { | |
| 42 TRACE_EVENT0("cc", "ContentLayerUpdater::PaintContents"); | 41 TRACE_EVENT0("cc", "ContentLayerUpdater::PaintContents"); |
| 43 if (!canvas) | 42 if (!canvas) |
| 44 return; | 43 return; |
| 45 canvas->save(); | 44 canvas->save(); |
| 46 canvas->translate(SkFloatToScalar(-content_rect.x()), | 45 canvas->translate(SkFloatToScalar(-content_rect.x()), |
| 47 SkFloatToScalar(-content_rect.y())); | 46 SkFloatToScalar(-content_rect.y())); |
| 48 | 47 |
| 49 // The |canvas| backing should be sized to hold the |content_rect|. | 48 // The |canvas| backing should be sized to hold the |content_rect|. |
| 50 DCHECK_EQ(content_rect.width(), canvas->getBaseLayerSize().width()); | 49 DCHECK_EQ(content_rect.width(), canvas->getBaseLayerSize().width()); |
| 51 DCHECK_EQ(content_rect.height(), canvas->getBaseLayerSize().height()); | 50 DCHECK_EQ(content_rect.height(), canvas->getBaseLayerSize().height()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 | 63 |
| 65 canvas->clipRect(layer_sk_rect); | 64 canvas->clipRect(layer_sk_rect); |
| 66 | 65 |
| 67 // If the layer has opaque contents or will fill the bounds completely there | 66 // If the layer has opaque contents or will fill the bounds completely there |
| 68 // is no need to clear the canvas before painting. | 67 // is no need to clear the canvas before painting. |
| 69 if (!layer_is_opaque_ && !layer_fills_bounds_completely_) { | 68 if (!layer_is_opaque_ && !layer_fills_bounds_completely_) { |
| 70 TRACE_EVENT0("cc", "Clear"); | 69 TRACE_EVENT0("cc", "Clear"); |
| 71 canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode); | 70 canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode); |
| 72 } | 71 } |
| 73 | 72 |
| 74 gfx::RectF opaque_layer_rect; | 73 painter_->Paint(canvas, layer_rect); |
| 75 painter_->Paint(canvas, layer_rect, &opaque_layer_rect); | |
| 76 canvas->restore(); | 74 canvas->restore(); |
| 77 | 75 |
| 78 gfx::Rect opaque_content_rect = gfx::ToEnclosedRect(gfx::ScaleRect( | |
| 79 opaque_layer_rect, contents_width_scale, contents_height_scale)); | |
| 80 *resulting_opaque_rect = opaque_content_rect; | |
| 81 | |
| 82 content_rect_ = content_rect; | 76 content_rect_ = content_rect; |
| 83 } | 77 } |
| 84 | 78 |
| 85 void ContentLayerUpdater::SetOpaque(bool opaque) { | 79 void ContentLayerUpdater::SetOpaque(bool opaque) { |
| 86 layer_is_opaque_ = opaque; | 80 layer_is_opaque_ = opaque; |
| 87 } | 81 } |
| 88 | 82 |
| 89 void ContentLayerUpdater::SetFillsBoundsCompletely(bool fills_bounds) { | 83 void ContentLayerUpdater::SetFillsBoundsCompletely(bool fills_bounds) { |
| 90 layer_fills_bounds_completely_ = fills_bounds; | 84 layer_fills_bounds_completely_ = fills_bounds; |
| 91 } | 85 } |
| 92 | 86 |
| 93 } // namespace cc | 87 } // namespace cc |
| OLD | NEW |