[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 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 | |
[email protected] | 89e8267a | 2013-03-18 07:50:56 | [diff] [blame^] | 5 | #include "cc/quads/tile_draw_quad.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 7 | #include "base/logging.h" |
[email protected] | d9c2852 | 2012-10-18 23:35:43 | [diff] [blame] | 8 | #include "third_party/khronos/GLES2/gl2.h" |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 9 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 10 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 11 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 12 | TileDrawQuad::TileDrawQuad() |
| 13 | : resource_id(0), |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 14 | swizzle_contents(false) { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 15 | } |
| 16 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 17 | scoped_ptr<TileDrawQuad> TileDrawQuad::Create() { |
| 18 | return make_scoped_ptr(new TileDrawQuad); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 19 | } |
| 20 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 21 | void 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, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 27 | bool swizzle_contents) { |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 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; |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void 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, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 46 | bool swizzle_contents) { |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 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; |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 53 | } |
| 54 | |
[email protected] | 3c0a63c2 | 2013-03-01 03:56:58 | [diff] [blame] | 55 | void TileDrawQuad::IterateResources( |
| 56 | const ResourceIteratorCallback& callback) { |
| 57 | resource_id = callback.Run(resource_id); |
[email protected] | 0546963 | 2013-01-16 03:41:00 | [diff] [blame] | 58 | } |
| 59 | |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 60 | const TileDrawQuad* TileDrawQuad::MaterialCast( |
| 61 | const DrawQuad* quad) { |
| 62 | DCHECK(quad->material == DrawQuad::TILED_CONTENT); |
| 63 | return static_cast<const TileDrawQuad*>(quad); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 64 | } |
| 65 | |
[email protected] | bc5e77c | 2012-11-05 20:00:49 | [diff] [blame] | 66 | } // namespace cc |