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

Side by Side Diff: cc/layers/surface_layer_impl.cc

Issue 331533002: Use a struct for cc::Surface ids for more type safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add is_null and explicit ctor Created 6 years, 6 months 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/layers/surface_layer_impl.h ('k') | cc/layers/surface_layer_impl_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/layers/surface_layer_impl.h" 5 #include "cc/layers/surface_layer_impl.h"
6 6
7 #include "cc/debug/debug_colors.h" 7 #include "cc/debug/debug_colors.h"
8 #include "cc/layers/quad_sink.h" 8 #include "cc/layers/quad_sink.h"
9 #include "cc/quads/surface_draw_quad.h" 9 #include "cc/quads/surface_draw_quad.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) 13 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
14 : LayerImpl(tree_impl, id), surface_id_(0) {} 14 : LayerImpl(tree_impl, id) {
15 }
15 16
16 SurfaceLayerImpl::~SurfaceLayerImpl() {} 17 SurfaceLayerImpl::~SurfaceLayerImpl() {}
17 18
18 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( 19 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl(
19 LayerTreeImpl* tree_impl) { 20 LayerTreeImpl* tree_impl) {
20 return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 21 return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
21 } 22 }
22 23
23 void SurfaceLayerImpl::SetSurfaceId(int surface_id) { 24 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) {
24 if (surface_id_ == surface_id) 25 if (surface_id_ == surface_id)
25 return; 26 return;
26 27
27 surface_id_ = surface_id; 28 surface_id_ = surface_id;
28 NoteLayerPropertyChanged(); 29 NoteLayerPropertyChanged();
29 } 30 }
30 31
31 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { 32 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
32 LayerImpl::PushPropertiesTo(layer); 33 LayerImpl::PushPropertiesTo(layer);
33 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); 34 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
34 35
35 layer_impl->SetSurfaceId(surface_id_); 36 layer_impl->SetSurfaceId(surface_id_);
36 } 37 }
37 38
38 void SurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, 39 void SurfaceLayerImpl::AppendQuads(QuadSink* quad_sink,
39 AppendQuadsData* append_quads_data) { 40 AppendQuadsData* append_quads_data) {
40 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 41 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState();
41 PopulateSharedQuadState(shared_quad_state); 42 PopulateSharedQuadState(shared_quad_state);
42 43
43 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); 44 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
44 45
45 if (!surface_id_) 46 if (surface_id_.is_null())
46 return; 47 return;
47 48
48 scoped_ptr<SurfaceDrawQuad> quad = SurfaceDrawQuad::Create(); 49 scoped_ptr<SurfaceDrawQuad> quad = SurfaceDrawQuad::Create();
49 gfx::Rect quad_rect(content_bounds()); 50 gfx::Rect quad_rect(content_bounds());
50 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( 51 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect(
51 quad_rect, draw_properties().target_space_transform); 52 quad_rect, draw_properties().target_space_transform);
52 if (visible_quad_rect.IsEmpty()) 53 if (visible_quad_rect.IsEmpty())
53 return; 54 return;
54 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); 55 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_);
55 quad_sink->Append(quad.PassAs<DrawQuad>()); 56 quad_sink->Append(quad.PassAs<DrawQuad>());
56 } 57 }
57 58
58 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, 59 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color,
59 float* width) const { 60 float* width) const {
60 *color = DebugColors::SurfaceLayerBorderColor(); 61 *color = DebugColors::SurfaceLayerBorderColor();
61 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); 62 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl());
62 } 63 }
63 64
64 void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const { 65 void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const {
65 LayerImpl::AsValueInto(dict); 66 LayerImpl::AsValueInto(dict);
66 dict->SetInteger("surface_id", surface_id_); 67 dict->SetInteger("surface_id", surface_id_.id);
67 } 68 }
68 69
69 const char* SurfaceLayerImpl::LayerTypeAsString() const { 70 const char* SurfaceLayerImpl::LayerTypeAsString() const {
70 return "cc::SurfaceLayerImpl"; 71 return "cc::SurfaceLayerImpl";
71 } 72 }
72 73
73 } // namespace cc 74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer_impl.h ('k') | cc/layers/surface_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698