| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "examples/ganesh_app/ganesh_view.h" | 5 #include "examples/ganesh_app/ganesh_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "mojo/skia/ganesh_surface.h" | 9 #include "mojo/skia/ganesh_texture_surface.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 | 12 |
| 13 namespace examples { | 13 namespace examples { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 mojo::Size ToSize(const mojo::Rect& rect) { | 17 mojo::Size ToSize(const mojo::Rect& rect) { |
| 18 mojo::Size size; | 18 mojo::Size size; |
| 19 size.width = rect.width; | 19 size.width = rect.width; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 void GaneshView::OnViewBoundsChanged(mojo::View* view, | 58 void GaneshView::OnViewBoundsChanged(mojo::View* view, |
| 59 const mojo::Rect& old_bounds, | 59 const mojo::Rect& old_bounds, |
| 60 const mojo::Rect& new_bounds) { | 60 const mojo::Rect& new_bounds) { |
| 61 Draw(ToSize(new_bounds)); | 61 Draw(ToSize(new_bounds)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void GaneshView::Draw(const mojo::Size& size) { | 64 void GaneshView::Draw(const mojo::Size& size) { |
| 65 TRACE_EVENT0("ganesh_app", __func__); | 65 TRACE_EVENT0("ganesh_app", __func__); |
| 66 mojo::GaneshContext::Scope scope(gr_context_.get()); | 66 mojo::GaneshContext::Scope scope(gr_context_.get()); |
| 67 mojo::GaneshSurface surface( | 67 mojo::GaneshTextureSurface surface( |
| 68 gr_context_.get(), | 68 gr_context_.get(), |
| 69 make_scoped_ptr(new mojo::GLTexture(gl_context_, size))); | 69 std::unique_ptr<mojo::GLTexture>(new mojo::GLTexture(gl_context_, size))); |
| 70 | 70 |
| 71 SkCanvas* canvas = surface.canvas(); | 71 SkCanvas* canvas = surface.canvas(); |
| 72 canvas->clear(SK_ColorCYAN); | 72 canvas->clear(SK_ColorCYAN); |
| 73 | 73 |
| 74 SkPaint paint; | 74 SkPaint paint; |
| 75 paint.setColor(SK_ColorGREEN); | 75 paint.setColor(SK_ColorGREEN); |
| 76 SkRect rect = SkRect::MakeWH(size.width, size.height); | 76 SkRect rect = SkRect::MakeWH(size.width, size.height); |
| 77 rect.inset(10, 10); | 77 rect.inset(10, 10); |
| 78 canvas->drawRect(rect, paint); | 78 canvas->drawRect(rect, paint); |
| 79 | 79 |
| 80 paint.setColor(SK_ColorRED); | 80 paint.setColor(SK_ColorRED); |
| 81 paint.setFlags(SkPaint::kAntiAlias_Flag); | 81 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 82 canvas->drawCircle(50, 100, 100, paint); | 82 canvas->drawCircle(50, 100, 100, paint); |
| 83 | 83 |
| 84 canvas->flush(); | 84 canvas->flush(); |
| 85 | 85 |
| 86 texture_uploader_.Upload(surface.TakeTexture()); | 86 texture_uploader_.Upload( |
| 87 scoped_ptr<mojo::GLTexture>(surface.TakeTexture().release())); |
| 87 } | 88 } |
| 88 | 89 |
| 89 } // namespace examples | 90 } // namespace examples |
| OLD | NEW |