| Index: services/gfx/compositor/render/render_image.h
|
| diff --git a/services/gfx/compositor/render/render_image.h b/services/gfx/compositor/render/render_image.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b6a8fa74135be23ad1a0cee62f2c7e434967fc6d
|
| --- /dev/null
|
| +++ b/services/gfx/compositor/render/render_image.h
|
| @@ -0,0 +1,77 @@
|
| +// 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 SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_
|
| +#define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_
|
| +
|
| +#include <memory>
|
| +
|
| +#include <GLES2/gl2.h>
|
| +#include <GLES2/gl2extmojo.h>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/task_runner.h"
|
| +#include "services/gfx/compositor/render/painting.h"
|
| +
|
| +class SkImage;
|
| +
|
| +namespace compositor {
|
| +
|
| +// Describes an image which can be rendered by the compositor.
|
| +//
|
| +// Render objects are thread-safe, immutable, and reference counted via
|
| +// std::shared_ptr. They have no direct references to the scene graph.
|
| +//
|
| +// TODO(jeffbrown): Generalize this beyond mailbox textures.
|
| +class RenderImage {
|
| + public:
|
| + 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_callback);
|
| + ~RenderImage();
|
| +
|
| + // Creates a new image backed by a mailbox texture.
|
| + // When the last reference is released, the associated release task is
|
| + // posted to the task runner.
|
| + static std::shared_ptr<RenderImage> FromMailboxTexture(
|
| + 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) {
|
| + return std::make_shared<RenderImage>(mailbox_name, sync_point, width,
|
| + height, task_runner, release_task);
|
| + }
|
| +
|
| + // Gets the dimensions of the image.
|
| + uint32_t width() const { return width_; }
|
| + uint32_t height() const { return height_; }
|
| +
|
| + // Creates a Skia image from the underlying texture.
|
| + // Automatically inserts a sync point into the GL command stream.
|
| + // Returns null if the image could not be created.
|
| + skia::RefPtr<SkImage> CreateSkImage(
|
| + const PaintingScope& painting_scope) const;
|
| +
|
| + private:
|
| + GLbyte mailbox_name_[GL_MAILBOX_SIZE_CHROMIUM];
|
| + uint32_t const sync_point_;
|
| + uint32_t const width_;
|
| + uint32_t const height_;
|
| +
|
| + scoped_refptr<base::TaskRunner> const task_runner_;
|
| + base::Closure const release_task_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RenderImage);
|
| +};
|
| +
|
| +} // namespace compositor
|
| +
|
| +#endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_
|
|
|