| 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/quads/tile_draw_quad.h" | 5 #include "cc/quads/tile_draw_quad.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 TileDrawQuad::TileDrawQuad() | 13 TileDrawQuad::TileDrawQuad() { |
| 14 : resource_id(0) { | |
| 15 } | 14 } |
| 16 | 15 |
| 17 TileDrawQuad::~TileDrawQuad() { | 16 TileDrawQuad::~TileDrawQuad() { |
| 18 } | 17 } |
| 19 | 18 |
| 20 void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state, | 19 void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 21 const gfx::Rect& rect, | 20 const gfx::Rect& rect, |
| 22 const gfx::Rect& opaque_rect, | 21 const gfx::Rect& opaque_rect, |
| 23 const gfx::Rect& visible_rect, | 22 const gfx::Rect& visible_rect, |
| 24 unsigned resource_id, | 23 unsigned resource_id, |
| 25 const gfx::RectF& tex_coord_rect, | 24 const gfx::RectF& tex_coord_rect, |
| 26 const gfx::Size& texture_size, | 25 const gfx::Size& texture_size, |
| 27 bool swizzle_contents, | 26 bool swizzle_contents, |
| 28 bool nearest_neighbor) { | 27 bool nearest_neighbor) { |
| 29 ContentDrawQuadBase::SetNew(shared_quad_state, | 28 ContentDrawQuadBase::SetNew(shared_quad_state, |
| 30 DrawQuad::TILED_CONTENT, | 29 DrawQuad::TILED_CONTENT, |
| 31 rect, | 30 rect, |
| 32 opaque_rect, | 31 opaque_rect, |
| 33 visible_rect, | 32 visible_rect, |
| 34 tex_coord_rect, | 33 tex_coord_rect, |
| 35 texture_size, | 34 texture_size, |
| 36 swizzle_contents, | 35 swizzle_contents, |
| 37 nearest_neighbor); | 36 nearest_neighbor); |
| 38 this->resource_id = resource_id; | 37 resources.ids[kResourceIdIndex] = resource_id; |
| 38 resources.count = 1; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state, | 41 void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 42 const gfx::Rect& rect, | 42 const gfx::Rect& rect, |
| 43 const gfx::Rect& opaque_rect, | 43 const gfx::Rect& opaque_rect, |
| 44 const gfx::Rect& visible_rect, | 44 const gfx::Rect& visible_rect, |
| 45 bool needs_blending, | 45 bool needs_blending, |
| 46 unsigned resource_id, | 46 unsigned resource_id, |
| 47 const gfx::RectF& tex_coord_rect, | 47 const gfx::RectF& tex_coord_rect, |
| 48 const gfx::Size& texture_size, | 48 const gfx::Size& texture_size, |
| 49 bool swizzle_contents, | 49 bool swizzle_contents, |
| 50 bool nearest_neighbor) { | 50 bool nearest_neighbor) { |
| 51 ContentDrawQuadBase::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, | 51 ContentDrawQuadBase::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, |
| 52 opaque_rect, visible_rect, needs_blending, | 52 opaque_rect, visible_rect, needs_blending, |
| 53 tex_coord_rect, texture_size, swizzle_contents, | 53 tex_coord_rect, texture_size, swizzle_contents, |
| 54 nearest_neighbor); | 54 nearest_neighbor); |
| 55 this->resource_id = resource_id; | 55 resources.ids[kResourceIdIndex] = resource_id; |
| 56 } | 56 resources.count = 1; |
| 57 | |
| 58 void TileDrawQuad::IterateResources( | |
| 59 const ResourceIteratorCallback& callback) { | |
| 60 resource_id = callback.Run(resource_id); | |
| 61 } | 57 } |
| 62 | 58 |
| 63 const TileDrawQuad* TileDrawQuad::MaterialCast(const DrawQuad* quad) { | 59 const TileDrawQuad* TileDrawQuad::MaterialCast(const DrawQuad* quad) { |
| 64 DCHECK(quad->material == DrawQuad::TILED_CONTENT); | 60 DCHECK(quad->material == DrawQuad::TILED_CONTENT); |
| 65 return static_cast<const TileDrawQuad*>(quad); | 61 return static_cast<const TileDrawQuad*>(quad); |
| 66 } | 62 } |
| 67 | 63 |
| 68 void TileDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const { | 64 void TileDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const { |
| 69 ContentDrawQuadBase::ExtendValue(value); | 65 ContentDrawQuadBase::ExtendValue(value); |
| 70 value->SetInteger("resource_id", resource_id); | 66 value->SetInteger("resource_id", resources.ids[kResourceIdIndex]); |
| 71 } | 67 } |
| 72 | 68 |
| 73 } // namespace cc | 69 } // namespace cc |
| OLD | NEW |