tile_draw_quad.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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. 4 5#include "cc/quads/tile_draw_quad.h" 6 7#include "base/logging.h" 8#include "third_party/khronos/GLES2/gl2.h" 9 10namespace cc { 11 12TileDrawQuad::TileDrawQuad() 13 : resource_id(0), 14 swizzle_contents(false) { 15} 16 17scoped_ptr<TileDrawQuad> TileDrawQuad::Create() { 18 return make_scoped_ptr(new TileDrawQuad); 19} 20 21void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state, 22 gfx::Rect rect, 23 gfx::Rect opaque_rect, 24 unsigned resource_id, 25 const gfx::RectF& tex_coord_rect, 26 gfx::Size texture_size, 27 bool swizzle_contents) { 28 gfx::Rect visible_rect = rect; 29 bool needs_blending = false; 30 DrawQuad::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, 31 opaque_rect, visible_rect, needs_blending); 32 this->resource_id = resource_id; 33 this->tex_coord_rect = tex_coord_rect; 34 this->texture_size = texture_size; 35 this->swizzle_contents = swizzle_contents; 36} 37 38void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state, 39 gfx::Rect rect, 40 gfx::Rect opaque_rect, 41 gfx::Rect visible_rect, 42 bool needs_blending, 43 unsigned resource_id, 44 const gfx::RectF& tex_coord_rect, 45 gfx::Size texture_size, 46 bool swizzle_contents) { 47 DrawQuad::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect, 48 opaque_rect, visible_rect, needs_blending); 49 this->resource_id = resource_id; 50 this->tex_coord_rect = tex_coord_rect; 51 this->texture_size = texture_size; 52 this->swizzle_contents = swizzle_contents; 53} 54 55void TileDrawQuad::IterateResources( 56 const ResourceIteratorCallback& callback) { 57 resource_id = callback.Run(resource_id); 58} 59 60const TileDrawQuad* TileDrawQuad::MaterialCast( 61 const DrawQuad* quad) { 62 DCHECK(quad->material == DrawQuad::TILED_CONTENT); 63 return static_cast<const TileDrawQuad*>(quad); 64} 65 66} // namespace cc 67