blob: 7798423da12ed6ff683689d4ad7861ffdd03c863 [file] [log] [blame]
[email protected]09d50362012-10-18 20:54:371// Copyright (c) 2012 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 UI_GL_GL_IMAGE_H_
6#define UI_GL_GL_IMAGE_H_
7
8#include "base/memory/ref_counted.h"
[email protected]5780f5ac2013-08-03 13:22:429#include "ui/gfx/gpu_memory_buffer.h"
[email protected]09d50362012-10-18 20:54:3710#include "ui/gfx/native_widget_types.h"
11#include "ui/gfx/size.h"
[email protected]09d50362012-10-18 20:54:3712#include "ui/gl/gl_export.h"
13
14namespace gfx {
15
16class GLSurface;
17
18// Encapsulates an image that can be bound to a texture, hiding platform
19// specific management.
20class GL_EXPORT GLImage : public base::RefCounted<GLImage> {
21 public:
22 GLImage();
23
24 // Destroys the image.
25 virtual void Destroy() = 0;
26
27 // Get the size of the image.
28 virtual gfx::Size GetSize() = 0;
29
[email protected]3c580122013-11-22 07:52:2630 // Bind image to texture currently bound to |target|.
[email protected]463c12b2014-03-15 00:25:4931 virtual bool BindTexImage(unsigned target) = 0;
[email protected]09d50362012-10-18 20:54:3732
[email protected]3c580122013-11-22 07:52:2633 // Release image from texture currently bound to |target|.
[email protected]463c12b2014-03-15 00:25:4934 virtual void ReleaseTexImage(unsigned target) = 0;
[email protected]09d50362012-10-18 20:54:3735
[email protected]91c94eb2013-10-22 10:32:5436 // Called before the texture is used for drawing.
[email protected]463c12b2014-03-15 00:25:4937 virtual void WillUseTexImage() = 0;
[email protected]91c94eb2013-10-22 10:32:5438
39 // Called after the texture has been used for drawing.
[email protected]463c12b2014-03-15 00:25:4940 virtual void DidUseTexImage() = 0;
[email protected]91c94eb2013-10-22 10:32:5441
[email protected]00c2cf92014-03-14 00:08:3742 // Called before the texture image data will be modified.
[email protected]463c12b2014-03-15 00:25:4943 virtual void WillModifyTexImage() = 0;
[email protected]00c2cf92014-03-14 00:08:3744
45 // Called after the texture image data has been modified.
[email protected]463c12b2014-03-15 00:25:4946 virtual void DidModifyTexImage() = 0;
[email protected]00c2cf92014-03-14 00:08:3747
[email protected]40245ccf2013-11-13 04:00:4948 // Indicate that image should be released after use.
49 // (For an Android work-around only).
50 virtual void SetReleaseAfterUse();
51
[email protected]09d50362012-10-18 20:54:3752 // Create a GL image for a window.
53 static scoped_refptr<GLImage> CreateGLImage(gfx::PluginWindowHandle window);
54
[email protected]b8160812013-04-09 00:41:0455 // Create a GL image for a GPU Memory buffer.
56 static scoped_refptr<GLImage> CreateGLImageForGpuMemoryBuffer(
[email protected]bac37fd32013-08-16 17:31:0057 gfx::GpuMemoryBufferHandle buffer,
58 gfx::Size size,
59 unsigned internalformat);
[email protected]b8160812013-04-09 00:41:0460
[email protected]09d50362012-10-18 20:54:3761 protected:
62 virtual ~GLImage();
63
64 private:
65 friend class base::RefCounted<GLImage>;
66
67 DISALLOW_COPY_AND_ASSIGN(GLImage);
68};
69
70} // namespace gfx
71
72#endif // UI_GL_GL_IMAGE_H_