[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" | ||||
reveman | 6b683f2 | 2015-05-22 02:38:32 | [diff] [blame] | 9 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 10 | #include "ui/gfx/geometry/rect.h" |
11 | #include "ui/gfx/geometry/rect_f.h" | ||||
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 12 | #include "ui/gfx/geometry/size.h" |
[email protected] | 5e57db7 | 2014-08-01 21:50:17 | [diff] [blame] | 13 | #include "ui/gfx/native_widget_types.h" |
14 | #include "ui/gfx/overlay_transform.h" | ||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 15 | #include "ui/gl/gl_export.h" |
16 | |||||
17 | namespace gfx { | ||||
18 | |||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 19 | // Encapsulates an image that can be bound to a texture, hiding platform |
20 | // specific management. | ||||
21 | class GL_EXPORT GLImage : public base::RefCounted<GLImage> { | ||||
22 | public: | ||||
reveman | c0c002b | 2014-09-29 21:46:23 | [diff] [blame] | 23 | GLImage() {} |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 24 | |
25 | // Destroys the image. | ||||
[email protected] | d2eaf52f | 2014-07-31 15:01:24 | [diff] [blame] | 26 | virtual void Destroy(bool have_context) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 27 | |
28 | // Get the size of the image. | ||||
29 | virtual gfx::Size GetSize() = 0; | ||||
30 | |||||
christiank | 55ddebb | 2015-05-18 08:56:32 | [diff] [blame] | 31 | // Get the internal format of the image. |
32 | virtual unsigned GetInternalFormat() = 0; | ||||
33 | |||||
[email protected] | 3c58012 | 2013-11-22 07:52:26 | [diff] [blame] | 34 | // Bind image to texture currently bound to |target|. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 35 | virtual bool BindTexImage(unsigned target) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 36 | |
[email protected] | 3c58012 | 2013-11-22 07:52:26 | [diff] [blame] | 37 | // Release image from texture currently bound to |target|. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 38 | virtual void ReleaseTexImage(unsigned target) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 39 | |
reveman | 6b683f2 | 2015-05-22 02:38:32 | [diff] [blame] | 40 | // Copy |rect| of image to |offset| in texture currently bound to |target|. |
41 | virtual bool CopyTexSubImage(unsigned target, | ||||
42 | const Point& offset, | ||||
43 | const Rect& rect) = 0; | ||||
reveman | ce8fbe8 | 2014-09-05 02:19:52 | [diff] [blame] | 44 | |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 45 | // Called before the texture is used for drawing. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 46 | virtual void WillUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 47 | |
48 | // Called after the texture has been used for drawing. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 49 | virtual void DidUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 50 | |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 51 | // Called before the texture image data will be modified. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 52 | virtual void WillModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 53 | |
54 | // Called after the texture image data has been modified. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 55 | virtual void DidModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 56 | |
[email protected] | 5e57db7 | 2014-08-01 21:50:17 | [diff] [blame] | 57 | // Schedule image as an overlay plane to be shown at swap time for |widget|. |
58 | virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | ||||
59 | int z_order, | ||||
60 | OverlayTransform transform, | ||||
61 | const Rect& bounds_rect, | ||||
62 | const RectF& crop_rect) = 0; | ||||
63 | |||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 64 | protected: |
reveman | c0c002b | 2014-09-29 21:46:23 | [diff] [blame] | 65 | virtual ~GLImage() {} |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 66 | |
67 | private: | ||||
68 | friend class base::RefCounted<GLImage>; | ||||
69 | |||||
70 | DISALLOW_COPY_AND_ASSIGN(GLImage); | ||||
71 | }; | ||||
72 | |||||
73 | } // namespace gfx | ||||
74 | |||||
75 | #endif // UI_GL_GL_IMAGE_H_ |