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

Unified Diff: sky/shell/gpu/rasterizer.cc

Issue 936883002: Connect Sky and Ganesh in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address review comments Created 5 years, 10 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
« no previous file with comments | « sky/shell/gpu/rasterizer.h ('k') | sky/shell/gpu_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/shell/gpu/rasterizer.cc
diff --git a/sky/shell/gpu/rasterizer.cc b/sky/shell/gpu/rasterizer.cc
index 70336e64df84b7043a2bae8a68d0779da976f2c2..d841ea8a478f3ec0b0becac9eb4c7227c8ed98e2 100644
--- a/sky/shell/gpu/rasterizer.cc
+++ b/sky/shell/gpu/rasterizer.cc
@@ -24,7 +24,8 @@ gfx::Size GetSize(SkPicture* picture) {
} // namespace
-Rasterizer::Rasterizer() : weak_factory_(this) {
+Rasterizer::Rasterizer()
+ : share_group_(new gfx::GLShareGroup()), weak_factory_(this) {
}
Rasterizer::~Rasterizer() {
@@ -35,14 +36,15 @@ base::WeakPtr<Rasterizer> Rasterizer::GetWeakPtr() {
}
void Rasterizer::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) {
- share_group_ = make_scoped_refptr(new gfx::GLShareGroup());
surface_ = gfx::GLSurface::CreateViewGLSurface(widget);
CHECK(surface_) << "GLSurface required.";
- CHECK(CreateGLContext()) << "GLContext required.";
}
void Rasterizer::Draw(skia::RefPtr<SkPicture> picture) {
- // TODO(abarth): We should handle losing the GL context.
+ if (!surface_)
+ return;
+
+ EnsureGLContext();
CHECK(context_->MakeCurrent(surface_.get()));
EnsureGaneshSurface(GetSize(picture.get()));
@@ -54,15 +56,20 @@ void Rasterizer::Draw(skia::RefPtr<SkPicture> picture) {
}
void Rasterizer::OnOutputSurfaceDestroyed() {
+ ganesh_surface_.reset();
+ ganesh_context_.reset();
+ context_ = nullptr;
+ surface_ = nullptr;
}
-bool Rasterizer::CreateGLContext() {
+void Rasterizer::EnsureGLContext() {
+ if (context_)
+ return;
context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(),
gfx::PreferIntegratedGpu);
- if (!context_)
- return false;
+ CHECK(context_) << "GLContext required.";
+ CHECK(context_->MakeCurrent(surface_.get()));
ganesh_context_.reset(new GaneshContext(context_.get()));
- return true;
}
void Rasterizer::EnsureGaneshSurface(const gfx::Size& size) {
« no previous file with comments | « sky/shell/gpu/rasterizer.h ('k') | sky/shell/gpu_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698