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 "sky/shell/gpu/picture_serializer.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/SkPicture.h" | 12 #include "third_party/skia/include/core/SkPicture.h" |
12 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
13 #include "ui/gl/gl_context.h" | 14 #include "ui/gl/gl_context.h" |
14 #include "ui/gl/gl_share_group.h" | 15 #include "ui/gl/gl_share_group.h" |
15 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
16 | 17 |
17 namespace sky { | 18 namespace sky { |
18 namespace shell { | 19 namespace shell { |
19 namespace { | 20 namespace { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 gfx::Size size = GetSize(picture.get()); | 52 gfx::Size size = GetSize(picture.get()); |
52 if (size.IsEmpty()) | 53 if (size.IsEmpty()) |
53 return; | 54 return; |
54 | 55 |
55 EnsureGLContext(); | 56 EnsureGLContext(); |
56 CHECK(context_->MakeCurrent(surface_.get())); | 57 CHECK(context_->MakeCurrent(surface_.get())); |
57 EnsureGaneshSurface(surface_->GetBackingFrameBufferObject(), size); | 58 EnsureGaneshSurface(surface_->GetBackingFrameBufferObject(), size); |
58 | 59 |
59 DrawPicture(picture.get()); | 60 DrawPicture(picture.get()); |
60 surface_->SwapBuffers(); | 61 surface_->SwapBuffers(); |
| 62 |
| 63 // SerializePicture("/data/data/org.domokit.sky.demo/cache/layer0.skp", pictur
e.get()); |
61 } | 64 } |
62 | 65 |
63 void Rasterizer::DrawPicture(SkPicture* picture) { | 66 void Rasterizer::DrawPicture(SkPicture* picture) { |
64 TRACE_EVENT0("sky", "Rasterizer::DrawPicture"); | 67 TRACE_EVENT0("sky", "Rasterizer::DrawPicture"); |
65 SkCanvas* canvas = ganesh_surface_->canvas(); | 68 SkCanvas* canvas = ganesh_surface_->canvas(); |
66 canvas->drawPicture(picture); | 69 canvas->drawPicture(picture); |
67 canvas->flush(); | 70 canvas->flush(); |
68 } | 71 } |
69 | 72 |
70 void Rasterizer::OnOutputSurfaceDestroyed() { | 73 void Rasterizer::OnOutputSurfaceDestroyed() { |
(...skipping 16 matching lines...) Expand all Loading... |
87 | 90 |
88 void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo, | 91 void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo, |
89 const gfx::Size& size) { | 92 const gfx::Size& size) { |
90 if (!ganesh_surface_ || ganesh_surface_->size() != size) | 93 if (!ganesh_surface_ || ganesh_surface_->size() != size) |
91 ganesh_surface_.reset( | 94 ganesh_surface_.reset( |
92 new GaneshSurface(window_fbo, ganesh_context_.get(), size)); | 95 new GaneshSurface(window_fbo, ganesh_context_.get(), size)); |
93 } | 96 } |
94 | 97 |
95 } // namespace shell | 98 } // namespace shell |
96 } // namespace sky | 99 } // namespace sky |
OLD | NEW |