James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [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" |
Nick Bray | 27a3f6e | 2015-01-08 16:39:35 -0800 | [diff] [blame] | 9 | #include "ui/gfx/geometry/rect.h" |
| 10 | #include "ui/gfx/geometry/rect_f.h" |
| 11 | #include "ui/gfx/geometry/size.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 12 | #include "ui/gfx/native_widget_types.h" |
| 13 | #include "ui/gfx/overlay_transform.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 14 | #include "ui/gl/gl_export.h" |
| 15 | |
| 16 | namespace gfx { |
| 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(bool have_context) = 0; |
| 26 | |
| 27 | // Get the size of the image. |
| 28 | virtual gfx::Size GetSize() = 0; |
| 29 | |
| 30 | // Bind image to texture currently bound to |target|. |
| 31 | virtual bool BindTexImage(unsigned target) = 0; |
| 32 | |
| 33 | // Release image from texture currently bound to |target|. |
| 34 | virtual void ReleaseTexImage(unsigned target) = 0; |
| 35 | |
| 36 | // Copy image to texture currently bound to |target|. |
| 37 | virtual bool CopyTexImage(unsigned target) = 0; |
| 38 | |
| 39 | // Called before the texture is used for drawing. |
| 40 | virtual void WillUseTexImage() = 0; |
| 41 | |
| 42 | // Called after the texture has been used for drawing. |
| 43 | virtual void DidUseTexImage() = 0; |
| 44 | |
| 45 | // Called before the texture image data will be modified. |
| 46 | virtual void WillModifyTexImage() = 0; |
| 47 | |
| 48 | // Called after the texture image data has been modified. |
| 49 | virtual void DidModifyTexImage() = 0; |
| 50 | |
| 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 | |
| 58 | protected: |
| 59 | virtual ~GLImage() {} |
| 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_ |