Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: cc/draw_quad.cc

Issue 11418047: cc: Turn DrawQuad into a struct-like class with public data members. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no virtual for SetAll() Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/draw_quad.h ('k') | cc/draw_quad_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/draw_quad.h" 5 #include "cc/draw_quad.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/checkerboard_draw_quad.h" 8 #include "cc/checkerboard_draw_quad.h"
9 #include "cc/debug_border_draw_quad.h" 9 #include "cc/debug_border_draw_quad.h"
10 #include "cc/io_surface_draw_quad.h" 10 #include "cc/io_surface_draw_quad.h"
11 #include "cc/render_pass_draw_quad.h" 11 #include "cc/render_pass_draw_quad.h"
12 #include "cc/solid_color_draw_quad.h" 12 #include "cc/solid_color_draw_quad.h"
13 #include "cc/stream_video_draw_quad.h" 13 #include "cc/stream_video_draw_quad.h"
14 #include "cc/texture_draw_quad.h" 14 #include "cc/texture_draw_quad.h"
15 #include "cc/tile_draw_quad.h" 15 #include "cc/tile_draw_quad.h"
16 #include "cc/yuv_video_draw_quad.h" 16 #include "cc/yuv_video_draw_quad.h"
17 17
18 namespace { 18 namespace {
19 19
20 template<typename T> T* TypedCopy(const cc::DrawQuad* other) { 20 template<typename T> T* TypedCopy(const cc::DrawQuad* other) {
21 return new T(*T::materialCast(other)); 21 return new T(*T::materialCast(other));
22 } 22 }
23 23
24 } 24 }
25 25
26 namespace cc { 26 namespace cc {
27 27
28 DrawQuad::DrawQuad(const SharedQuadState* shared_quad_state, 28 DrawQuad::DrawQuad()
29 Material material, 29 : shared_quad_state(),
30 gfx::Rect rect, 30 material(INVALID),
31 gfx::Rect opaque_rect) 31 needs_blending(false) {
32 : shared_quad_state_(shared_quad_state), 32 }
33 material_(material), 33
34 rect_(rect), 34 void DrawQuad::SetAll(const SharedQuadState* shared_quad_state,
35 visible_rect_(rect), 35 Material material,
36 needs_blending_(false), 36 gfx::Rect rect,
37 opaque_rect_(opaque_rect) { 37 gfx::Rect opaque_rect,
38 DCHECK(shared_quad_state_); 38 gfx::Rect visible_rect,
39 DCHECK(material_ != INVALID); 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;
46
47 DCHECK(shared_quad_state);
48 DCHECK(material != INVALID);
40 } 49 }
41 50
42 DrawQuad::~DrawQuad() { 51 DrawQuad::~DrawQuad() {
43 } 52 }
44 53
45 scoped_ptr<DrawQuad> DrawQuad::Copy( 54 scoped_ptr<DrawQuad> DrawQuad::Copy(
46 const SharedQuadState* copied_shared_quad_state) const 55 const SharedQuadState* copied_shared_quad_state) const
47 { 56 {
48 scoped_ptr<DrawQuad> copy_quad; 57 scoped_ptr<DrawQuad> copy_quad;
49 switch (material()) { 58 switch (material) {
50 case CHECKERBOARD: 59 case CHECKERBOARD:
51 copy_quad.reset(TypedCopy<CheckerboardDrawQuad>(this)); 60 copy_quad.reset(TypedCopy<CheckerboardDrawQuad>(this));
52 break; 61 break;
53 case DEBUG_BORDER: 62 case DEBUG_BORDER:
54 copy_quad.reset(TypedCopy<DebugBorderDrawQuad>(this)); 63 copy_quad.reset(TypedCopy<DebugBorderDrawQuad>(this));
55 break; 64 break;
56 case IO_SURFACE_CONTENT: 65 case IO_SURFACE_CONTENT:
57 copy_quad.reset(TypedCopy<IOSurfaceDrawQuad>(this)); 66 copy_quad.reset(TypedCopy<IOSurfaceDrawQuad>(this));
58 break; 67 break;
59 case TEXTURE_CONTENT: 68 case TEXTURE_CONTENT:
60 copy_quad.reset(TypedCopy<TextureDrawQuad>(this)); 69 copy_quad.reset(TypedCopy<TextureDrawQuad>(this));
61 break; 70 break;
62 case SOLID_COLOR: 71 case SOLID_COLOR:
63 copy_quad.reset(TypedCopy<SolidColorDrawQuad>(this)); 72 copy_quad.reset(TypedCopy<SolidColorDrawQuad>(this));
64 break; 73 break;
65 case TILED_CONTENT: 74 case TILED_CONTENT:
66 copy_quad.reset(TypedCopy<TileDrawQuad>(this)); 75 copy_quad.reset(TypedCopy<TileDrawQuad>(this));
67 break; 76 break;
68 case STREAM_VIDEO_CONTENT: 77 case STREAM_VIDEO_CONTENT:
69 copy_quad.reset(TypedCopy<StreamVideoDrawQuad>(this)); 78 copy_quad.reset(TypedCopy<StreamVideoDrawQuad>(this));
70 break; 79 break;
71 case YUV_VIDEO_CONTENT: 80 case YUV_VIDEO_CONTENT:
72 copy_quad.reset(TypedCopy<YUVVideoDrawQuad>(this)); 81 copy_quad.reset(TypedCopy<YUVVideoDrawQuad>(this));
73 break; 82 break;
74 case RENDER_PASS: // RenderPass quads have their own copy() method. 83 case RENDER_PASS: // RenderPass quads have their own copy() method.
75 case INVALID: 84 case INVALID:
76 LOG(FATAL) << "Invalid DrawQuad material " << material(); 85 LOG(FATAL) << "Invalid DrawQuad material " << material;
77 break; 86 break;
78 } 87 }
79 copy_quad->set_shared_quad_state(copied_shared_quad_state); 88 copy_quad->shared_quad_state = copied_shared_quad_state;
80 return copy_quad.Pass(); 89 return copy_quad.Pass();
81 } 90 }
82 91
83 } // namespace cc 92 } // namespace cc
OLDNEW
« no previous file with comments | « cc/draw_quad.h ('k') | cc/draw_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698