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

Unified Diff: sky/compositor/layer.cc

Issue 854303002: Sky should use an SkPicture when drawing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fixes 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 side-by-side diff with in-line comments
Download patch
Index: sky/compositor/layer.cc
diff --git a/sky/compositor/layer.cc b/sky/compositor/layer.cc
index 1142093f0c121281a832cad327c1bcc7ac639f37..c1bac833b6c36676dbc99ab4de9df1018df94b2a 100644
--- a/sky/compositor/layer.cc
+++ b/sky/compositor/layer.cc
@@ -5,17 +5,14 @@
#include "sky/compositor/layer.h"
#include "base/debug/trace_event.h"
-#include "mojo/skia/ganesh_surface.h"
-#include "sky/compositor/display_delegate.h"
#include "sky/compositor/layer_host.h"
+#include "sky/compositor/rasterizer.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkPictureRecorder.h"
namespace sky {
-Layer::Layer(LayerClient* client)
- : client_(client),
- host_(nullptr) {
- delegate_.reset(DisplayDelegate::create(client));
+Layer::Layer(LayerClient* client) : client_(client) {
}
Layer::~Layer() {
@@ -25,22 +22,25 @@ void Layer::SetSize(const gfx::Size& size) {
size_ = size;
}
-void Layer::GetPixelsForTesting(std::vector<unsigned char>* pixels) {
- delegate_->GetPixelsForTesting(pixels);
-}
-
void Layer::Display() {
TRACE_EVENT0("sky", "Layer::Display");
+ DCHECK(rasterizer_);
+ auto picture = RecordPicture();
+ texture_ = rasterizer_->Rasterize(picture.get());
+}
- DCHECK(host_);
+skia::RefPtr<SkPicture> Layer::RecordPicture() {
+ TRACE_EVENT0("sky", "Layer::RecordPicture");
- mojo::GaneshSurface surface(host_->ganesh_context(),
- host_->resource_manager()->CreateTexture(size_));
+ SkRTreeFactory factory;
+ SkPictureRecorder recorder;
- gfx::Rect rect(size_);
- delegate_->Paint(surface, rect);
+ auto canvas = skia::SharePtr(recorder.beginRecording(
+ size_.width(), size_.height(), &factory,
+ SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
- texture_ = surface.TakeTexture();
+ client_->PaintContents(canvas.get(), gfx::Rect(size_));
+ return skia::AdoptRef(recorder.endRecordingAsPicture());
}
scoped_ptr<mojo::GLTexture> Layer::GetTexture() {
« no previous file with comments | « sky/compositor/layer.h ('k') | sky/compositor/layer_host.h » ('j') | sky/viewer/document_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698