| 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_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 5 #ifndef CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| 6 #define CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 6 #define CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| 7 | 7 |
| 8 #include "cc/resources/content_layer_updater.h" | 8 #include "cc/resources/content_layer_updater.h" |
| 9 #include "third_party/skia/include/core/SkPicture.h" | 9 #include "third_party/skia/include/core/SkPicture.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 | 16 |
| 17 // This class records the content_rect into an SkPicture. Subclasses, provide | 17 // This class records the content_rect into an SkPicture. Subclasses, provide |
| 18 // different implementations of tile updating based on this recorded picture. | 18 // different implementations of tile updating based on this recorded picture. |
| 19 // The BitmapSkPictureContentLayerUpdater and | 19 // The BitmapSkPictureContentLayerUpdater and |
| 20 // FrameBufferSkPictureContentLayerUpdater are two examples of such | 20 // FrameBufferSkPictureContentLayerUpdater are two examples of such |
| 21 // implementations. | 21 // implementations. |
| 22 class SkPictureContentLayerUpdater : public ContentLayerUpdater { | 22 class SkPictureContentLayerUpdater : public ContentLayerUpdater { |
| 23 public: | 23 public: |
| 24 class Resource : public LayerUpdater::Resource { | |
| 25 public: | |
| 26 Resource(SkPictureContentLayerUpdater* updater, | |
| 27 scoped_ptr<PrioritizedResource> texture); | |
| 28 virtual ~Resource(); | |
| 29 | |
| 30 virtual void Update(ResourceUpdateQueue* queue, | |
| 31 gfx::Rect source_rect, | |
| 32 gfx::Vector2d dest_offset, | |
| 33 bool partial_update, | |
| 34 RenderingStats* stats) OVERRIDE; | |
| 35 | |
| 36 private: | |
| 37 SkPictureContentLayerUpdater* updater_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(Resource); | |
| 40 }; | |
| 41 | |
| 42 static scoped_refptr<SkPictureContentLayerUpdater> Create( | |
| 43 scoped_ptr<LayerPainter> painter, | |
| 44 RenderingStatsInstrumentation* stats_instrumentation, | |
| 45 int layer_id); | |
| 46 | |
| 47 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( | |
| 48 PrioritizedResourceManager* manager) OVERRIDE; | |
| 49 virtual void SetOpaque(bool opaque) OVERRIDE; | 24 virtual void SetOpaque(bool opaque) OVERRIDE; |
| 50 | 25 |
| 51 protected: | 26 protected: |
| 52 SkPictureContentLayerUpdater( | 27 SkPictureContentLayerUpdater( |
| 53 scoped_ptr<LayerPainter> painter, | 28 scoped_ptr<LayerPainter> painter, |
| 54 RenderingStatsInstrumentation* stats_instrumentation, | 29 RenderingStatsInstrumentation* stats_instrumentation, |
| 55 int layer_id); | 30 int layer_id); |
| 56 virtual ~SkPictureContentLayerUpdater(); | 31 virtual ~SkPictureContentLayerUpdater(); |
| 57 | 32 |
| 58 virtual void PrepareToUpdate(gfx::Rect content_rect, | 33 virtual void PrepareToUpdate(gfx::Rect content_rect, |
| 59 gfx::Size tile_size, | 34 gfx::Size tile_size, |
| 60 float contents_width_scale, | 35 float contents_width_scale, |
| 61 float contents_height_scale, | 36 float contents_height_scale, |
| 62 gfx::Rect* resulting_opaque_rect, | 37 gfx::Rect* resulting_opaque_rect, |
| 63 RenderingStats* stats) OVERRIDE; | 38 RenderingStats* stats) OVERRIDE; |
| 64 void DrawPicture(SkCanvas* canvas); | 39 void DrawPicture(SkCanvas* canvas); |
| 65 void UpdateTexture(ResourceUpdateQueue* queue, | |
| 66 PrioritizedResource* texture, | |
| 67 gfx::Rect source_rect, | |
| 68 gfx::Vector2d dest_offset, | |
| 69 bool partial_update); | |
| 70 | 40 |
| 71 bool layer_is_opaque() const { return layer_is_opaque_; } | 41 bool layer_is_opaque() const { return layer_is_opaque_; } |
| 72 | 42 |
| 73 private: | 43 private: |
| 74 // Recording canvas. | 44 // Recording canvas. |
| 75 SkPicture picture_; | 45 SkPicture picture_; |
| 76 // True when it is known that all output pixels will be opaque. | 46 // True when it is known that all output pixels will be opaque. |
| 77 bool layer_is_opaque_; | 47 bool layer_is_opaque_; |
| 78 | 48 |
| 79 DISALLOW_COPY_AND_ASSIGN(SkPictureContentLayerUpdater); | 49 DISALLOW_COPY_AND_ASSIGN(SkPictureContentLayerUpdater); |
| 80 }; | 50 }; |
| 81 | 51 |
| 82 } // namespace cc | 52 } // namespace cc |
| 83 | 53 |
| 84 #endif // CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 54 #endif // CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| OLD | NEW |