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

Unified 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: address feedback 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/ui/content_viewer_app.cc ('k') | mojo/ui/ganesh_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/ui/ganesh_renderer.h
diff --git a/mojo/ui/ganesh_renderer.h b/mojo/ui/ganesh_renderer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5190ecd958a7b663c1cbaa5217e17356db46e244
--- /dev/null
+++ b/mojo/ui/ganesh_renderer.h
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_UI_GANESH_RENDERER_H_
+#define MOJO_UI_GANESH_RENDERER_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "mojo/services/gfx/composition/interfaces/resources.mojom.h"
+#include "mojo/ui/gl_renderer.h"
+
+class SkCanvas;
+class SkSurface;
+
+namespace mojo {
+namespace skia {
+class GaneshContext;
+} // namespace skia
+
+namespace ui {
+
+// Provides support for rendering Skia commands into surfaces backed by
+// a pool of textures and producing scene resources for them.
+class GaneshRenderer {
+ public:
+ // Called with an active GaneshContext and a Skia surface or canvas
+ // to draw into the framebuffer.
+ using DrawSurfaceCallback = base::Callback<void(SkSurface* surface)>;
+ using DrawCanvasCallback = base::Callback<void(SkCanvas* canvas)>;
+
+ // Creates a Ganesh backed renderer.
+ // Does not take ownership of |ganesh_context|; it must outlive the renderer.
+ explicit GaneshRenderer(mojo::skia::GaneshContext* ganesh_context);
+ ~GaneshRenderer();
+
+ // Gets the Ganesh context.
+ mojo::skia::GaneshContext* ganesh_context() { return ganesh_context_; }
+
+ // Allocates a GL texture, binds it to a Ganesh surface or canvas,
+ // invokes the provided function, then returns the resulting resource.
+ mojo::gfx::composition::ResourcePtr DrawSurface(
+ const mojo::Size& size,
+ const DrawSurfaceCallback& callback);
+ mojo::gfx::composition::ResourcePtr DrawCanvas(
+ const mojo::Size& size,
+ const DrawCanvasCallback& callback);
+
+ private:
+ mojo::skia::GaneshContext* ganesh_context_;
+ mojo::ui::GLRenderer gl_renderer_;
+
+ DISALLOW_COPY_AND_ASSIGN(GaneshRenderer);
+};
+
+} // namespace ui
+} // namespace mojo
+
+#endif // MOJO_UI_GANESH_RENDERER_H_
« no previous file with comments | « mojo/ui/content_viewer_app.cc ('k') | mojo/ui/ganesh_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698