[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" | ||||
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 9 | #include "ui/gfx/geometry/rect.h" |
10 | #include "ui/gfx/geometry/rect_f.h" | ||||
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame^] | 11 | #include "ui/gfx/geometry/size.h" |
[email protected] | 5e57db7 | 2014-08-01 21:50:17 | [diff] [blame] | 12 | #include "ui/gfx/native_widget_types.h" |
13 | #include "ui/gfx/overlay_transform.h" | ||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 14 | #include "ui/gl/gl_export.h" |
15 | |||||
16 | namespace gfx { | ||||
17 | |||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 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: | ||||
reveman | c0c002b | 2014-09-29 21:46:23 | [diff] [blame] | 22 | GLImage() {} |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 23 | |
24 | // Destroys the image. | ||||
[email protected] | d2eaf52f | 2014-07-31 15:01:24 | [diff] [blame] | 25 | virtual void Destroy(bool have_context) = 0; |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 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 | |
reveman | ce8fbe8 | 2014-09-05 02:19:52 | [diff] [blame] | 36 | // Copy image to texture currently bound to |target|. |
37 | virtual bool CopyTexImage(unsigned target) = 0; | ||||
38 | |||||
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 39 | // Called before the texture is used for drawing. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 40 | virtual void WillUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 41 | |
42 | // Called after the texture has been used for drawing. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 43 | virtual void DidUseTexImage() = 0; |
[email protected] | 91c94eb | 2013-10-22 10:32:54 | [diff] [blame] | 44 | |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 45 | // Called before the texture image data will be modified. |
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 46 | virtual void WillModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 47 | |
48 | // Called after the texture image data has been modified. | ||||
[email protected] | 463c12b | 2014-03-15 00:25:49 | [diff] [blame] | 49 | virtual void DidModifyTexImage() = 0; |
[email protected] | 00c2cf9 | 2014-03-14 00:08:37 | [diff] [blame] | 50 | |
[email protected] | 5e57db7 | 2014-08-01 21:50:17 | [diff] [blame] | 51 | // Schedule image as an overlay plane to be shown at swap time for |widget|. |
52 | virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | ||||
53 | int z_order, | ||||
54 | OverlayTransform transform, | ||||
55 | const Rect& bounds_rect, | ||||
56 | const RectF& crop_rect) = 0; | ||||
57 | |||||
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 58 | protected: |
reveman | c0c002b | 2014-09-29 21:46:23 | [diff] [blame] | 59 | virtual ~GLImage() {} |
[email protected] | 09d5036 | 2012-10-18 20:54:37 | [diff] [blame] | 60 | |
61 | private: | ||||
62 | friend class base::RefCounted<GLImage>; | ||||
63 | |||||
64 | DISALLOW_COPY_AND_ASSIGN(GLImage); | ||||
65 | }; | ||||
66 | |||||
67 | } // namespace gfx | ||||
68 | |||||
69 | #endif // UI_GL_GL_IMAGE_H_ |