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

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

Issue 797063002: Make reftests work for sky. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 6 years 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
« no previous file with comments | « sky/compositor/layer.h ('k') | sky/compositor/layer_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/debug/trace_event.h"
8 #include "mojo/skia/ganesh_surface.h" 8 #include "mojo/skia/ganesh_surface.h"
9 #include "sky/compositor/display_delegate.h"
9 #include "sky/compositor/layer_host.h" 10 #include "sky/compositor/layer_host.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
11 12
12 namespace sky { 13 namespace sky {
13 14
14 Layer::Layer(LayerClient* client) : client_(client), host_(nullptr) { 15 Layer::Layer(LayerClient* client)
16 : client_(client),
17 host_(nullptr) {
18 delegate_.reset(DisplayDelegate::create(client));
15 } 19 }
16 20
17 Layer::~Layer() { 21 Layer::~Layer() {
18 } 22 }
19 23
20 void Layer::ClearClient() {
21 client_ = nullptr;
22 }
23
24 void Layer::SetSize(const gfx::Size& size) { 24 void Layer::SetSize(const gfx::Size& size) {
25 size_ = size; 25 size_ = size;
26 } 26 }
27 27
28 void Layer::GetPixelsForTesting(std::vector<unsigned char>* pixels) {
29 delegate_->GetPixelsForTesting(pixels);
30 }
31
28 void Layer::Display() { 32 void Layer::Display() {
29 TRACE_EVENT0("sky", "Layer::Display"); 33 TRACE_EVENT0("sky", "Layer::Display");
30 34
31 DCHECK(host_); 35 DCHECK(host_);
32 36
33 mojo::GaneshSurface surface(host_->ganesh_context(), 37 mojo::GaneshSurface surface(host_->ganesh_context(),
34 host_->resource_manager()->CreateTexture(size_)); 38 host_->resource_manager()->CreateTexture(size_));
35 39
36 SkCanvas* canvas = surface.canvas();
37
38 gfx::Rect rect(size_); 40 gfx::Rect rect(size_);
39 client_->PaintContents(canvas, rect); 41 delegate_->Paint(surface, rect);
40 canvas->flush();
41 42
42 texture_ = surface.TakeTexture(); 43 texture_ = surface.TakeTexture();
43 } 44 }
44 45
45 scoped_ptr<mojo::GLTexture> Layer::GetTexture() { 46 scoped_ptr<mojo::GLTexture> Layer::GetTexture() {
46 return texture_.Pass(); 47 return texture_.Pass();
47 } 48 }
48 49
49 } // namespace sky 50 } // namespace sky
OLDNEW
« no previous file with comments | « sky/compositor/layer.h ('k') | sky/compositor/layer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698