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/bitmap_skpicture_content_layer_updater.h" | 5 #include "cc/resources/bitmap_skpicture_content_layer_updater.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.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/content_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 BitmapSkPictureContentLayerUpdater::Resource::Resource( | 16 BitmapSkPictureContentLayerUpdater::Resource::Resource( |
17 BitmapSkPictureContentLayerUpdater* updater, | 17 BitmapSkPictureContentLayerUpdater* updater, |
18 scoped_ptr<PrioritizedResource> texture) | 18 scoped_ptr<PrioritizedResource> texture) |
19 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {} | 19 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {} |
(...skipping 13 matching lines...) Expand all Loading... |
33 ResourceUpdate upload = ResourceUpdate::Create( | 33 ResourceUpdate upload = ResourceUpdate::Create( |
34 texture(), &bitmap_, source_rect, source_rect, dest_offset); | 34 texture(), &bitmap_, source_rect, source_rect, dest_offset); |
35 if (partial_update) | 35 if (partial_update) |
36 queue->AppendPartialUpload(upload); | 36 queue->AppendPartialUpload(upload); |
37 else | 37 else |
38 queue->AppendFullUpload(upload); | 38 queue->AppendFullUpload(upload); |
39 } | 39 } |
40 | 40 |
41 scoped_refptr<BitmapSkPictureContentLayerUpdater> | 41 scoped_refptr<BitmapSkPictureContentLayerUpdater> |
42 BitmapSkPictureContentLayerUpdater::Create( | 42 BitmapSkPictureContentLayerUpdater::Create( |
43 scoped_ptr<LayerPainter> painter, | 43 scoped_ptr<ContentLayerPainter> painter, |
44 RenderingStatsInstrumentation* stats_instrumentation, | 44 RenderingStatsInstrumentation* stats_instrumentation, |
45 int layer_id) { | 45 int layer_id) { |
46 return make_scoped_refptr( | 46 return make_scoped_refptr( |
47 new BitmapSkPictureContentLayerUpdater(painter.Pass(), | 47 new BitmapSkPictureContentLayerUpdater(painter.Pass(), |
48 stats_instrumentation, | 48 stats_instrumentation, |
49 layer_id)); | 49 layer_id)); |
50 } | 50 } |
51 | 51 |
52 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( | 52 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( |
53 scoped_ptr<LayerPainter> painter, | 53 scoped_ptr<ContentLayerPainter> painter, |
54 RenderingStatsInstrumentation* stats_instrumentation, | 54 RenderingStatsInstrumentation* stats_instrumentation, |
55 int layer_id) | 55 int layer_id) |
56 : SkPictureContentLayerUpdater(painter.Pass(), | 56 : SkPictureContentLayerUpdater(painter.Pass(), |
57 stats_instrumentation, | 57 stats_instrumentation, |
58 layer_id) {} | 58 layer_id) { |
| 59 } |
59 | 60 |
60 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} | 61 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} |
61 | 62 |
62 scoped_ptr<LayerUpdater::Resource> | 63 scoped_ptr<LayerUpdater::Resource> |
63 BitmapSkPictureContentLayerUpdater::CreateResource( | 64 BitmapSkPictureContentLayerUpdater::CreateResource( |
64 PrioritizedResourceManager* manager) { | 65 PrioritizedResourceManager* manager) { |
65 return scoped_ptr<LayerUpdater::Resource>( | 66 return scoped_ptr<LayerUpdater::Resource>( |
66 new Resource(this, PrioritizedResource::Create(manager))); | 67 new Resource(this, PrioritizedResource::Create(manager))); |
67 } | 68 } |
68 | 69 |
69 void BitmapSkPictureContentLayerUpdater::PaintContentsRect( | 70 void BitmapSkPictureContentLayerUpdater::PaintContentsRect( |
70 SkCanvas* canvas, | 71 SkCanvas* canvas, |
71 const gfx::Rect& source_rect) { | 72 const gfx::Rect& source_rect) { |
72 if (!canvas) | 73 if (!canvas) |
73 return; | 74 return; |
74 // Translate the origin of content_rect to that of source_rect. | 75 // Translate the origin of content_rect to that of source_rect. |
75 canvas->translate(content_rect().x() - source_rect.x(), | 76 canvas->translate(content_rect().x() - source_rect.x(), |
76 content_rect().y() - source_rect.y()); | 77 content_rect().y() - source_rect.y()); |
77 base::TimeTicks start_time = | 78 base::TimeTicks start_time = |
78 rendering_stats_instrumentation_->StartRecording(); | 79 rendering_stats_instrumentation_->StartRecording(); |
79 DrawPicture(canvas); | 80 DrawPicture(canvas); |
80 base::TimeDelta duration = | 81 base::TimeDelta duration = |
81 rendering_stats_instrumentation_->EndRecording(start_time); | 82 rendering_stats_instrumentation_->EndRecording(start_time); |
82 rendering_stats_instrumentation_->AddRaster( | 83 rendering_stats_instrumentation_->AddRaster( |
83 duration, | 84 duration, |
84 source_rect.width() * source_rect.height()); | 85 source_rect.width() * source_rect.height()); |
85 } | 86 } |
86 | 87 |
87 } // namespace cc | 88 } // namespace cc |
OLD | NEW |