1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CCDrawQuad_h
#define CCDrawQuad_h
#include "cc/shared_quad_state.h"
namespace cc {
// WARNING! All CCXYZDrawQuad classes must remain PODs (plain old data).
// They are intended to be "serializable" by copying their raw bytes, so they
// must not contain any non-bit-copyable member variables!
//
// Furthermore, the class members need to be packed so they are aligned
// properly and don't have paddings/gaps, otherwise memory check tools
// like Valgrind will complain about uninitialized memory usage when
// transferring these classes over the wire.
#pragma pack(push, 4)
// CCDrawQuad is a bag of data used for drawing a quad. Because different
// materials need different bits of per-quad data to render, classes that derive
// from CCDrawQuad store additional data in their derived instance. The Material
// enum is used to "safely" downcast to the derived class.
class CCDrawQuad {
public:
enum Material {
Invalid,
Checkerboard,
DebugBorder,
IOSurfaceContent,
RenderPass,
TextureContent,
SolidColor,
TiledContent,
YUVVideoContent,
StreamVideoContent,
};
gfx::Rect quadRect() const { return m_quadRect; }
const WebKit::WebTransformationMatrix& quadTransform() const { return m_sharedQuadState->quadTransform; }
gfx::Rect visibleContentRect() const { return m_sharedQuadState->visibleContentRect; }
gfx::Rect clippedRectInTarget() const { return m_sharedQuadState->clippedRectInTarget; }
float opacity() const { return m_sharedQuadState->opacity; }
// For the purposes of blending, what part of the contents of this quad are opaque?
gfx::Rect opaqueRect() const;
bool needsBlending() const { return m_needsBlending || !opaqueRect().Contains(m_quadVisibleRect); }
// Allows changing the rect that gets drawn to make it smaller. Parameter passed
// in will be clipped to quadRect().
void setQuadVisibleRect(gfx::Rect);
gfx::Rect quadVisibleRect() const { return m_quadVisibleRect; }
bool isDebugQuad() const { return m_material == DebugBorder; }
Material material() const { return m_material; }
// Returns transfer size of this object based on the derived class (by
// looking at the material type).
unsigned size() const;
scoped_ptr<CCDrawQuad> copy(const CCSharedQuadState* copiedSharedQuadState) const;
const CCSharedQuadState* sharedQuadState() const { return m_sharedQuadState; }
int sharedQuadStateId() const { return m_sharedQuadStateId; }
void setSharedQuadState(const CCSharedQuadState*);
protected:
CCDrawQuad(const CCSharedQuadState*, Material, const gfx::Rect&);
// Stores state common to a large bundle of quads; kept separate for memory
// efficiency. There is special treatment to reconstruct these pointers
// during serialization.
const CCSharedQuadState* m_sharedQuadState;
int m_sharedQuadStateId;
Material m_material;
gfx::Rect m_quadRect;
gfx::Rect m_quadVisibleRect;
// By default, the shared quad state determines whether or not this quad is
// opaque or needs blending. Derived classes can override with these
// variables.
bool m_quadOpaque;
bool m_needsBlending;
// Be default, this rect is empty. It is used when the shared quad state and above
// variables determine that the quad is not fully opaque but may be partially opaque.
gfx::Rect m_opaqueRect;
};
#pragma pack(pop)
}
#endif
|