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

Unified Diff: services/gfx/compositor/render/render_image.cc

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: Created 4 years, 12 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
Index: services/gfx/compositor/render/render_image.cc
diff --git a/services/gfx/compositor/render/render_image.cc b/services/gfx/compositor/render/render_image.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17b6fb76719fea3dacde75c3d248eb40352d6347
--- /dev/null
+++ b/services/gfx/compositor/render/render_image.cc
@@ -0,0 +1,62 @@
+// 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 GL_GLEXT_PROTOTYPES
+#define GL_GLEXT_PROTOTYPES
+#endif
+
+#include "services/gfx/compositor/render/render_image.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "mojo/skia/ganesh_helpers.h"
+#include "third_party/skia/include/core/SkImage.h"
+
+namespace compositor {
+
+static void DeleteTexture(GLuint texture_id) {
+ glDeleteTextures(1, &texture_id);
+}
+
+RenderImage::RenderImage(const uint8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM],
+ uint32_t sync_point,
+ uint32_t width,
+ uint32_t height,
+ const scoped_refptr<base::TaskRunner>& task_runner,
+ const base::Closure& release_task)
+ : sync_point_(sync_point),
+ width_(width),
+ height_(height),
+ task_runner_(task_runner),
+ release_task_(release_task) {
+ DCHECK(mailbox_name);
+ DCHECK(width_);
+ DCHECK(height_);
+ DCHECK(task_runner_);
+ memcpy(mailbox_name_, mailbox_name, GL_MAILBOX_SIZE_CHROMIUM);
+}
+
+RenderImage::~RenderImage() {
+ task_runner_->PostTask(FROM_HERE, release_task_);
+}
+
+// Creates a Skia image for this rendr image.
+// Automatically inserts a sync point into the GL command stream.
+skia::RefPtr<SkImage> RenderImage::CreateSkImage(
+ const PaintingScope& painting_scope) const {
+ if (sync_point_)
+ glWaitSyncPointCHROMIUM(sync_point_);
+
+ GLuint texture_id =
+ glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name_);
+ if (!texture_id)
+ return skia::RefPtr<SkImage>();
+
+ return mojo::skia::CreateImageFromTexture(
+ painting_scope.ganesh_scope(), texture_id, width_, height_,
+ base::Bind(&DeleteTexture, texture_id));
+}
+
+} // namespace compositor

Powered by Google App Engine
This is Rietveld 408576698