Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 1 | // Copyright 2013 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/picture_draw_quad.h" |
| 6 | |
Ben Murdoch | ba5b9a6 | 2013-08-12 14:20:17 +0100 | [diff] [blame^] | 7 | #include "base/values.h" |
| 8 | #include "cc/base/math_util.h" |
| 9 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 10 | namespace cc { |
| 11 | |
| 12 | PictureDrawQuad::PictureDrawQuad() { |
| 13 | } |
| 14 | |
| 15 | PictureDrawQuad::~PictureDrawQuad() { |
| 16 | } |
| 17 | |
| 18 | scoped_ptr<PictureDrawQuad> PictureDrawQuad::Create() { |
| 19 | return make_scoped_ptr(new PictureDrawQuad); |
| 20 | } |
| 21 | |
| 22 | void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 23 | gfx::Rect rect, |
| 24 | gfx::Rect opaque_rect, |
| 25 | const gfx::RectF& tex_coord_rect, |
| 26 | gfx::Size texture_size, |
| 27 | bool swizzle_contents, |
| 28 | gfx::Rect content_rect, |
| 29 | float contents_scale, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 30 | bool can_draw_direct_to_backbuffer, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 31 | scoped_refptr<PicturePileImpl> picture_pile) { |
| 32 | ContentDrawQuadBase::SetNew(shared_quad_state, DrawQuad::PICTURE_CONTENT, |
| 33 | rect, opaque_rect, tex_coord_rect, texture_size, |
| 34 | swizzle_contents); |
| 35 | this->content_rect = content_rect; |
| 36 | this->contents_scale = contents_scale; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 37 | this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 38 | this->picture_pile = picture_pile; |
| 39 | } |
| 40 | |
| 41 | void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 42 | gfx::Rect rect, |
| 43 | gfx::Rect opaque_rect, |
| 44 | gfx::Rect visible_rect, |
| 45 | bool needs_blending, |
| 46 | const gfx::RectF& tex_coord_rect, |
| 47 | gfx::Size texture_size, |
| 48 | bool swizzle_contents, |
| 49 | gfx::Rect content_rect, |
| 50 | float contents_scale, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 51 | bool can_draw_direct_to_backbuffer, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 52 | scoped_refptr<PicturePileImpl> picture_pile) { |
| 53 | ContentDrawQuadBase::SetAll(shared_quad_state, |
| 54 | DrawQuad::PICTURE_CONTENT, rect, opaque_rect, |
| 55 | visible_rect, needs_blending, tex_coord_rect, |
| 56 | texture_size, swizzle_contents); |
| 57 | this->content_rect = content_rect; |
| 58 | this->contents_scale = contents_scale; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 59 | this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 60 | this->picture_pile = picture_pile; |
| 61 | } |
| 62 | |
| 63 | void PictureDrawQuad::IterateResources( |
| 64 | const ResourceIteratorCallback& callback) { |
| 65 | // TODO(danakj): Convert to TextureDrawQuad? |
| 66 | NOTIMPLEMENTED(); |
| 67 | } |
| 68 | |
| 69 | const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { |
| 70 | DCHECK(quad->material == DrawQuad::PICTURE_CONTENT); |
| 71 | return static_cast<const PictureDrawQuad*>(quad); |
| 72 | } |
| 73 | |
Ben Murdoch | ba5b9a6 | 2013-08-12 14:20:17 +0100 | [diff] [blame^] | 74 | void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const { |
| 75 | ContentDrawQuadBase::ExtendValue(value); |
| 76 | value->Set("content_rect", MathUtil::AsValue(content_rect).release()); |
| 77 | value->SetDouble("contents_scale", contents_scale); |
| 78 | value->SetBoolean("can_draw_direct_to_backbuffer", |
| 79 | can_draw_direct_to_backbuffer); |
| 80 | // TODO(piman): picture_pile? |
| 81 | } |
| 82 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 83 | } // namespace cc |