| 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_DRAW_QUAD_H_ | 5 #ifndef CC_DRAW_QUAD_H_ |
| 6 #define CC_DRAW_QUAD_H_ | 6 #define CC_DRAW_QUAD_H_ |
| 7 | 7 |
| 8 #include "cc/cc_export.h" | 8 #include "cc/cc_export.h" |
| 9 #include "cc/shared_quad_state.h" | 9 #include "cc/shared_quad_state.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 // WARNING! All XYZDrawQuad classes must remain PODs (plain old data). | |
| 14 // They are intended to be "serializable" by copying their raw bytes, so they | |
| 15 // must not contain any non-bit-copyable member variables! | |
| 16 // | |
| 17 // Furthermore, the class members need to be packed so they are aligned | |
| 18 // properly and don't have paddings/gaps, otherwise memory check tools | |
| 19 // like Valgrind will complain about uninitialized memory usage when | |
| 20 // transferring these classes over the wire. | |
| 21 #pragma pack(push, 4) | |
| 22 | |
| 23 // DrawQuad is a bag of data used for drawing a quad. Because different | 13 // DrawQuad is a bag of data used for drawing a quad. Because different |
| 24 // materials need different bits of per-quad data to render, classes that derive | 14 // materials need different bits of per-quad data to render, classes that derive |
| 25 // from DrawQuad store additional data in their derived instance. The Material | 15 // from DrawQuad store additional data in their derived instance. The Material |
| 26 // enum is used to "safely" downcast to the derived class. | 16 // enum is used to "safely" downcast to the derived class. |
| 27 class CC_EXPORT DrawQuad { | 17 class CC_EXPORT DrawQuad { |
| 28 public: | 18 public: |
| 29 enum Material { | 19 enum Material { |
| 30 Invalid, | 20 INVALID, |
| 31 Checkerboard, | 21 CHECKERBOARD, |
| 32 DebugBorder, | 22 DEBUG_BORDER, |
| 33 IOSurfaceContent, | 23 IO_SURFACE_CONTENT, |
| 34 RenderPass, | 24 RENDER_PASS, |
| 35 TextureContent, | 25 TEXTURE_CONTENT, |
| 36 SolidColor, | 26 SOLID_COLOR, |
| 37 TiledContent, | 27 TILED_CONTENT, |
| 38 YUVVideoContent, | 28 YUV_VIDEO_CONTENT, |
| 39 StreamVideoContent, | 29 STREAM_VIDEO_CONTENT, |
| 40 }; | 30 }; |
| 41 | 31 |
| 42 gfx::Rect quadRect() const { return m_quadRect; } | 32 gfx::Rect quadRect() const { return m_quadRect; } |
| 43 const WebKit::WebTransformationMatrix& quadTransform() const { return m_shar
edQuadState->quadTransform; } | 33 const WebKit::WebTransformationMatrix& quadTransform() const { return m_shar
edQuadState->quadTransform; } |
| 44 gfx::Rect visibleContentRect() const { return m_sharedQuadState->visibleCont
entRect; } | 34 gfx::Rect visibleContentRect() const { return m_sharedQuadState->visibleCont
entRect; } |
| 45 gfx::Rect clippedRectInTarget() const { return m_sharedQuadState->clippedRec
tInTarget; } | 35 gfx::Rect clippedRectInTarget() const { return m_sharedQuadState->clippedRec
tInTarget; } |
| 46 float opacity() const { return m_sharedQuadState->opacity; } | 36 float opacity() const { return m_sharedQuadState->opacity; } |
| 47 // For the purposes of blending, what part of the contents of this quad are
opaque? | 37 // For the purposes of blending, what part of the contents of this quad are
opaque? |
| 48 gfx::Rect opaqueRect() const; | 38 gfx::Rect opaqueRect() const; |
| 49 bool needsBlending() const { return m_needsBlending || !opaqueRect().Contain
s(m_quadVisibleRect); } | 39 bool needsBlending() const { return m_needsBlending || !opaqueRect().Contain
s(m_quadVisibleRect); } |
| 50 | 40 |
| 51 // Allows changing the rect that gets drawn to make it smaller. Parameter pa
ssed | 41 // Allows changing the rect that gets drawn to make it smaller. Parameter pa
ssed |
| 52 // in will be clipped to quadRect(). | 42 // in will be clipped to quadRect(). |
| 53 void setQuadVisibleRect(gfx::Rect); | 43 void setQuadVisibleRect(gfx::Rect); |
| 54 gfx::Rect quadVisibleRect() const { return m_quadVisibleRect; } | 44 gfx::Rect quadVisibleRect() const { return m_quadVisibleRect; } |
| 55 bool isDebugQuad() const { return m_material == DebugBorder; } | 45 bool isDebugQuad() const { return m_material == DEBUG_BORDER; } |
| 56 | 46 |
| 57 Material material() const { return m_material; } | 47 Material material() const { return m_material; } |
| 58 | 48 |
| 59 scoped_ptr<DrawQuad> copy(const SharedQuadState* copiedSharedQuadState) cons
t; | 49 scoped_ptr<DrawQuad> copy(const SharedQuadState* copiedSharedQuadState) cons
t; |
| 60 | 50 |
| 61 const SharedQuadState* sharedQuadState() const { return m_sharedQuadState; } | 51 const SharedQuadState* sharedQuadState() const { return m_sharedQuadState; } |
| 62 int sharedQuadStateId() const { return m_sharedQuadStateId; } | 52 int sharedQuadStateId() const { return m_sharedQuadStateId; } |
| 63 void setSharedQuadState(const SharedQuadState*); | 53 void setSharedQuadState(const SharedQuadState*); |
| 64 | 54 |
| 65 protected: | 55 protected: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 // opaque or needs blending. Derived classes can override with these | 69 // opaque or needs blending. Derived classes can override with these |
| 80 // variables. | 70 // variables. |
| 81 bool m_quadOpaque; | 71 bool m_quadOpaque; |
| 82 bool m_needsBlending; | 72 bool m_needsBlending; |
| 83 | 73 |
| 84 // Be default, this rect is empty. It is used when the shared quad state and
above | 74 // Be default, this rect is empty. It is used when the shared quad state and
above |
| 85 // variables determine that the quad is not fully opaque but may be partiall
y opaque. | 75 // variables determine that the quad is not fully opaque but may be partiall
y opaque. |
| 86 gfx::Rect m_opaqueRect; | 76 gfx::Rect m_opaqueRect; |
| 87 }; | 77 }; |
| 88 | 78 |
| 89 #pragma pack(pop) | |
| 90 | |
| 91 } | 79 } |
| 92 | 80 |
| 93 #endif // CC_DRAW_QUAD_H_ | 81 #endif // CC_DRAW_QUAD_H_ |
| OLD | NEW |