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/logging.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
14 IOSurfaceDrawQuad::IOSurfaceDrawQuad() : orientation(FLIPPED
) {
17 void IOSurfaceDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
18 const gfx::Rect
& rect
,
19 const gfx::Rect
& opaque_rect
,
20 const gfx::Rect
& visible_rect
,
21 const gfx::Size
& io_surface_size
,
22 unsigned io_surface_resource_id
,
23 Orientation orientation
) {
24 bool needs_blending
= false;
25 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
26 opaque_rect
, visible_rect
, needs_blending
);
27 this->io_surface_size
= io_surface_size
;
28 resources
.ids
[kIOSurfaceResourceIdIndex
] = io_surface_resource_id
;
30 this->orientation
= orientation
;
33 void IOSurfaceDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
34 const gfx::Rect
& rect
,
35 const gfx::Rect
& opaque_rect
,
36 const gfx::Rect
& visible_rect
,
38 const gfx::Size
& io_surface_size
,
39 unsigned io_surface_resource_id
,
40 Orientation orientation
) {
41 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
42 opaque_rect
, visible_rect
, needs_blending
);
43 this->io_surface_size
= io_surface_size
;
44 resources
.ids
[kIOSurfaceResourceIdIndex
] = io_surface_resource_id
;
46 this->orientation
= orientation
;
49 const IOSurfaceDrawQuad
* IOSurfaceDrawQuad::MaterialCast(
50 const DrawQuad
* quad
) {
51 DCHECK(quad
->material
== DrawQuad::IO_SURFACE_CONTENT
);
52 return static_cast<const IOSurfaceDrawQuad
*>(quad
);
55 void IOSurfaceDrawQuad::ExtendValue(
56 base::trace_event::TracedValue
* value
) const {
57 MathUtil::AddToTracedValue("io_surface_size", io_surface_size
, value
);
59 value
->SetInteger("io_surface_resource_id",
60 resources
.ids
[kIOSurfaceResourceIdIndex
]);
61 const char* orientation_string
= NULL
;
62 switch (orientation
) {
64 orientation_string
= "flipped";
67 orientation_string
= "unflipped";
71 value
->SetString("orientation", orientation_string
);