[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 1 | // 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] | 5780f5ac | 2013-08-03 13:22:42 | [diff] [blame] | 9 | #include "ui/gfx/gpu_memory_buffer.h" |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 10 | #include "ui/gfx/native_widget_types.h" |
11 | #include "ui/gfx/size.h" | ||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 12 | #include "ui/gl/gl_export.h" |
13 | |||||
14 | namespace gfx { | ||||
15 | |||||
16 | class GLSurface; | ||||
17 | |||||
18 | // Encapsulates an image that can be bound to a texture, hiding platform | ||||
19 | // specific management. | ||||
20 | class 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] | 3c58012 | 2013-11-22 07:52:26 | [diff] [blame] | 30 | // Bind image to texture currently bound to |target|. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 31 | virtual bool BindTexImage(unsigned target) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 32 | |
[email protected] | 3c58012 | 2013-11-22 07:52:26 | [diff] [blame] | 33 | // Release image from texture currently bound to |target|. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 34 | virtual void ReleaseTexImage(unsigned target) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 35 | |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 36 | // Called before the texture is used for drawing. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 37 | virtual void WillUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 38 | |
39 | // Called after the texture has been used for drawing. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 40 | virtual void DidUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 41 | |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 42 | // Called before the texture image data will be modified. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 43 | virtual void WillModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 44 | |
45 | // Called after the texture image data has been modified. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame^] | 46 | virtual void DidModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 47 | |
[email protected] | 40245ccf | 2013-11-13 04:00:49 | [diff] [blame] | 48 | // Indicate that image should be released after use. |
49 | // (For an Android work-around only). | ||||
50 | virtual void SetReleaseAfterUse(); | ||||
51 | |||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 52 | // Create a GL image for a window. |
53 | static scoped_refptr<GLImage> CreateGLImage(gfx::PluginWindowHandle window); | ||||
54 | |||||
[email protected] | b816081 | 2013-04-09 00:41:04 | [diff] [blame] | 55 | // Create a GL image for a GPU Memory buffer. |
56 | static scoped_refptr<GLImage> CreateGLImageForGpuMemoryBuffer( | ||||
[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 57 | gfx::GpuMemoryBufferHandle buffer, |
58 | gfx::Size size, | ||||
59 | unsigned internalformat); | ||||
[email protected] | b816081 | 2013-04-09 00:41:04 | [diff] [blame] | 60 | |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 61 | 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_ |