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