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.
5 #ifndef UI_GL_GL_IMAGE_H_
6 #define UI_GL_GL_IMAGE_H_
8 #include "base/memory/ref_counted.h"
9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/overlay_transform.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/rect_f.h"
13 #include "ui/gfx/size.h"
14 #include "ui/gl/gl_export.h"
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
> {
24 // Destroys the image.
25 virtual void Destroy(bool have_context
) = 0;
27 // Get the size of the image.
28 virtual gfx::Size
GetSize() = 0;
30 // Bind image to texture currently bound to |target|.
31 virtual bool BindTexImage(unsigned target
) = 0;
33 // Release image from texture currently bound to |target|.
34 virtual void ReleaseTexImage(unsigned target
) = 0;
36 // Called before the texture is used for drawing.
37 virtual void WillUseTexImage() = 0;
39 // Called after the texture has been used for drawing.
40 virtual void DidUseTexImage() = 0;
42 // Called before the texture image data will be modified.
43 virtual void WillModifyTexImage() = 0;
45 // Called after the texture image data has been modified.
46 virtual void DidModifyTexImage() = 0;
48 // Schedule image as an overlay plane to be shown at swap time for |widget|.
49 virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget
,
51 OverlayTransform transform
,
52 const Rect
& bounds_rect
,
53 const RectF
& crop_rect
) = 0;
55 // Indicate that image should be released after use.
56 // (For an Android work-around only).
57 virtual void SetReleaseAfterUse();
63 friend class base::RefCounted
<GLImage
>;
65 DISALLOW_COPY_AND_ASSIGN(GLImage
);
70 #endif // UI_GL_GL_IMAGE_H_