| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/quads/picture_draw_quad.h" | 5 #include "cc/quads/picture_draw_quad.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/resources/platform_color.h" |
| 9 | 10 |
| 10 namespace cc { | 11 namespace cc { |
| 11 | 12 |
| 12 PictureDrawQuad::PictureDrawQuad() { | 13 PictureDrawQuad::PictureDrawQuad() { |
| 13 } | 14 } |
| 14 | 15 |
| 15 PictureDrawQuad::~PictureDrawQuad() { | 16 PictureDrawQuad::~PictureDrawQuad() { |
| 16 } | 17 } |
| 17 | 18 |
| 18 scoped_ptr<PictureDrawQuad> PictureDrawQuad::Create() { | 19 scoped_ptr<PictureDrawQuad> PictureDrawQuad::Create() { |
| 19 return make_scoped_ptr(new PictureDrawQuad); | 20 return make_scoped_ptr(new PictureDrawQuad); |
| 20 } | 21 } |
| 21 | 22 |
| 22 void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, | 23 void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 23 gfx::Rect rect, | 24 gfx::Rect rect, |
| 24 gfx::Rect opaque_rect, | 25 gfx::Rect opaque_rect, |
| 25 const gfx::RectF& tex_coord_rect, | 26 const gfx::RectF& tex_coord_rect, |
| 26 gfx::Size texture_size, | 27 gfx::Size texture_size, |
| 27 bool swizzle_contents, | 28 ResourceFormat texture_format, |
| 28 gfx::Rect content_rect, | 29 gfx::Rect content_rect, |
| 29 float contents_scale, | 30 float contents_scale, |
| 30 bool can_draw_direct_to_backbuffer, | 31 bool can_draw_direct_to_backbuffer, |
| 31 scoped_refptr<PicturePileImpl> picture_pile) { | 32 scoped_refptr<PicturePileImpl> picture_pile) { |
| 32 ContentDrawQuadBase::SetNew(shared_quad_state, DrawQuad::PICTURE_CONTENT, | 33 ContentDrawQuadBase::SetNew(shared_quad_state, |
| 33 rect, opaque_rect, tex_coord_rect, texture_size, | 34 DrawQuad::PICTURE_CONTENT, |
| 34 swizzle_contents); | 35 rect, |
| 36 opaque_rect, |
| 37 tex_coord_rect, |
| 38 texture_size, |
| 39 !PlatformColor::SameComponentOrder( |
| 40 texture_format)); |
| 35 this->content_rect = content_rect; | 41 this->content_rect = content_rect; |
| 36 this->contents_scale = contents_scale; | 42 this->contents_scale = contents_scale; |
| 37 this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; | 43 this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; |
| 38 this->picture_pile = picture_pile; | 44 this->picture_pile = picture_pile; |
| 45 this->texture_format = texture_format; |
| 39 } | 46 } |
| 40 | 47 |
| 41 void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, | 48 void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 42 gfx::Rect rect, | 49 gfx::Rect rect, |
| 43 gfx::Rect opaque_rect, | 50 gfx::Rect opaque_rect, |
| 44 gfx::Rect visible_rect, | 51 gfx::Rect visible_rect, |
| 45 bool needs_blending, | 52 bool needs_blending, |
| 46 const gfx::RectF& tex_coord_rect, | 53 const gfx::RectF& tex_coord_rect, |
| 47 gfx::Size texture_size, | 54 gfx::Size texture_size, |
| 48 bool swizzle_contents, | 55 ResourceFormat texture_format, |
| 49 gfx::Rect content_rect, | 56 gfx::Rect content_rect, |
| 50 float contents_scale, | 57 float contents_scale, |
| 51 bool can_draw_direct_to_backbuffer, | 58 bool can_draw_direct_to_backbuffer, |
| 52 scoped_refptr<PicturePileImpl> picture_pile) { | 59 scoped_refptr<PicturePileImpl> picture_pile) { |
| 53 ContentDrawQuadBase::SetAll(shared_quad_state, | 60 ContentDrawQuadBase::SetAll(shared_quad_state, |
| 54 DrawQuad::PICTURE_CONTENT, rect, opaque_rect, | 61 DrawQuad::PICTURE_CONTENT, |
| 55 visible_rect, needs_blending, tex_coord_rect, | 62 rect, |
| 56 texture_size, swizzle_contents); | 63 opaque_rect, |
| 64 visible_rect, |
| 65 needs_blending, |
| 66 tex_coord_rect, |
| 67 texture_size, |
| 68 !PlatformColor::SameComponentOrder( |
| 69 texture_format)); |
| 57 this->content_rect = content_rect; | 70 this->content_rect = content_rect; |
| 58 this->contents_scale = contents_scale; | 71 this->contents_scale = contents_scale; |
| 59 this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; | 72 this->can_draw_direct_to_backbuffer = can_draw_direct_to_backbuffer; |
| 60 this->picture_pile = picture_pile; | 73 this->picture_pile = picture_pile; |
| 74 this->texture_format = texture_format; |
| 61 } | 75 } |
| 62 | 76 |
| 63 void PictureDrawQuad::IterateResources( | 77 void PictureDrawQuad::IterateResources( |
| 64 const ResourceIteratorCallback& callback) { | 78 const ResourceIteratorCallback& callback) { |
| 65 // TODO(danakj): Convert to TextureDrawQuad? | 79 // TODO(danakj): Convert to TextureDrawQuad? |
| 66 NOTIMPLEMENTED(); | 80 NOTIMPLEMENTED(); |
| 67 } | 81 } |
| 68 | 82 |
| 69 const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { | 83 const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { |
| 70 DCHECK(quad->material == DrawQuad::PICTURE_CONTENT); | 84 DCHECK(quad->material == DrawQuad::PICTURE_CONTENT); |
| 71 return static_cast<const PictureDrawQuad*>(quad); | 85 return static_cast<const PictureDrawQuad*>(quad); |
| 72 } | 86 } |
| 73 | 87 |
| 74 void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const { | 88 void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const { |
| 75 ContentDrawQuadBase::ExtendValue(value); | 89 ContentDrawQuadBase::ExtendValue(value); |
| 76 value->Set("content_rect", MathUtil::AsValue(content_rect).release()); | 90 value->Set("content_rect", MathUtil::AsValue(content_rect).release()); |
| 77 value->SetDouble("contents_scale", contents_scale); | 91 value->SetDouble("contents_scale", contents_scale); |
| 78 value->SetBoolean("can_draw_direct_to_backbuffer", | 92 value->SetBoolean("can_draw_direct_to_backbuffer", |
| 79 can_draw_direct_to_backbuffer); | 93 can_draw_direct_to_backbuffer); |
| 94 value->SetInteger("texture_format", texture_format); |
| 80 // TODO(piman): picture_pile? | 95 // TODO(piman): picture_pile? |
| 81 } | 96 } |
| 82 | 97 |
| 83 } // namespace cc | 98 } // namespace cc |
| OLD | NEW |