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