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