Depend on stored sync session GUID for Android.
[chromium-blink-merge.git] / cc / draw_quad.cc
blob47f9aa0e0b123d62cc7e058bb01f4163e45f83b6
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/draw_quad.h"
7 #include "base/logging.h"
8 #include "cc/checkerboard_draw_quad.h"
9 #include "cc/debug_border_draw_quad.h"
10 #include "cc/io_surface_draw_quad.h"
11 #include "cc/render_pass_draw_quad.h"
12 #include "cc/solid_color_draw_quad.h"
13 #include "cc/stream_video_draw_quad.h"
14 #include "cc/texture_draw_quad.h"
15 #include "cc/tile_draw_quad.h"
16 #include "cc/yuv_video_draw_quad.h"
18 namespace {
20 template<typename T> T* TypedCopy(const cc::DrawQuad* other) {
21 return new T(*T::MaterialCast(other));
26 namespace cc {
28 DrawQuad::DrawQuad()
29 : shared_quad_state(),
30 material(INVALID),
31 needs_blending(false) {
34 void DrawQuad::SetAll(const SharedQuadState* shared_quad_state,
35 Material material,
36 gfx::Rect rect,
37 gfx::Rect opaque_rect,
38 gfx::Rect visible_rect,
39 bool needs_blending) {
40 this->material = material;
41 this->rect = rect;
42 this->opaque_rect = opaque_rect;
43 this->visible_rect = visible_rect;
44 this->needs_blending = needs_blending;
45 this->shared_quad_state = shared_quad_state;
47 DCHECK(shared_quad_state);
48 DCHECK(material != INVALID);
51 DrawQuad::~DrawQuad() {
54 scoped_ptr<DrawQuad> DrawQuad::Copy(
55 const SharedQuadState* copied_shared_quad_state) const
57 scoped_ptr<DrawQuad> copy_quad;
58 switch (material) {
59 case CHECKERBOARD:
60 copy_quad.reset(TypedCopy<CheckerboardDrawQuad>(this));
61 break;
62 case DEBUG_BORDER:
63 copy_quad.reset(TypedCopy<DebugBorderDrawQuad>(this));
64 break;
65 case IO_SURFACE_CONTENT:
66 copy_quad.reset(TypedCopy<IOSurfaceDrawQuad>(this));
67 break;
68 case TEXTURE_CONTENT:
69 copy_quad.reset(TypedCopy<TextureDrawQuad>(this));
70 break;
71 case SOLID_COLOR:
72 copy_quad.reset(TypedCopy<SolidColorDrawQuad>(this));
73 break;
74 case TILED_CONTENT:
75 copy_quad.reset(TypedCopy<TileDrawQuad>(this));
76 break;
77 case STREAM_VIDEO_CONTENT:
78 copy_quad.reset(TypedCopy<StreamVideoDrawQuad>(this));
79 break;
80 case YUV_VIDEO_CONTENT:
81 copy_quad.reset(TypedCopy<YUVVideoDrawQuad>(this));
82 break;
83 case RENDER_PASS: // RenderPass quads have their own copy() method.
84 case INVALID:
85 LOG(FATAL) << "Invalid DrawQuad material " << material;
86 break;
88 copy_quad->shared_quad_state = copied_shared_quad_state;
89 return copy_quad.Pass();
92 } // namespace cc