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/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/rect_f.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/overlay_transform.h"
15 #include "ui/gl/gl_export.h"
18 namespace trace_event
{
19 class ProcessMemoryDump
;
25 // Encapsulates an image that can be bound to a texture, hiding platform
26 // specific management.
27 class GL_EXPORT GLImage
: public base::RefCounted
<GLImage
> {
31 // Destroys the image.
32 virtual void Destroy(bool have_context
) = 0;
34 // Get the size of the image.
35 virtual gfx::Size
GetSize() = 0;
37 // Get the internal format of the image.
38 virtual unsigned GetInternalFormat() = 0;
40 // Bind image to texture currently bound to |target|.
41 virtual bool BindTexImage(unsigned target
) = 0;
43 // Release image from texture currently bound to |target|.
44 virtual void ReleaseTexImage(unsigned target
) = 0;
46 // Copy |rect| of image to |offset| in texture currently bound to |target|.
47 virtual bool CopyTexSubImage(unsigned target
,
49 const Rect
& rect
) = 0;
51 // Called before the texture is used for drawing.
52 virtual void WillUseTexImage() = 0;
54 // Called after the texture has been used for drawing.
55 virtual void DidUseTexImage() = 0;
57 // Called before the texture image data will be modified.
58 virtual void WillModifyTexImage() = 0;
60 // Called after the texture image data has been modified.
61 virtual void DidModifyTexImage() = 0;
63 // Schedule image as an overlay plane to be shown at swap time for |widget|.
64 virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget
,
66 OverlayTransform transform
,
67 const Rect
& bounds_rect
,
68 const RectF
& crop_rect
) = 0;
70 // Dumps information about the memory backing the GLImage to a dump named
72 virtual void OnMemoryDump(base::trace_event::ProcessMemoryDump
* pmd
,
73 uint64_t process_tracing_id
,
74 const std::string
& dump_name
) = 0;
80 friend class base::RefCounted
<GLImage
>;
82 DISALLOW_COPY_AND_ASSIGN(GLImage
);
87 #endif // UI_GL_GL_IMAGE_H_