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

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

Issue 853863003: Serialize SkPictures to the file system (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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/BUILD.gn ('k') | sky/compositor/picture_serializer.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 "sky/compositor/layer_host.h" 8 #include "sky/compositor/layer_host.h"
9 #include "sky/compositor/picture_serializer.h"
9 #include "sky/compositor/rasterizer.h" 10 #include "sky/compositor/rasterizer.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkPictureRecorder.h" 12 #include "third_party/skia/include/core/SkPictureRecorder.h"
12 13
13 namespace sky { 14 namespace sky {
14 15
15 Layer::Layer(LayerClient* client) : client_(client) { 16 Layer::Layer(LayerClient* client) : client_(client) {
16 } 17 }
17 18
18 Layer::~Layer() { 19 Layer::~Layer() {
19 } 20 }
20 21
21 void Layer::SetSize(const gfx::Size& size) { 22 void Layer::SetSize(const gfx::Size& size) {
22 size_ = size; 23 size_ = size;
23 } 24 }
24 25
25 void Layer::Display() { 26 void Layer::Display() {
26 TRACE_EVENT0("sky", "Layer::Display"); 27 TRACE_EVENT0("sky", "Layer::Display");
27 DCHECK(rasterizer_); 28 DCHECK(rasterizer_);
28 auto picture = RecordPicture(); 29 auto picture = RecordPicture();
30
31 #if 0
32 SerializePicture(
33 "/data/data/org.chromium.mojo.shell/cache/layer0.skp", picture.get());
34 #endif
35
29 texture_ = rasterizer_->Rasterize(picture.get()); 36 texture_ = rasterizer_->Rasterize(picture.get());
30 } 37 }
31 38
32 skia::RefPtr<SkPicture> Layer::RecordPicture() { 39 skia::RefPtr<SkPicture> Layer::RecordPicture() {
33 TRACE_EVENT0("sky", "Layer::RecordPicture"); 40 TRACE_EVENT0("sky", "Layer::RecordPicture");
34 41
35 SkRTreeFactory factory; 42 SkRTreeFactory factory;
36 SkPictureRecorder recorder; 43 SkPictureRecorder recorder;
37 44
38 auto canvas = skia::SharePtr(recorder.beginRecording( 45 auto canvas = skia::SharePtr(recorder.beginRecording(
39 size_.width(), size_.height(), &factory, 46 size_.width(), size_.height(), &factory,
40 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); 47 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
41 48
42 client_->PaintContents(canvas.get(), gfx::Rect(size_)); 49 client_->PaintContents(canvas.get(), gfx::Rect(size_));
43 return skia::AdoptRef(recorder.endRecordingAsPicture()); 50 return skia::AdoptRef(recorder.endRecordingAsPicture());
44 } 51 }
45 52
46 scoped_ptr<mojo::GLTexture> Layer::GetTexture() { 53 scoped_ptr<mojo::GLTexture> Layer::GetTexture() {
47 return texture_.Pass(); 54 return texture_.Pass();
48 } 55 }
49 56
50 } // namespace sky 57 } // namespace sky
OLDNEW
« no previous file with comments | « sky/compositor/BUILD.gn ('k') | sky/compositor/picture_serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698