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 "cc/tile_draw_quad.h" | 5 #include "cc/tile_draw_quad.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/khronos/GLES2/gl2.h" | 8 #include "third_party/khronos/GLES2/gl2.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 scoped_ptr<TileDrawQuad> TileDrawQuad::create(const SharedQuadState* sharedQuadS
tate, const gfx::Rect& quadRect, const gfx::Rect& opaqueRect, unsigned resourceI
d, const gfx::RectF& texCoordRect, const gfx::Size& textureSize, bool swizzleCon
tents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA) | 12 TileDrawQuad::TileDrawQuad() |
13 { | 13 : resource_id(0), |
14 return make_scoped_ptr(new TileDrawQuad(sharedQuadState, quadRect, opaqueRec
t, resourceId, texCoordRect, textureSize, swizzleContents, leftEdgeAA, topEdgeAA
, rightEdgeAA, bottomEdgeAA)); | 14 swizzle_contents(false), |
| 15 left_edge_aa(false), |
| 16 top_edge_aa(false), |
| 17 right_edge_aa(false), |
| 18 bottom_edge_aa(false) { |
15 } | 19 } |
16 | 20 |
17 TileDrawQuad::TileDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Re
ct& quadRect, const gfx::Rect& opaqueRect, unsigned resourceId, const gfx::RectF
& texCoordRect, const gfx::Size& textureSize, bool swizzleContents, bool leftEdg
eAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA) | 21 scoped_ptr<TileDrawQuad> TileDrawQuad::Create() { |
18 : m_resourceId(resourceId) | 22 return make_scoped_ptr(new TileDrawQuad); |
19 , m_texCoordRect(texCoordRect) | |
20 , m_textureSize(textureSize) | |
21 , m_swizzleContents(swizzleContents) | |
22 , m_leftEdgeAA(leftEdgeAA) | |
23 , m_topEdgeAA(topEdgeAA) | |
24 , m_rightEdgeAA(rightEdgeAA) | |
25 , m_bottomEdgeAA(bottomEdgeAA) | |
26 { | |
27 gfx::Rect visibleRect = quadRect; | |
28 bool needsBlending = isAntialiased(); | |
29 DrawQuad::SetAll(sharedQuadState, DrawQuad::TILED_CONTENT, quadRect, opaqueR
ect, visibleRect, needsBlending); | |
30 } | 23 } |
31 | 24 |
32 const TileDrawQuad* TileDrawQuad::materialCast(const DrawQuad* quad) | 25 void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
33 { | 26 gfx::Rect rect, |
34 DCHECK(quad->material == DrawQuad::TILED_CONTENT); | 27 gfx::Rect opaque_rect, |
35 return static_cast<const TileDrawQuad*>(quad); | 28 unsigned resource_id, |
| 29 const gfx::RectF& tex_coord_rect, |
| 30 gfx::Size texture_size, |
| 31 bool swizzle_contents, |
| 32 bool left_edge_aa, |
| 33 bool top_edge_aa, |
| 34 bool right_edge_aa, |
| 35 bool bottom_edge_aa) { |
| 36 gfx::Rect visible_rect = rect; |
| 37 bool needs_blending = false; |
| 38 DrawQuad::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, |
| 39 opaque_rect, visible_rect, needs_blending); |
| 40 this->resource_id = resource_id; |
| 41 this->tex_coord_rect = tex_coord_rect; |
| 42 this->texture_size = texture_size; |
| 43 this->swizzle_contents = swizzle_contents; |
| 44 this->left_edge_aa = left_edge_aa; |
| 45 this->top_edge_aa = top_edge_aa; |
| 46 this->right_edge_aa = right_edge_aa; |
| 47 this->bottom_edge_aa = bottom_edge_aa; |
| 48 |
| 49 // Override needs_blending after initializing the quad. |
| 50 this->needs_blending = IsAntialiased(); |
| 51 } |
| 52 |
| 53 void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 54 gfx::Rect rect, |
| 55 gfx::Rect opaque_rect, |
| 56 gfx::Rect visible_rect, |
| 57 bool needs_blending, |
| 58 unsigned resource_id, |
| 59 const gfx::RectF& tex_coord_rect, |
| 60 gfx::Size texture_size, |
| 61 bool swizzle_contents, |
| 62 bool left_edge_aa, |
| 63 bool top_edge_aa, |
| 64 bool right_edge_aa, |
| 65 bool bottom_edge_aa) { |
| 66 DrawQuad::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, |
| 67 opaque_rect, visible_rect, needs_blending); |
| 68 this->resource_id = resource_id; |
| 69 this->tex_coord_rect = tex_coord_rect; |
| 70 this->texture_size = texture_size; |
| 71 this->swizzle_contents = swizzle_contents; |
| 72 this->left_edge_aa = left_edge_aa; |
| 73 this->top_edge_aa = top_edge_aa; |
| 74 this->right_edge_aa = right_edge_aa; |
| 75 this->bottom_edge_aa = bottom_edge_aa; |
| 76 } |
| 77 |
| 78 const TileDrawQuad* TileDrawQuad::MaterialCast( |
| 79 const DrawQuad* quad) { |
| 80 DCHECK(quad->material == DrawQuad::TILED_CONTENT); |
| 81 return static_cast<const TileDrawQuad*>(quad); |
36 } | 82 } |
37 | 83 |
38 } // namespace cc | 84 } // namespace cc |
OLD | NEW |