• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/debug/trace_event_argument.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
11 
12 namespace cc {
13 
IOSurfaceDrawQuad()14 IOSurfaceDrawQuad::IOSurfaceDrawQuad()
15     : io_surface_resource_id(0),
16       orientation(FLIPPED) {
17 }
18 
SetNew(const SharedQuadState * shared_quad_state,const gfx::Rect & rect,const gfx::Rect & opaque_rect,const gfx::Rect & visible_rect,const gfx::Size & io_surface_size,unsigned io_surface_resource_id,Orientation orientation)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 
SetAll(const SharedQuadState * shared_quad_state,const gfx::Rect & rect,const gfx::Rect & opaque_rect,const gfx::Rect & visible_rect,bool needs_blending,const gfx::Size & io_surface_size,unsigned io_surface_resource_id,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,
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 
IterateResources(const ResourceIteratorCallback & callback)49 void IOSurfaceDrawQuad::IterateResources(
50     const ResourceIteratorCallback& callback) {
51   io_surface_resource_id = callback.Run(io_surface_resource_id);
52 }
53 
MaterialCast(const DrawQuad * quad)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 
ExtendValue(base::debug::TracedValue * value) const60 void IOSurfaceDrawQuad::ExtendValue(base::debug::TracedValue* value) const {
61   value->BeginDictionary("io_surface_size");
62   MathUtil::AddToTracedValue(io_surface_size, value);
63   value->EndDictionary();
64 
65   value->SetInteger("io_surface_resource_id", io_surface_resource_id);
66   const char* orientation_string = NULL;
67   switch (orientation) {
68     case FLIPPED:
69       orientation_string = "flipped";
70       break;
71     case UNFLIPPED:
72       orientation_string = "unflipped";
73       break;
74   }
75 
76   value->SetString("orientation", orientation_string);
77 }
78 
79 }  // namespace cc
80