| 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 | 5 |
| 6 #ifndef CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 6 #ifndef CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| 7 #define CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 7 #define CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| 8 | 8 |
| 9 #include "cc/content_layer_updater.h" | 9 #include "cc/content_layer_updater.h" |
| 10 #include "third_party/skia/include/core/SkPicture.h" | 10 #include "third_party/skia/include/core/SkPicture.h" |
| 11 | 11 |
| 12 class SkCanvas; | 12 class SkCanvas; |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class LayerPainter; | 16 class LayerPainter; |
| 17 | 17 |
| 18 // This class records the contentRect into an SkPicture. Subclasses, provide | 18 // This class records the contentRect into an SkPicture. Subclasses, provide |
| 19 // different implementations of tile updating based on this recorded picture. | 19 // different implementations of tile updating based on this recorded picture. |
| 20 // The BitmapSkPictureContentLayerUpdater and | 20 // The BitmapSkPictureContentLayerUpdater and |
| 21 // FrameBufferSkPictureContentLayerUpdater are two examples of such | 21 // FrameBufferSkPictureContentLayerUpdater are two examples of such |
| 22 // implementations. | 22 // implementations. |
| 23 class SkPictureContentLayerUpdater : public ContentLayerUpdater { | 23 class SkPictureContentLayerUpdater : public ContentLayerUpdater { |
| 24 public: | 24 public: |
| 25 class Resource : public LayerUpdater::Resource { | 25 class Resource : public LayerUpdater::Resource { |
| 26 public: | 26 public: |
| 27 Resource(SkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>)
; | 27 Resource(SkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>)
; |
| 28 virtual ~Resource(); | 28 virtual ~Resource(); |
| 29 | 29 |
| 30 virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, c
onst gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; | 30 virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, c
onst gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) OVERRIDE; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 SkPictureContentLayerUpdater* updater() { return m_updater; } | 33 SkPictureContentLayerUpdater* updater() { return m_updater; } |
| 34 | 34 |
| 35 SkPictureContentLayerUpdater* m_updater; | 35 SkPictureContentLayerUpdater* m_updater; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 static scoped_refptr<SkPictureContentLayerUpdater> create(scoped_ptr<LayerPa
inter>); | 38 static scoped_refptr<SkPictureContentLayerUpdater> create(scoped_ptr<LayerPa
inter>); |
| 39 | 39 |
| 40 virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourc
eManager*) OVERRIDE; | 40 virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourc
eManager*) OVERRIDE; |
| 41 virtual void setOpaque(bool) OVERRIDE; | 41 virtual void setOpaque(bool) OVERRIDE; |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 explicit SkPictureContentLayerUpdater(scoped_ptr<LayerPainter>); | 44 explicit SkPictureContentLayerUpdater(scoped_ptr<LayerPainter>); |
| 45 virtual ~SkPictureContentLayerUpdater(); | 45 virtual ~SkPictureContentLayerUpdater(); |
| 46 | 46 |
| 47 virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&
tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& result
ingOpaqueRect, RenderingStats&) OVERRIDE; | 47 virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&
tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& result
ingOpaqueRect, RenderingStats*) OVERRIDE; |
| 48 void drawPicture(SkCanvas*); | 48 void drawPicture(SkCanvas*); |
| 49 void updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture,
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdat
e); | 49 void updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture,
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdat
e); |
| 50 | 50 |
| 51 bool layerIsOpaque() const { return m_layerIsOpaque; } | 51 bool layerIsOpaque() const { return m_layerIsOpaque; } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 // Recording canvas. | 54 // Recording canvas. |
| 55 SkPicture m_picture; | 55 SkPicture m_picture; |
| 56 // True when it is known that all output pixels will be opaque. | 56 // True when it is known that all output pixels will be opaque. |
| 57 bool m_layerIsOpaque; | 57 bool m_layerIsOpaque; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace cc | 60 } // namespace cc |
| 61 #endif // CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | 61 #endif // CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ |
| OLD | NEW |