| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell/gpu/rasterizer.h" | 5 #include "sky/shell/gpu/rasterizer.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "sky/shell/gpu/ganesh_context.h" | 8 #include "sky/shell/gpu/ganesh_context.h" |
| 9 #include "sky/shell/gpu/ganesh_surface.h" | 9 #include "sky/shell/gpu/ganesh_surface.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 void Rasterizer::DrawPicture(SkPicture* picture) { | 63 void Rasterizer::DrawPicture(SkPicture* picture) { |
| 64 TRACE_EVENT0("sky", "Rasterizer::DrawPicture"); | 64 TRACE_EVENT0("sky", "Rasterizer::DrawPicture"); |
| 65 SkCanvas* canvas = ganesh_surface_->canvas(); | 65 SkCanvas* canvas = ganesh_surface_->canvas(); |
| 66 canvas->drawPicture(picture); | 66 canvas->drawPicture(picture); |
| 67 canvas->flush(); | 67 canvas->flush(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void Rasterizer::OnOutputSurfaceDestroyed() { | 70 void Rasterizer::OnOutputSurfaceDestroyed() { |
| 71 CHECK(context_->MakeCurrent(surface_.get())); |
| 71 ganesh_surface_.reset(); | 72 ganesh_surface_.reset(); |
| 72 ganesh_context_.reset(); | 73 ganesh_context_.reset(); |
| 73 context_ = nullptr; | 74 context_ = nullptr; |
| 74 surface_ = nullptr; | 75 surface_ = nullptr; |
| 75 } | 76 } |
| 76 | 77 |
| 77 void Rasterizer::EnsureGLContext() { | 78 void Rasterizer::EnsureGLContext() { |
| 78 if (context_) | 79 if (context_) |
| 79 return; | 80 return; |
| 80 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), | 81 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), |
| 81 gfx::PreferIntegratedGpu); | 82 gfx::PreferIntegratedGpu); |
| 82 CHECK(context_) << "GLContext required."; | 83 CHECK(context_) << "GLContext required."; |
| 83 CHECK(context_->MakeCurrent(surface_.get())); | 84 CHECK(context_->MakeCurrent(surface_.get())); |
| 84 ganesh_context_.reset(new GaneshContext(context_.get())); | 85 ganesh_context_.reset(new GaneshContext(context_.get())); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo, | 88 void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo, |
| 88 const gfx::Size& size) { | 89 const gfx::Size& size) { |
| 89 if (!ganesh_surface_ || ganesh_surface_->size() != size) | 90 if (!ganesh_surface_ || ganesh_surface_->size() != size) |
| 90 ganesh_surface_.reset( | 91 ganesh_surface_.reset( |
| 91 new GaneshSurface(window_fbo, ganesh_context_.get(), size)); | 92 new GaneshSurface(window_fbo, ganesh_context_.get(), size)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 } // namespace shell | 95 } // namespace shell |
| 95 } // namespace sky | 96 } // namespace sky |
| OLD | NEW |