1 // Copyright 2012 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/io_surface_draw_quad.h"
7 #include "base/debug/trace_event_argument.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
14 IOSurfaceDrawQuad::IOSurfaceDrawQuad()
15 : io_surface_resource_id(0),
16 orientation(FLIPPED
) {
19 void IOSurfaceDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
20 const gfx::Rect
& rect
,
21 const gfx::Rect
& opaque_rect
,
22 const gfx::Rect
& visible_rect
,
23 const gfx::Size
& io_surface_size
,
24 unsigned io_surface_resource_id
,
25 Orientation orientation
) {
26 bool needs_blending
= false;
27 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
28 opaque_rect
, visible_rect
, needs_blending
);
29 this->io_surface_size
= io_surface_size
;
30 this->io_surface_resource_id
= io_surface_resource_id
;
31 this->orientation
= orientation
;
34 void IOSurfaceDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
35 const gfx::Rect
& rect
,
36 const gfx::Rect
& opaque_rect
,
37 const gfx::Rect
& visible_rect
,
39 const gfx::Size
& io_surface_size
,
40 unsigned io_surface_resource_id
,
41 Orientation orientation
) {
42 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
43 opaque_rect
, visible_rect
, needs_blending
);
44 this->io_surface_size
= io_surface_size
;
45 this->io_surface_resource_id
= io_surface_resource_id
;
46 this->orientation
= orientation
;
49 void IOSurfaceDrawQuad::IterateResources(
50 const ResourceIteratorCallback
& callback
) {
51 io_surface_resource_id
= callback
.Run(io_surface_resource_id
);
54 const IOSurfaceDrawQuad
* IOSurfaceDrawQuad::MaterialCast(
55 const DrawQuad
* quad
) {
56 DCHECK(quad
->material
== DrawQuad::IO_SURFACE_CONTENT
);
57 return static_cast<const IOSurfaceDrawQuad
*>(quad
);
60 void IOSurfaceDrawQuad::ExtendValue(base::debug::TracedValue
* value
) const {
61 value
->BeginDictionary("io_surface_size");
62 MathUtil::AddToTracedValue(io_surface_size
, value
);
63 value
->EndDictionary();
65 value
->SetInteger("io_surface_resource_id", io_surface_resource_id
);
66 const char* orientation_string
= NULL
;
67 switch (orientation
) {
69 orientation_string
= "flipped";
72 orientation_string
= "unflipped";
76 value
->SetString("orientation", orientation_string
);