| 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, |
| 32 RenderingStats* stats) OVERRIDE; | 33 RenderingStats* stats) OVERRIDE; |
| 33 | 34 |
| 34 private: | 35 private: |
| 35 BitmapContentLayerUpdater* updater_; | 36 BitmapContentLayerUpdater* updater_; |
| 36 | 37 |
| 37 DISALLOW_COPY_AND_ASSIGN(Resource); | 38 DISALLOW_COPY_AND_ASSIGN(Resource); |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 static scoped_refptr<BitmapContentLayerUpdater> Create( | 41 static scoped_refptr<BitmapContentLayerUpdater> Create( |
| 41 scoped_ptr<LayerPainter> painter); | 42 scoped_ptr<LayerPainter> painter, |
| 43 RenderingStatsInstrumentation* stats_instrumenation); |
| 42 | 44 |
| 43 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( | 45 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( |
| 44 PrioritizedResourceManager* manager) OVERRIDE; | 46 PrioritizedResourceManager* manager) OVERRIDE; |
| 45 virtual void PrepareToUpdate(gfx::Rect content_rect, | 47 virtual void PrepareToUpdate(gfx::Rect content_rect, |
| 46 gfx::Size tile_size, | 48 gfx::Size tile_size, |
| 47 float contents_width_scale, | 49 float contents_width_scale, |
| 48 float contents_height_scale, | 50 float contents_height_scale, |
| 49 gfx::Rect* resulting_opaque_rect, | 51 gfx::Rect* resulting_opaque_rect, |
| 50 RenderingStats* stats) OVERRIDE; | 52 RenderingStats* stats) OVERRIDE; |
| 51 void UpdateTexture(ResourceUpdateQueue* queue, | 53 void UpdateTexture(ResourceUpdateQueue* queue, |
| 52 PrioritizedResource* resource, | 54 PrioritizedResource* resource, |
| 53 gfx::Rect source_rect, | 55 gfx::Rect source_rect, |
| 54 gfx::Vector2d dest_offset, | 56 gfx::Vector2d dest_offset, |
| 55 bool partial_update); | 57 bool partial_update); |
| 56 | 58 |
| 57 virtual void SetOpaque(bool opaque) OVERRIDE; | 59 virtual void SetOpaque(bool opaque) OVERRIDE; |
| 58 | 60 |
| 59 protected: | 61 protected: |
| 60 explicit BitmapContentLayerUpdater(scoped_ptr<LayerPainter> painter); | 62 BitmapContentLayerUpdater( |
| 63 scoped_ptr<LayerPainter> painter, |
| 64 RenderingStatsInstrumentation* stats_instrumenation); |
| 61 virtual ~BitmapContentLayerUpdater(); | 65 virtual ~BitmapContentLayerUpdater(); |
| 62 | 66 |
| 63 scoped_ptr<SkCanvas> canvas_; | 67 scoped_ptr<SkCanvas> canvas_; |
| 64 gfx::Size canvas_size_; | 68 gfx::Size canvas_size_; |
| 65 bool opaque_; | 69 bool opaque_; |
| 66 | 70 |
| 67 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater); | 71 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater); |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 } // namespace cc | 74 } // namespace cc |
| 71 | 75 |
| 72 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | 76 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ |
| OLD | NEW |