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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 if (!surface_) | 48 if (!surface_) |
49 return; | 49 return; |
50 | 50 |
51 gfx::Size size = GetSize(picture.get()); | 51 gfx::Size size = GetSize(picture.get()); |
52 if (size.IsEmpty()) | 52 if (size.IsEmpty()) |
53 return; | 53 return; |
54 | 54 |
55 EnsureGLContext(); | 55 EnsureGLContext(); |
56 CHECK(context_->MakeCurrent(surface_.get())); | 56 CHECK(context_->MakeCurrent(surface_.get())); |
57 EnsureGaneshSurface(size); | 57 EnsureGaneshSurface(surface_->GetBackingFrameBufferObject(), size); |
58 | 58 |
59 DrawPicture(picture.get()); | 59 DrawPicture(picture.get()); |
60 surface_->SwapBuffers(); | 60 surface_->SwapBuffers(); |
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 ganesh_surface_.reset(); | 71 ganesh_surface_.reset(); |
72 ganesh_context_.reset(); | 72 ganesh_context_.reset(); |
73 context_ = nullptr; | 73 context_ = nullptr; |
74 surface_ = nullptr; | 74 surface_ = nullptr; |
75 } | 75 } |
76 | 76 |
77 void Rasterizer::EnsureGLContext() { | 77 void Rasterizer::EnsureGLContext() { |
78 if (context_) | 78 if (context_) |
79 return; | 79 return; |
80 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), | 80 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), |
81 gfx::PreferIntegratedGpu); | 81 gfx::PreferIntegratedGpu); |
82 CHECK(context_) << "GLContext required."; | 82 CHECK(context_) << "GLContext required."; |
83 CHECK(context_->MakeCurrent(surface_.get())); | 83 CHECK(context_->MakeCurrent(surface_.get())); |
84 ganesh_context_.reset(new GaneshContext(context_.get())); | 84 ganesh_context_.reset(new GaneshContext(context_.get())); |
85 } | 85 } |
86 | 86 |
87 void Rasterizer::EnsureGaneshSurface(const gfx::Size& size) { | 87 void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo, |
| 88 const gfx::Size& size) { |
88 if (!ganesh_surface_ || ganesh_surface_->size() != size) | 89 if (!ganesh_surface_ || ganesh_surface_->size() != size) |
89 ganesh_surface_.reset(new GaneshSurface(ganesh_context_.get(), size)); | 90 ganesh_surface_.reset( |
| 91 new GaneshSurface(window_fbo, ganesh_context_.get(), size)); |
90 } | 92 } |
91 | 93 |
92 } // namespace shell | 94 } // namespace shell |
93 } // namespace sky | 95 } // namespace sky |
OLD | NEW |