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"
11 IOSurfaceDrawQuad::IOSurfaceDrawQuad()
12 : io_surface_resource_id(0),
13 orientation(FLIPPED
) {
16 scoped_ptr
<IOSurfaceDrawQuad
> IOSurfaceDrawQuad::Create() {
17 return make_scoped_ptr(new IOSurfaceDrawQuad
);
20 void IOSurfaceDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
22 gfx::Rect opaque_rect
,
23 gfx::Size io_surface_size
,
24 unsigned io_surface_resource_id
,
25 Orientation orientation
) {
26 gfx::Rect visible_rect
= rect
;
27 bool needs_blending
= false;
28 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
29 opaque_rect
, visible_rect
, needs_blending
);
30 this->io_surface_size
= io_surface_size
;
31 this->io_surface_resource_id
= io_surface_resource_id
;
32 this->orientation
= orientation
;
35 void IOSurfaceDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
37 gfx::Rect opaque_rect
,
38 gfx::Rect visible_rect
,
40 gfx::Size io_surface_size
,
41 unsigned io_surface_resource_id
,
42 Orientation orientation
) {
43 DrawQuad::SetAll(shared_quad_state
, DrawQuad::IO_SURFACE_CONTENT
, rect
,
44 opaque_rect
, visible_rect
, needs_blending
);
45 this->io_surface_size
= io_surface_size
;
46 this->io_surface_resource_id
= io_surface_resource_id
;
47 this->orientation
= orientation
;
50 void IOSurfaceDrawQuad::IterateResources(
51 const ResourceIteratorCallback
& callback
) {
52 io_surface_resource_id
= callback
.Run(io_surface_resource_id
);
55 const IOSurfaceDrawQuad
* IOSurfaceDrawQuad::MaterialCast(
56 const DrawQuad
* quad
) {
57 DCHECK(quad
->material
== DrawQuad::IO_SURFACE_CONTENT
);
58 return static_cast<const IOSurfaceDrawQuad
*>(quad
);