Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: sky/compositor/layer.cc

Issue 740923002: Add a simple compositor for Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address reviewer comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698