OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | |
6 #define CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | |
7 | |
8 #include "cc/content_layer_updater.h" | |
9 #include "third_party/skia/include/core/SkPicture.h" | |
10 | |
11 class SkCanvas; | |
12 | |
13 namespace cc { | |
14 | |
15 class LayerPainter; | |
16 | |
17 // This class records the content_rect into an SkPicture. Subclasses, provide | |
18 // different implementations of tile updating based on this recorded picture. | |
19 // The BitmapSkPictureContentLayerUpdater and | |
20 // FrameBufferSkPictureContentLayerUpdater are two examples of such | |
21 // implementations. | |
22 class SkPictureContentLayerUpdater : public ContentLayerUpdater { | |
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 | |
45 virtual scoped_ptr<LayerUpdater::Resource> CreateResource( | |
46 PrioritizedResourceManager* manager) OVERRIDE; | |
47 virtual void SetOpaque(bool opaque) OVERRIDE; | |
48 | |
49 protected: | |
50 explicit SkPictureContentLayerUpdater(scoped_ptr<LayerPainter> painter); | |
51 virtual ~SkPictureContentLayerUpdater(); | |
52 | |
53 virtual void PrepareToUpdate(gfx::Rect content_rect, | |
54 gfx::Size tile_size, | |
55 float contents_width_scale, | |
56 float contents_height_scale, | |
57 gfx::Rect* resulting_opaque_rect, | |
58 RenderingStats* stats) OVERRIDE; | |
59 void DrawPicture(SkCanvas* canvas); | |
60 void UpdateTexture(ResourceUpdateQueue* queue, | |
61 PrioritizedResource* texture, | |
62 gfx::Rect source_rect, | |
63 gfx::Vector2d dest_offset, | |
64 bool partial_update); | |
65 | |
66 bool layer_is_opaque() const { return layer_is_opaque_; } | |
67 | |
68 private: | |
69 // Recording canvas. | |
70 SkPicture picture_; | |
71 // True when it is known that all output pixels will be opaque. | |
72 bool layer_is_opaque_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(SkPictureContentLayerUpdater); | |
75 }; | |
76 | |
77 } // namespace cc | |
78 | |
79 #endif // CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_ | |
OLD | NEW |