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"
12 PictureDrawQuad::PictureDrawQuad() {
15 PictureDrawQuad::~PictureDrawQuad() {
18 scoped_ptr
<PictureDrawQuad
> PictureDrawQuad::Create() {
19 return make_scoped_ptr(new PictureDrawQuad
);
22 void PictureDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
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
,
30 bool can_draw_direct_to_backbuffer
,
31 scoped_refptr
<PicturePileImpl
> picture_pile
) {
32 ContentDrawQuadBase::SetNew(shared_quad_state
, DrawQuad::PICTURE_CONTENT
,
33 rect
, opaque_rect
, tex_coord_rect
, texture_size
,
35 this->content_rect
= content_rect
;
36 this->contents_scale
= contents_scale
;
37 this->can_draw_direct_to_backbuffer
= can_draw_direct_to_backbuffer
;
38 this->picture_pile
= picture_pile
;
41 void PictureDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
43 gfx::Rect opaque_rect
,
44 gfx::Rect visible_rect
,
46 const gfx::RectF
& tex_coord_rect
,
47 gfx::Size texture_size
,
48 bool swizzle_contents
,
49 gfx::Rect content_rect
,
51 bool can_draw_direct_to_backbuffer
,
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
;
59 this->can_draw_direct_to_backbuffer
= can_draw_direct_to_backbuffer
;
60 this->picture_pile
= picture_pile
;
63 void PictureDrawQuad::IterateResources(
64 const ResourceIteratorCallback
& callback
) {
65 // TODO(danakj): Convert to TextureDrawQuad?
69 const PictureDrawQuad
* PictureDrawQuad::MaterialCast(const DrawQuad
* quad
) {
70 DCHECK(quad
->material
== DrawQuad::PICTURE_CONTENT
);
71 return static_cast<const PictureDrawQuad
*>(quad
);
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?