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