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/debug/trace_event_argument.h"
8 #include "base/values.h"
9 #include "cc/base/math_util.h"
10 #include "cc/resources/platform_color.h"
14 PictureDrawQuad::PictureDrawQuad() {
17 PictureDrawQuad::~PictureDrawQuad() {
20 void PictureDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
21 const gfx::Rect
& rect
,
22 const gfx::Rect
& opaque_rect
,
23 const gfx::Rect
& visible_rect
,
24 const gfx::RectF
& tex_coord_rect
,
25 const gfx::Size
& texture_size
,
26 ResourceFormat texture_format
,
27 const gfx::Rect
& content_rect
,
29 scoped_refptr
<RasterSource
> raster_source
) {
30 ContentDrawQuadBase::SetNew(
32 DrawQuad::PICTURE_CONTENT
,
38 !PlatformColor::SameComponentOrder(texture_format
));
39 this->content_rect
= content_rect
;
40 this->contents_scale
= contents_scale
;
41 this->raster_source
= raster_source
;
42 this->texture_format
= texture_format
;
45 void PictureDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
46 const gfx::Rect
& rect
,
47 const gfx::Rect
& opaque_rect
,
48 const gfx::Rect
& visible_rect
,
50 const gfx::RectF
& tex_coord_rect
,
51 const gfx::Size
& texture_size
,
52 ResourceFormat texture_format
,
53 const gfx::Rect
& content_rect
,
55 scoped_refptr
<RasterSource
> raster_source
) {
56 ContentDrawQuadBase::SetAll(shared_quad_state
,
57 DrawQuad::PICTURE_CONTENT
,
64 !PlatformColor::SameComponentOrder(
66 this->content_rect
= content_rect
;
67 this->contents_scale
= contents_scale
;
68 this->raster_source
= raster_source
;
69 this->texture_format
= texture_format
;
72 void PictureDrawQuad::IterateResources(
73 const ResourceIteratorCallback
& callback
) {
74 // TODO(danakj): Convert to TextureDrawQuad?
78 const PictureDrawQuad
* PictureDrawQuad::MaterialCast(const DrawQuad
* quad
) {
79 DCHECK(quad
->material
== DrawQuad::PICTURE_CONTENT
);
80 return static_cast<const PictureDrawQuad
*>(quad
);
83 void PictureDrawQuad::ExtendValue(base::debug::TracedValue
* value
) const {
84 ContentDrawQuadBase::ExtendValue(value
);
85 value
->BeginArray("content_rect");
86 MathUtil::AddToTracedValue(content_rect
, value
);
88 value
->SetDouble("contents_scale", contents_scale
);
89 value
->SetInteger("texture_format", texture_format
);
90 // TODO(piman): raster_source?