[Do not revert] Roll-back V8 to version 4.4.63.
[chromium-blink-merge.git] / cc / layers / surface_layer_impl.cc
blob966112d7f546c1147471fdaf4f68d93fe395cc80
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 "base/trace_event/trace_event_argument.h"
8 #include "cc/debug/debug_colors.h"
9 #include "cc/quads/surface_draw_quad.h"
10 #include "cc/trees/occlusion.h"
12 namespace cc {
14 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
15 : LayerImpl(tree_impl, id) {
18 SurfaceLayerImpl::~SurfaceLayerImpl() {}
20 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl(
21 LayerTreeImpl* tree_impl) {
22 return SurfaceLayerImpl::Create(tree_impl, id());
25 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) {
26 if (surface_id_ == surface_id)
27 return;
29 surface_id_ = surface_id;
30 NoteLayerPropertyChanged();
33 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
34 LayerImpl::PushPropertiesTo(layer);
35 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
37 layer_impl->SetSurfaceId(surface_id_);
40 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
41 AppendQuadsData* append_quads_data) {
42 SharedQuadState* shared_quad_state =
43 render_pass->CreateAndAppendSharedQuadState();
44 PopulateSharedQuadState(shared_quad_state);
46 AppendDebugBorderQuad(
47 render_pass, content_bounds(), shared_quad_state, append_quads_data);
49 if (surface_id_.is_null())
50 return;
52 gfx::Rect quad_rect(content_bounds());
53 gfx::Rect visible_quad_rect =
54 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
55 quad_rect);
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::trace_event::TracedValue* 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