| 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
|
|
|