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
3 // found in the LICENSE file.
5 #ifndef CC_DRAW_QUAD_H_
6 #define CC_DRAW_QUAD_H_
8 #include "cc/cc_export.h"
9 #include "cc/shared_quad_state.h"
13 // DrawQuad is a bag of data used for drawing a quad. Because different
14 // materials need different bits of per-quad data to render, classes that derive
15 // from DrawQuad store additional data in their derived instance. The Material
16 // enum is used to "safely" downcast to the derived class.
17 class CC_EXPORT DrawQuad
{
34 scoped_ptr
<DrawQuad
> Copy(
35 const SharedQuadState
* copied_shared_quad_state
) const;
37 // TODO(danakj): Chromify or remove these SharedQuadState helpers.
38 const gfx::Transform
& quadTransform() const { return shared_quad_state
->content_to_target_transform
; }
39 gfx::Rect
visibleContentRect() const { return shared_quad_state
->visible_content_rect
; }
40 gfx::Rect
clippedRectInTarget() const { return shared_quad_state
->clipped_rect_in_target
; }
41 gfx::Rect
clipRect() const { return shared_quad_state
->clip_rect
; }
42 bool isClipped() const { return shared_quad_state
->is_clipped
; }
43 float opacity() const { return shared_quad_state
->opacity
; }
47 // This rect, after applying the quad_transform(), gives the geometry that
48 // this quad should draw to.
51 // This specifies the region of the quad that is opaque.
52 gfx::Rect opaque_rect
;
54 // Allows changing the rect that gets drawn to make it smaller. This value
55 // should be clipped to quadRect.
56 gfx::Rect visible_rect
;
58 // By default blending is used when some part of the quad is not opaque.
59 // With this setting, it is possible to force blending on regardless of the
63 // Stores state common to a large bundle of quads; kept separate for memory
64 // efficiency. There is special treatment to reconstruct these pointers
65 // during serialization.
66 const SharedQuadState
* shared_quad_state
;
68 bool IsDebugQuad() const { return material
== DEBUG_BORDER
; }
69 bool ShouldDrawWithBlending() const {
70 return needs_blending
|| shared_quad_state
->opacity
< 1.0f
||
71 !opaque_rect
.Contains(visible_rect
);
77 void SetAll(const SharedQuadState
* shared_quad_state
,
80 gfx::Rect opaque_rect
,
81 gfx::Rect visible_rect
,
87 #endif // CC_DRAW_QUAD_H_