RenderText: handle center-aligned text in UpdateCachedBoundsAndOffset()
[chromium-blink-merge.git] / cc / quads / io_surface_draw_quad.cc
blobcc3581bd0833d7a35d3ceb1bdd52ff5955f4b48a
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/values.h"
9 #include "cc/base/math_util.h"
11 namespace cc {
13 IOSurfaceDrawQuad::IOSurfaceDrawQuad()
14 : io_surface_resource_id(0),
15 orientation(FLIPPED) {
18 void IOSurfaceDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
19 const gfx::Rect& rect,
20 const gfx::Rect& opaque_rect,
21 const gfx::Rect& visible_rect,
22 const gfx::Size& io_surface_size,
23 unsigned io_surface_resource_id,
24 Orientation orientation) {
25 bool needs_blending = false;
26 DrawQuad::SetAll(shared_quad_state, DrawQuad::IO_SURFACE_CONTENT, rect,
27 opaque_rect, visible_rect, needs_blending);
28 this->io_surface_size = io_surface_size;
29 this->io_surface_resource_id = 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,
37 bool needs_blending,
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 this->io_surface_resource_id = io_surface_resource_id;
45 this->orientation = orientation;
48 void IOSurfaceDrawQuad::IterateResources(
49 const ResourceIteratorCallback& callback) {
50 io_surface_resource_id = callback.Run(io_surface_resource_id);
53 const IOSurfaceDrawQuad* IOSurfaceDrawQuad::MaterialCast(
54 const DrawQuad* quad) {
55 DCHECK(quad->material == DrawQuad::IO_SURFACE_CONTENT);
56 return static_cast<const IOSurfaceDrawQuad*>(quad);
59 void IOSurfaceDrawQuad::ExtendValue(base::DictionaryValue* value) const {
60 value->Set("io_surface_size", MathUtil::AsValue(io_surface_size).release());
61 value->SetInteger("io_surface_resource_id", io_surface_resource_id);
62 const char* orientation_string = NULL;
63 switch (orientation) {
64 case FLIPPED:
65 orientation_string = "flipped";
66 break;
67 case UNFLIPPED:
68 orientation_string = "unflipped";
69 break;
72 value->SetString("orientation", orientation_string);
75 } // namespace cc