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.
5 #include "cc/quads/picture_draw_quad.h"
7 #include "base/values.h"
8 #include "cc/base/math_util.h"
9 #include "cc/resources/platform_color.h"
13 PictureDrawQuad::PictureDrawQuad() {
16 PictureDrawQuad::~PictureDrawQuad() {
19 scoped_ptr
<PictureDrawQuad
> PictureDrawQuad::Create() {
20 return make_scoped_ptr(new PictureDrawQuad
);
23 void PictureDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
24 const gfx::Rect
& rect
,
25 const gfx::Rect
& opaque_rect
,
26 const gfx::Rect
& visible_rect
,
27 const gfx::RectF
& tex_coord_rect
,
28 const gfx::Size
& texture_size
,
29 ResourceFormat texture_format
,
30 const gfx::Rect
& content_rect
,
32 scoped_refptr
<PicturePileImpl
> picture_pile
) {
33 ContentDrawQuadBase::SetNew(
35 DrawQuad::PICTURE_CONTENT
,
41 !PlatformColor::SameComponentOrder(texture_format
));
42 this->content_rect
= content_rect
;
43 this->contents_scale
= contents_scale
;
44 this->picture_pile
= picture_pile
;
45 this->texture_format
= texture_format
;
48 void PictureDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
49 const gfx::Rect
& rect
,
50 const gfx::Rect
& opaque_rect
,
51 const gfx::Rect
& visible_rect
,
53 const gfx::RectF
& tex_coord_rect
,
54 const gfx::Size
& texture_size
,
55 ResourceFormat texture_format
,
56 const gfx::Rect
& content_rect
,
58 scoped_refptr
<PicturePileImpl
> picture_pile
) {
59 ContentDrawQuadBase::SetAll(shared_quad_state
,
60 DrawQuad::PICTURE_CONTENT
,
67 !PlatformColor::SameComponentOrder(
69 this->content_rect
= content_rect
;
70 this->contents_scale
= contents_scale
;
71 this->picture_pile
= picture_pile
;
72 this->texture_format
= texture_format
;
75 void PictureDrawQuad::IterateResources(
76 const ResourceIteratorCallback
& callback
) {
77 // TODO(danakj): Convert to TextureDrawQuad?
81 const PictureDrawQuad
* PictureDrawQuad::MaterialCast(const DrawQuad
* quad
) {
82 DCHECK(quad
->material
== DrawQuad::PICTURE_CONTENT
);
83 return static_cast<const PictureDrawQuad
*>(quad
);
86 void PictureDrawQuad::ExtendValue(base::DictionaryValue
* value
) const {
87 ContentDrawQuadBase::ExtendValue(value
);
88 value
->Set("content_rect", MathUtil::AsValue(content_rect
).release());
89 value
->SetDouble("contents_scale", contents_scale
);
90 value
->SetInteger("texture_format", texture_format
);
91 // TODO(piman): picture_pile?