Depend on stored sync session GUID for Android.
[chromium-blink-merge.git] / cc / draw_quad.h
blobc1982c17d5aa8f200893f477c52b9d707386bcba
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"
11 namespace cc {
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 {
18 public:
19 enum Material {
20 INVALID,
21 CHECKERBOARD,
22 DEBUG_BORDER,
23 IO_SURFACE_CONTENT,
24 RENDER_PASS,
25 TEXTURE_CONTENT,
26 SOLID_COLOR,
27 TILED_CONTENT,
28 YUV_VIDEO_CONTENT,
29 STREAM_VIDEO_CONTENT,
32 virtual ~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; }
45 Material material;
47 // This rect, after applying the quad_transform(), gives the geometry that
48 // this quad should draw to.
49 gfx::Rect rect;
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
60 // opaque area.
61 bool needs_blending;
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);
74 protected:
75 DrawQuad();
77 void SetAll(const SharedQuadState* shared_quad_state,
78 Material material,
79 gfx::Rect rect,
80 gfx::Rect opaque_rect,
81 gfx::Rect visible_rect,
82 bool needs_blending);
87 #endif // CC_DRAW_QUAD_H_