Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / layers / surface_layer_impl.cc
blob80c6da0d594271f9277c3eb731ea70b4fdb2899f
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
3 // found in the LICENSE file.
5 #include "cc/layers/surface_layer_impl.h"
7 #include "cc/debug/debug_colors.h"
8 #include "cc/quads/surface_draw_quad.h"
9 #include "cc/trees/occlusion_tracker.h"
11 namespace cc {
13 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
14 : LayerImpl(tree_impl, id) {
17 SurfaceLayerImpl::~SurfaceLayerImpl() {}
19 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl(
20 LayerTreeImpl* tree_impl) {
21 return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
24 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) {
25 if (surface_id_ == surface_id)
26 return;
28 surface_id_ = surface_id;
29 NoteLayerPropertyChanged();
32 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
33 LayerImpl::PushPropertiesTo(layer);
34 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
36 layer_impl->SetSurfaceId(surface_id_);
39 void SurfaceLayerImpl::AppendQuads(
40 RenderPass* render_pass,
41 const OcclusionTracker<LayerImpl>& occlusion_tracker,
42 AppendQuadsData* append_quads_data) {
43 SharedQuadState* shared_quad_state =
44 render_pass->CreateAndAppendSharedQuadState();
45 PopulateSharedQuadState(shared_quad_state);
47 AppendDebugBorderQuad(
48 render_pass, content_bounds(), shared_quad_state, append_quads_data);
50 if (surface_id_.is_null())
51 return;
53 gfx::Rect quad_rect(content_bounds());
54 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect(
55 quad_rect, draw_properties().target_space_transform);
56 if (visible_quad_rect.IsEmpty())
57 return;
58 SurfaceDrawQuad* quad =
59 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
60 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_);
63 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color,
64 float* width) const {
65 *color = DebugColors::SurfaceLayerBorderColor();
66 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl());
69 void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const {
70 LayerImpl::AsValueInto(dict);
71 dict->SetInteger("surface_id", surface_id_.id);
74 const char* SurfaceLayerImpl::LayerTypeAsString() const {
75 return "cc::SurfaceLayerImpl";
78 } // namespace cc