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 #ifndef CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | 5 #ifndef CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ |
6 #define CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | 6 #define CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ |
7 | 7 |
8 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
9 #include "cc/resources/content_layer_updater.h" | 9 #include "cc/resources/content_layer_updater.h" |
10 | 10 |
11 class SkCanvas; | 11 class SkCanvas; |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 class LayerPainter; | 15 class LayerPainter; |
| 16 class RenderingStatsInstrumenation; |
16 | 17 |
17 // This class rasterizes the content_rect into a skia bitmap canvas. It then | 18 // This class rasterizes the content_rect into a skia bitmap canvas. It then |
18 // updates textures by copying from the canvas into the texture, using | 19 // updates textures by copying from the canvas into the texture, using |
19 // MapSubImage if possible. | 20 // MapSubImage if possible. |
20 class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { | 21 class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { |
21 public: | 22 public: |
22 class Resource : public LayerUpdater::Resource { | 23 class Resource : public LayerUpdater::Resource { |
23 public: | 24 public: |
24 Resource(BitmapContentLayerUpdater* updater, | 25 Resource(BitmapContentLayerUpdater* updater, |
25 scoped_ptr<PrioritizedResource> resource); | 26 scoped_ptr<PrioritizedResource> resource); |
26 virtual ~Resource(); | 27 virtual ~Resource(); |
27 | 28 |
28 virtual void Update(ResourceUpdateQueue* queue, | 29 virtual void Update(ResourceUpdateQueue* queue, |
29 gfx::Rect source_rect, | 30 gfx::Rect source_rect, |
30 gfx::Vector2d dest_offset, | 31 gfx::Vector2d dest_offset, |
31 bool partial_update, | 32 bool partial_update) OVERRIDE; |
32 RenderingStats* stats) OVERRIDE; | |
33 | 33 |
34 private: | 34 private: |
35 BitmapContentLayerUpdater* updater_; | 35 BitmapContentLayerUpdater* updater_; |
36 | 36 |
37 DISALLOW_COPY_AND_ASSIGN(Resource); | 37 DISALLOW_COPY_AND_ASSIGN(Resource); |
38 }; | 38 }; |
39 | 39 |
40 static scoped_refptr<BitmapContentLayerUpdater> Create( | 40 static scoped_refptr<BitmapContentLayerUpdater> Create( |
41 scoped_ptr<LayerPainter> painter); | 41 scoped_ptr<LayerPainter> painter, |
| 42 RenderingStatsInstrumentation* stats_instrumenation); |
42 | 43 |
43 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( | 44 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( |
44 PrioritizedResourceManager* manager) OVERRIDE; | 45 PrioritizedResourceManager* manager) OVERRIDE; |
45 virtual void PrepareToUpdate(gfx::Rect content_rect, | 46 virtual void PrepareToUpdate(gfx::Rect content_rect, |
46 gfx::Size tile_size, | 47 gfx::Size tile_size, |
47 float contents_width_scale, | 48 float contents_width_scale, |
48 float contents_height_scale, | 49 float contents_height_scale, |
49 gfx::Rect* resulting_opaque_rect, | 50 gfx::Rect* resulting_opaque_rect) OVERRIDE; |
50 RenderingStats* stats) OVERRIDE; | |
51 void UpdateTexture(ResourceUpdateQueue* queue, | 51 void UpdateTexture(ResourceUpdateQueue* queue, |
52 PrioritizedResource* resource, | 52 PrioritizedResource* resource, |
53 gfx::Rect source_rect, | 53 gfx::Rect source_rect, |
54 gfx::Vector2d dest_offset, | 54 gfx::Vector2d dest_offset, |
55 bool partial_update); | 55 bool partial_update); |
56 | 56 |
57 virtual void SetOpaque(bool opaque) OVERRIDE; | 57 virtual void SetOpaque(bool opaque) OVERRIDE; |
58 | 58 |
59 protected: | 59 protected: |
60 explicit BitmapContentLayerUpdater(scoped_ptr<LayerPainter> painter); | 60 BitmapContentLayerUpdater( |
| 61 scoped_ptr<LayerPainter> painter, |
| 62 RenderingStatsInstrumentation* stats_instrumenation); |
61 virtual ~BitmapContentLayerUpdater(); | 63 virtual ~BitmapContentLayerUpdater(); |
62 | 64 |
63 scoped_ptr<SkCanvas> canvas_; | 65 scoped_ptr<SkCanvas> canvas_; |
64 gfx::Size canvas_size_; | 66 gfx::Size canvas_size_; |
65 bool opaque_; | 67 bool opaque_; |
66 | 68 |
67 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater); | 69 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater); |
68 }; | 70 }; |
69 | 71 |
70 } // namespace cc | 72 } // namespace cc |
71 | 73 |
72 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | 74 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ |
OLD | NEW |