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/skpicture_content_layer_updater.h" | 5 #include "cc/resources/skpicture_content_layer_updater.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/debug/rendering_stats_instrumentation.h" | 8 #include "cc/debug/rendering_stats_instrumentation.h" |
9 #include "cc/resources/layer_painter.h" | 9 #include "cc/resources/layer_painter.h" |
10 #include "cc/resources/prioritized_resource.h" | 10 #include "cc/resources/prioritized_resource.h" |
11 #include "cc/resources/resource_update_queue.h" | 11 #include "cc/resources/resource_update_queue.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 SkPictureContentLayerUpdater::SkPictureContentLayerUpdater( | 16 SkPictureContentLayerUpdater::SkPictureContentLayerUpdater( |
17 scoped_ptr<LayerPainter> painter, | 17 scoped_ptr<LayerPainter> painter, |
18 RenderingStatsInstrumentation* stats_instrumentation, | 18 RenderingStatsInstrumentation* stats_instrumentation, |
19 int layer_id) | 19 int layer_id) |
20 : ContentLayerUpdater(painter.Pass(), stats_instrumentation, layer_id) {} | 20 : ContentLayerUpdater(painter.Pass(), stats_instrumentation, layer_id) {} |
21 | 21 |
22 SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() {} | 22 SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() {} |
23 | 23 |
24 void SkPictureContentLayerUpdater::PrepareToUpdate( | 24 void SkPictureContentLayerUpdater::PrepareToUpdate( |
25 const gfx::Rect& content_rect, | 25 const gfx::Rect& content_rect, |
26 const gfx::Size&, | 26 const gfx::Size&, |
27 float contents_width_scale, | 27 float contents_width_scale, |
28 float contents_height_scale, | 28 float contents_height_scale, |
29 gfx::Rect* resulting_opaque_rect) { | 29 gfx::Rect* resulting_opaque_rect) { |
30 SkCanvas* canvas = | 30 SkCanvas* canvas = picture_recorder_.beginRecording(content_rect.width(), |
reed1
2014/04/14 15:19:02
Why does picture_recorder_ have to be a persistent
robertphillips
2014/04/14 15:36:28
Done.
| |
31 picture_.beginRecording(content_rect.width(), content_rect.height()); | 31 content_rect.height()); |
32 DCHECK_EQ(content_rect.width(), canvas->getBaseLayerSize().width()); | 32 DCHECK_EQ(content_rect.width(), canvas->getBaseLayerSize().width()); |
33 DCHECK_EQ(content_rect.height(), canvas->getBaseLayerSize().height()); | 33 DCHECK_EQ(content_rect.height(), canvas->getBaseLayerSize().height()); |
34 base::TimeTicks start_time = | 34 base::TimeTicks start_time = |
35 rendering_stats_instrumentation_->StartRecording(); | 35 rendering_stats_instrumentation_->StartRecording(); |
36 PaintContents(canvas, | 36 PaintContents(canvas, |
37 content_rect, | 37 content_rect, |
38 contents_width_scale, | 38 contents_width_scale, |
39 contents_height_scale, | 39 contents_height_scale, |
40 resulting_opaque_rect); | 40 resulting_opaque_rect); |
41 base::TimeDelta duration = | 41 base::TimeDelta duration = |
42 rendering_stats_instrumentation_->EndRecording(start_time); | 42 rendering_stats_instrumentation_->EndRecording(start_time); |
43 rendering_stats_instrumentation_->AddRecord( | 43 rendering_stats_instrumentation_->AddRecord( |
44 duration, content_rect.width() * content_rect.height()); | 44 duration, content_rect.width() * content_rect.height()); |
45 picture_.endRecording(); | 45 picture_ = skia::AdoptRef(picture_recorder_.endRecording()); |
46 } | 46 } |
47 | 47 |
48 void SkPictureContentLayerUpdater::DrawPicture(SkCanvas* canvas) { | 48 void SkPictureContentLayerUpdater::DrawPicture(SkCanvas* canvas) { |
49 TRACE_EVENT0("cc", "SkPictureContentLayerUpdater::DrawPicture"); | 49 TRACE_EVENT0("cc", "SkPictureContentLayerUpdater::DrawPicture"); |
50 canvas->drawPicture(picture_); | 50 if (picture_) |
51 canvas->drawPicture(*picture_); | |
51 } | 52 } |
52 | 53 |
53 } // namespace cc | 54 } // namespace cc |
OLD | NEW |