OLD | NEW |
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 "sky/compositor/layer.h" | 5 #include "sky/compositor/layer.h" |
6 | 6 |
| 7 #include "base/debug/trace_event.h" |
7 #include "mojo/skia/ganesh_surface.h" | 8 #include "mojo/skia/ganesh_surface.h" |
8 #include "sky/compositor/layer_host.h" | 9 #include "sky/compositor/layer_host.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
10 | 11 |
11 namespace sky { | 12 namespace sky { |
12 | 13 |
13 Layer::Layer(LayerClient* client) : client_(client), host_(nullptr) { | 14 Layer::Layer(LayerClient* client) : client_(client), host_(nullptr) { |
14 } | 15 } |
15 | 16 |
16 Layer::~Layer() { | 17 Layer::~Layer() { |
17 } | 18 } |
18 | 19 |
19 void Layer::ClearClient() { | 20 void Layer::ClearClient() { |
20 client_ = nullptr; | 21 client_ = nullptr; |
21 } | 22 } |
22 | 23 |
23 void Layer::SetSize(const gfx::Size& size) { | 24 void Layer::SetSize(const gfx::Size& size) { |
24 size_ = size; | 25 size_ = size; |
25 } | 26 } |
26 | 27 |
27 void Layer::Display() { | 28 void Layer::Display() { |
| 29 TRACE_EVENT0("sky", "Layer::Display"); |
| 30 |
28 DCHECK(host_); | 31 DCHECK(host_); |
29 | 32 |
30 mojo::GaneshSurface surface(host_->ganesh_context(), | 33 mojo::GaneshSurface surface(host_->ganesh_context(), |
31 host_->resource_manager()->CreateTexture(size_)); | 34 host_->resource_manager()->CreateTexture(size_)); |
32 | 35 |
33 SkCanvas* canvas = surface.canvas(); | 36 SkCanvas* canvas = surface.canvas(); |
34 | 37 |
35 gfx::Rect rect(size_); | 38 gfx::Rect rect(size_); |
36 client_->PaintContents(canvas, rect); | 39 client_->PaintContents(canvas, rect); |
37 canvas->flush(); | 40 canvas->flush(); |
38 | 41 |
39 texture_ = surface.TakeTexture(); | 42 texture_ = surface.TakeTexture(); |
40 } | 43 } |
41 | 44 |
42 scoped_ptr<mojo::GLTexture> Layer::GetTexture() { | 45 scoped_ptr<mojo::GLTexture> Layer::GetTexture() { |
43 return texture_.Pass(); | 46 return texture_.Pass(); |
44 } | 47 } |
45 | 48 |
46 } // namespace sky | 49 } // namespace sky |
OLD | NEW |