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

Side by Side Diff: mojo/ui/ganesh_renderer.h

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_UI_GANESH_RENDERER_H_
6 #define MOJO_UI_GANESH_RENDERER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h"
11 #include "mojo/ui/gl_renderer.h"
12
13 class SkCanvas;
14 class SkSurface;
15
16 namespace mojo {
17 namespace skia {
18 class GaneshContext;
19 } // namespace skia
20
21 namespace ui {
22
23 // Provides support for rendering Skia commands into surfaces backed by
24 // a pool of textures and producing scene resources for them.
25 class GaneshRenderer {
26 public:
27 // Called with an active GaneshContext and a Skia surface or canvas
28 // to draw into the framebuffer.
29 using DrawSurfaceCallback = base::Callback<void(SkSurface* surface)>;
30 using DrawCanvasCallback = base::Callback<void(SkCanvas* canvas)>;
31
32 // Creates a Ganesh backed renderer.
33 // Does not take ownership of |ganesh_context|; it must outlive the renderer.
34 GaneshRenderer(mojo::skia::GaneshContext* ganesh_context);
viettrungluu 2016/01/05 21:53:26 nit: |explicit|
35 ~GaneshRenderer();
36
37 // Gets the Ganesh context.
38 mojo::skia::GaneshContext* ganesh_context() { return ganesh_context_; }
39
40 // Allocates a GL texture, binds it to a Ganesh surface or canvas,
41 // invokes the provided function, then returns the resulting resource.
42 mojo::gfx::composition::ResourcePtr DrawSurface(
43 const mojo::Size& size,
44 const DrawSurfaceCallback& callback);
45 mojo::gfx::composition::ResourcePtr DrawCanvas(
46 const mojo::Size& size,
47 const DrawCanvasCallback& callback);
48
49 private:
50 mojo::skia::GaneshContext* ganesh_context_;
51 mojo::ui::GLRenderer gl_renderer_;
52
53 DISALLOW_COPY_AND_ASSIGN(GaneshRenderer);
54 };
55
56 } // namespace ui
57 } // namespace mojo
58
59 #endif // MOJO_UI_GANESH_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698