OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "cc/quads/io_surface_draw_quad.h" |
| 6 |
| 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" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 IOSurfaceDrawQuad::IOSurfaceDrawQuad() |
| 15 : io_surface_resource_id(0), |
| 16 orientation(FLIPPED) { |
| 17 } |
| 18 |
| 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; |
| 32 } |
| 33 |
| 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, |
| 38 bool needs_blending, |
| 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; |
| 47 } |
| 48 |
| 49 void IOSurfaceDrawQuad::IterateResources( |
| 50 const ResourceIteratorCallback& callback) { |
| 51 io_surface_resource_id = callback.Run(io_surface_resource_id); |
| 52 } |
| 53 |
| 54 const IOSurfaceDrawQuad* IOSurfaceDrawQuad::MaterialCast( |
| 55 const DrawQuad* quad) { |
| 56 DCHECK(quad->material == DrawQuad::IO_SURFACE_CONTENT); |
| 57 return static_cast<const IOSurfaceDrawQuad*>(quad); |
| 58 } |
| 59 |
| 60 void IOSurfaceDrawQuad::ExtendValue( |
| 61 base::trace_event::TracedValue* value) const { |
| 62 MathUtil::AddToTracedValue("io_surface_size", io_surface_size, value); |
| 63 |
| 64 value->SetInteger("io_surface_resource_id", io_surface_resource_id); |
| 65 const char* orientation_string = NULL; |
| 66 switch (orientation) { |
| 67 case FLIPPED: |
| 68 orientation_string = "flipped"; |
| 69 break; |
| 70 case UNFLIPPED: |
| 71 orientation_string = "unflipped"; |
| 72 break; |
| 73 } |
| 74 |
| 75 value->SetString("orientation", orientation_string); |
| 76 } |
| 77 |
| 78 } // namespace cc |
OLD | NEW |