OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_QUADS_DRAW_QUAD_H_ | 5 #ifndef CC_QUADS_DRAW_QUAD_H_ |
6 #define CC_QUADS_DRAW_QUAD_H_ | 6 #define CC_QUADS_DRAW_QUAD_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/quads/shared_quad_state.h" | 10 #include "cc/quads/shared_quad_state.h" |
11 #include "cc/resources/resource_provider.h" | 11 #include "cc/resources/resource_provider.h" |
12 | 12 |
| 13 namespace base { |
| 14 class Value; |
| 15 class DictionaryValue; |
| 16 } |
| 17 |
13 namespace cc { | 18 namespace cc { |
14 | 19 |
15 // DrawQuad is a bag of data used for drawing a quad. Because different | 20 // DrawQuad is a bag of data used for drawing a quad. Because different |
16 // materials need different bits of per-quad data to render, classes that derive | 21 // materials need different bits of per-quad data to render, classes that derive |
17 // from DrawQuad store additional data in their derived instance. The Material | 22 // from DrawQuad store additional data in their derived instance. The Material |
18 // enum is used to "safely" downcast to the derived class. | 23 // enum is used to "safely" downcast to the derived class. |
| 24 // Note: quads contain rects and sizes, which live in different spaces. There is |
| 25 // the "content space", which is the arbitrary space in which the quad's |
| 26 // geometry is defined (generally related to the layer that produced the quad, |
| 27 // e.g. the content space for TiledLayerImpls, or the geometry space for |
| 28 // PictureLayerImpls). There is also the "target space", which is the space, in |
| 29 // "physical" pixels, of the render target where the quads is drawn. The quad's |
| 30 // transform maps the content space to the target space. |
19 class CC_EXPORT DrawQuad { | 31 class CC_EXPORT DrawQuad { |
20 public: | 32 public: |
21 enum Material { | 33 enum Material { |
22 INVALID, | 34 INVALID, |
23 CHECKERBOARD, | 35 CHECKERBOARD, |
24 DEBUG_BORDER, | 36 DEBUG_BORDER, |
25 IO_SURFACE_CONTENT, | 37 IO_SURFACE_CONTENT, |
26 PICTURE_CONTENT, | 38 PICTURE_CONTENT, |
27 RENDER_PASS, | 39 RENDER_PASS, |
28 TEXTURE_CONTENT, | 40 TEXTURE_CONTENT, |
(...skipping 15 matching lines...) Expand all Loading... |
44 gfx::Rect visibleContentRect() const { | 56 gfx::Rect visibleContentRect() const { |
45 return shared_quad_state->visible_content_rect; | 57 return shared_quad_state->visible_content_rect; |
46 } | 58 } |
47 gfx::Rect clipRect() const { return shared_quad_state->clip_rect; } | 59 gfx::Rect clipRect() const { return shared_quad_state->clip_rect; } |
48 bool isClipped() const { return shared_quad_state->is_clipped; } | 60 bool isClipped() const { return shared_quad_state->is_clipped; } |
49 float opacity() const { return shared_quad_state->opacity; } | 61 float opacity() const { return shared_quad_state->opacity; } |
50 | 62 |
51 Material material; | 63 Material material; |
52 | 64 |
53 // This rect, after applying the quad_transform(), gives the geometry that | 65 // This rect, after applying the quad_transform(), gives the geometry that |
54 // this quad should draw to. | 66 // this quad should draw to. This rect lives in content space. |
55 gfx::Rect rect; | 67 gfx::Rect rect; |
56 | 68 |
57 // This specifies the region of the quad that is opaque. | 69 // This specifies the region of the quad that is opaque. This rect lives in |
| 70 // content space. |
58 gfx::Rect opaque_rect; | 71 gfx::Rect opaque_rect; |
59 | 72 |
60 // Allows changing the rect that gets drawn to make it smaller. This value | 73 // Allows changing the rect that gets drawn to make it smaller. This value |
61 // should be clipped to |rect|. | 74 // should be clipped to |rect|. This rect lives in content space. |
62 gfx::Rect visible_rect; | 75 gfx::Rect visible_rect; |
63 | 76 |
64 // By default blending is used when some part of the quad is not opaque. | 77 // By default blending is used when some part of the quad is not opaque. |
65 // With this setting, it is possible to force blending on regardless of the | 78 // With this setting, it is possible to force blending on regardless of the |
66 // opaque area. | 79 // opaque area. |
67 bool needs_blending; | 80 bool needs_blending; |
68 | 81 |
69 // Stores state common to a large bundle of quads; kept separate for memory | 82 // Stores state common to a large bundle of quads; kept separate for memory |
70 // efficiency. There is special treatment to reconstruct these pointers | 83 // efficiency. There is special treatment to reconstruct these pointers |
71 // during serialization. | 84 // during serialization. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 bool IsBottomEdge() const { | 117 bool IsBottomEdge() const { |
105 return rect.bottom() == shared_quad_state->content_bounds.height(); | 118 return rect.bottom() == shared_quad_state->content_bounds.height(); |
106 } | 119 } |
107 | 120 |
108 // Is any edge of this tile aligned with the originating layer's | 121 // Is any edge of this tile aligned with the originating layer's |
109 // corresponding edge? | 122 // corresponding edge? |
110 bool IsEdge() const { | 123 bool IsEdge() const { |
111 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); | 124 return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); |
112 } | 125 } |
113 | 126 |
| 127 scoped_ptr<base::Value> AsValue() const; |
| 128 |
114 protected: | 129 protected: |
115 DrawQuad(); | 130 DrawQuad(); |
116 | 131 |
117 void SetAll(const SharedQuadState* shared_quad_state, | 132 void SetAll(const SharedQuadState* shared_quad_state, |
118 Material material, | 133 Material material, |
119 gfx::Rect rect, | 134 gfx::Rect rect, |
120 gfx::Rect opaque_rect, | 135 gfx::Rect opaque_rect, |
121 gfx::Rect visible_rect, | 136 gfx::Rect visible_rect, |
122 bool needs_blending); | 137 bool needs_blending); |
| 138 virtual void ExtendValue(base::DictionaryValue* value) const = 0; |
123 }; | 139 }; |
124 | 140 |
125 } // namespace cc | 141 } // namespace cc |
126 | 142 |
127 #endif // CC_QUADS_DRAW_QUAD_H_ | 143 #endif // CC_QUADS_DRAW_QUAD_H_ |
OLD | NEW |