Removed 'anonymous' from namespace, added whitespace in thread_restrictions.cc
[chromium-blink-merge.git] / cc / layers / heads_up_display_layer.cc
blob388c2ad2473e520d29e3da6c294af0ca63389c79
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
3 // found in the LICENSE file.
5 #include "cc/layers/heads_up_display_layer.h"
7 #include <algorithm>
9 #include "base/trace_event/trace_event.h"
10 #include "cc/layers/heads_up_display_layer_impl.h"
11 #include "cc/trees/layer_tree_host.h"
13 namespace cc {
15 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::Create(
16 const LayerSettings& settings) {
17 return make_scoped_refptr(new HeadsUpDisplayLayer(settings));
20 HeadsUpDisplayLayer::HeadsUpDisplayLayer(const LayerSettings& settings)
21 : Layer(settings) {
22 SetIsDrawable(true);
23 UpdateDrawsContent(HasDrawableContent());
26 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {}
28 void HeadsUpDisplayLayer::PrepareForCalculateDrawProperties(
29 const gfx::Size& device_viewport, float device_scale_factor) {
30 gfx::Size device_viewport_in_layout_pixels = gfx::Size(
31 device_viewport.width() / device_scale_factor,
32 device_viewport.height() / device_scale_factor);
34 gfx::Size bounds;
35 gfx::Transform matrix;
36 matrix.MakeIdentity();
38 if (layer_tree_host()->debug_state().ShowHudRects()) {
39 int max_texture_size =
40 layer_tree_host()->GetRendererCapabilities().max_texture_size;
41 bounds.SetSize(std::min(max_texture_size,
42 device_viewport_in_layout_pixels.width()),
43 std::min(max_texture_size,
44 device_viewport_in_layout_pixels.height()));
45 } else {
46 int size = 256;
47 bounds.SetSize(size, size);
48 matrix.Translate(device_viewport_in_layout_pixels.width() - size, 0.0);
51 SetBounds(bounds);
52 SetTransform(matrix);
55 bool HeadsUpDisplayLayer::HasDrawableContent() const {
56 return true;
59 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::CreateLayerImpl(
60 LayerTreeImpl* tree_impl) {
61 return HeadsUpDisplayLayerImpl::Create(tree_impl, layer_id_);
64 } // namespace cc