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/layers/quad_sink.h"
9 #include "cc/quads/surface_draw_quad.h"
13 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl
* tree_impl
, int id
)
14 : LayerImpl(tree_impl
, id
), surface_id_(0) {}
16 SurfaceLayerImpl::~SurfaceLayerImpl() {}
18 scoped_ptr
<LayerImpl
> SurfaceLayerImpl::CreateLayerImpl(
19 LayerTreeImpl
* tree_impl
) {
20 return SurfaceLayerImpl::Create(tree_impl
, id()).PassAs
<LayerImpl
>();
23 void SurfaceLayerImpl::SetSurfaceId(int surface_id
) {
24 if (surface_id_
== surface_id
)
27 surface_id_
= surface_id
;
28 NoteLayerPropertyChanged();
31 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl
* layer
) {
32 LayerImpl::PushPropertiesTo(layer
);
33 SurfaceLayerImpl
* layer_impl
= static_cast<SurfaceLayerImpl
*>(layer
);
35 layer_impl
->SetSurfaceId(surface_id_
);
38 void SurfaceLayerImpl::AppendQuads(QuadSink
* quad_sink
,
39 AppendQuadsData
* append_quads_data
) {
40 SharedQuadState
* shared_quad_state
=
41 quad_sink
->UseSharedQuadState(CreateSharedQuadState());
42 AppendDebugBorderQuad(quad_sink
, shared_quad_state
, append_quads_data
);
47 scoped_ptr
<SurfaceDrawQuad
> quad
= SurfaceDrawQuad::Create();
48 gfx::Rect
quad_rect(content_bounds());
49 quad
->SetNew(shared_quad_state
, quad_rect
, surface_id_
);
50 quad_sink
->Append(quad
.PassAs
<DrawQuad
>(), append_quads_data
);
53 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor
* color
,
55 *color
= DebugColors::SurfaceLayerBorderColor();
56 *width
= DebugColors::SurfaceLayerBorderWidth(layer_tree_impl());
59 void SurfaceLayerImpl::AsValueInto(base::DictionaryValue
* dict
) const {
60 LayerImpl::AsValueInto(dict
);
61 dict
->SetInteger("surface_id", surface_id_
);
64 const char* SurfaceLayerImpl::LayerTypeAsString() const {
65 return "cc::SurfaceLayerImpl";