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 #include "config.h" | 5 #include "config.h" |
6 #include "CCDrawQuad.h" | 6 #include "CCDrawQuad.h" |
7 | 7 |
8 #include "base/logging.h" | |
9 #include "CCCheckerboardDrawQuad.h" | 8 #include "CCCheckerboardDrawQuad.h" |
10 #include "CCDebugBorderDrawQuad.h" | 9 #include "CCDebugBorderDrawQuad.h" |
11 #include "CCIOSurfaceDrawQuad.h" | 10 #include "CCIOSurfaceDrawQuad.h" |
12 #include "CCRenderPassDrawQuad.h" | 11 #include "CCRenderPassDrawQuad.h" |
13 #include "CCSolidColorDrawQuad.h" | 12 #include "CCSolidColorDrawQuad.h" |
14 #include "CCStreamVideoDrawQuad.h" | 13 #include "CCStreamVideoDrawQuad.h" |
15 #include "CCTextureDrawQuad.h" | 14 #include "CCTextureDrawQuad.h" |
16 #include "CCTileDrawQuad.h" | 15 #include "CCTileDrawQuad.h" |
17 #include "CCYUVVideoDrawQuad.h" | 16 #include "CCYUVVideoDrawQuad.h" |
18 #include "IntRect.h" | 17 #include "IntRect.h" |
19 | 18 |
20 namespace cc { | 19 namespace cc { |
21 | 20 |
22 CCDrawQuad::CCDrawQuad(const CCSharedQuadState* sharedQuadState, Material materi
al, const IntRect& quadRect) | 21 CCDrawQuad::CCDrawQuad(const CCSharedQuadState* sharedQuadState, Material materi
al, const IntRect& quadRect) |
23 : m_sharedQuadState(sharedQuadState) | 22 : m_sharedQuadState(sharedQuadState) |
24 , m_sharedQuadStateId(sharedQuadState->id) | 23 , m_sharedQuadStateId(sharedQuadState->id) |
25 , m_material(material) | 24 , m_material(material) |
26 , m_quadRect(quadRect) | 25 , m_quadRect(quadRect) |
27 , m_quadVisibleRect(quadRect) | 26 , m_quadVisibleRect(quadRect) |
28 , m_quadOpaque(true) | 27 , m_quadOpaque(true) |
29 , m_needsBlending(false) | 28 , m_needsBlending(false) |
30 { | 29 { |
31 DCHECK(m_sharedQuadState); | 30 ASSERT(m_sharedQuadState); |
32 DCHECK(m_material != Invalid); | 31 ASSERT(m_material != Invalid); |
33 } | 32 } |
34 | 33 |
35 IntRect CCDrawQuad::opaqueRect() const | 34 IntRect CCDrawQuad::opaqueRect() const |
36 { | 35 { |
37 if (opacity() != 1) | 36 if (opacity() != 1) |
38 return IntRect(); | 37 return IntRect(); |
39 if (m_sharedQuadState->opaque && m_quadOpaque) | 38 if (m_sharedQuadState->opaque && m_quadOpaque) |
40 return m_quadRect; | 39 return m_quadRect; |
41 return m_opaqueRect; | 40 return m_opaqueRect; |
42 } | 41 } |
(...skipping 30 matching lines...) Expand all Loading... |
73 break; | 72 break; |
74 } | 73 } |
75 | 74 |
76 CRASH(); | 75 CRASH(); |
77 return sizeof(CCDrawQuad); | 76 return sizeof(CCDrawQuad); |
78 } | 77 } |
79 | 78 |
80 scoped_ptr<CCDrawQuad> CCDrawQuad::copy(const CCSharedQuadState* copiedSharedQua
dState) const | 79 scoped_ptr<CCDrawQuad> CCDrawQuad::copy(const CCSharedQuadState* copiedSharedQua
dState) const |
81 { | 80 { |
82 // RenderPass quads have their own copy() method. | 81 // RenderPass quads have their own copy() method. |
83 DCHECK(material() != RenderPass); | 82 ASSERT(material() != RenderPass); |
84 | 83 |
85 unsigned bytes = size(); | 84 unsigned bytes = size(); |
86 DCHECK(bytes > 0); | 85 ASSERT(bytes); |
87 | 86 |
88 scoped_ptr<CCDrawQuad> copyQuad(reinterpret_cast<CCDrawQuad*>(new char[bytes
])); | 87 scoped_ptr<CCDrawQuad> copyQuad(reinterpret_cast<CCDrawQuad*>(new char[bytes
])); |
89 memcpy(copyQuad.get(), this, bytes); | 88 memcpy(copyQuad.get(), this, bytes); |
90 copyQuad->setSharedQuadState(copiedSharedQuadState); | 89 copyQuad->setSharedQuadState(copiedSharedQuadState); |
91 | 90 |
92 return copyQuad.Pass(); | 91 return copyQuad.Pass(); |
93 } | 92 } |
94 | 93 |
95 void CCDrawQuad::setSharedQuadState(const CCSharedQuadState* sharedQuadState) | 94 void CCDrawQuad::setSharedQuadState(const CCSharedQuadState* sharedQuadState) |
96 { | 95 { |
97 m_sharedQuadState = sharedQuadState; | 96 m_sharedQuadState = sharedQuadState; |
98 m_sharedQuadStateId = sharedQuadState->id; | 97 m_sharedQuadStateId = sharedQuadState->id; |
99 } | 98 } |
100 | 99 |
101 } | 100 } |
OLD | NEW |