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