OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GL_GL_IMAGE_H_ | 5 #ifndef UI_GL_GL_IMAGE_H_ |
6 #define UI_GL_GL_IMAGE_H_ | 6 #define UI_GL_GL_IMAGE_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
10 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
11 #include "ui/gfx/geometry/rect_f.h" | 13 #include "ui/gfx/geometry/rect_f.h" |
12 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
13 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gfx/overlay_transform.h" | 16 #include "ui/gfx/overlay_transform.h" |
15 #include "ui/gl/gl_export.h" | 17 #include "ui/gl/gl_export.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 namespace trace_event { | 20 namespace trace_event { |
19 class ProcessMemoryDump; | 21 class ProcessMemoryDump; |
20 } | 22 } |
21 } | 23 } |
22 | 24 |
23 namespace gfx { | 25 namespace gfx { |
24 | 26 |
25 // Encapsulates an image that can be bound to a texture, hiding platform | 27 // Encapsulates an image that can be bound and/or copied to a texture, hiding |
26 // specific management. | 28 // platform specific management. |
27 class GL_EXPORT GLImage : public base::RefCounted<GLImage> { | 29 class GL_EXPORT GLImage : public base::RefCounted<GLImage> { |
28 public: | 30 public: |
29 GLImage() {} | 31 GLImage() {} |
30 | 32 |
31 // Destroys the image. | 33 // Destroys the image. |
32 virtual void Destroy(bool have_context) = 0; | 34 virtual void Destroy(bool have_context) = 0; |
33 | 35 |
34 // Get the size of the image. | 36 // Get the size of the image. |
35 virtual gfx::Size GetSize() = 0; | 37 virtual Size GetSize() = 0; |
36 | 38 |
37 // Get the internal format of the image. | 39 // Get the internal format of the image. |
38 virtual unsigned GetInternalFormat() = 0; | 40 virtual unsigned GetInternalFormat() = 0; |
39 | 41 |
40 // Bind image to texture currently bound to |target|. | 42 // Bind image to texture currently bound to |target|. Returns true on success. |
| 43 // It is valid for an implementation to always return false. |
41 virtual bool BindTexImage(unsigned target) = 0; | 44 virtual bool BindTexImage(unsigned target) = 0; |
42 | 45 |
43 // Release image from texture currently bound to |target|. | 46 // Release image from texture currently bound to |target|. |
44 virtual void ReleaseTexImage(unsigned target) = 0; | 47 virtual void ReleaseTexImage(unsigned target) = 0; |
45 | 48 |
| 49 // Define texture currently bound to |target| by copying image into it. |
| 50 // Returns true on success. It is valid for an implementation to always |
| 51 // return false. |
| 52 virtual bool CopyTexImage(unsigned target) = 0; |
| 53 |
46 // Copy |rect| of image to |offset| in texture currently bound to |target|. | 54 // Copy |rect| of image to |offset| in texture currently bound to |target|. |
| 55 // Returns true on success. It is valid for an implementation to always |
| 56 // return false. |
47 virtual bool CopyTexSubImage(unsigned target, | 57 virtual bool CopyTexSubImage(unsigned target, |
48 const Point& offset, | 58 const Point& offset, |
49 const Rect& rect) = 0; | 59 const Rect& rect) = 0; |
50 | 60 |
51 // Called before the texture is used for drawing. | |
52 virtual void WillUseTexImage() = 0; | |
53 | |
54 // Called after the texture has been used for drawing. | |
55 virtual void DidUseTexImage() = 0; | |
56 | |
57 // Called before the texture image data will be modified. | |
58 virtual void WillModifyTexImage() = 0; | |
59 | |
60 // Called after the texture image data has been modified. | |
61 virtual void DidModifyTexImage() = 0; | |
62 | |
63 // Schedule image as an overlay plane to be shown at swap time for |widget|. | 61 // Schedule image as an overlay plane to be shown at swap time for |widget|. |
64 virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 62 virtual bool ScheduleOverlayPlane(AcceleratedWidget widget, |
65 int z_order, | 63 int z_order, |
66 OverlayTransform transform, | 64 OverlayTransform transform, |
67 const Rect& bounds_rect, | 65 const Rect& bounds_rect, |
68 const RectF& crop_rect) = 0; | 66 const RectF& crop_rect) = 0; |
69 | 67 |
70 // Dumps information about the memory backing the GLImage to a dump named | 68 // Dumps information about the memory backing the GLImage to a dump named |
71 // |dump_name|. | 69 // |dump_name|. |
72 virtual void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 70 virtual void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
73 uint64_t process_tracing_id, | 71 uint64_t process_tracing_id, |
74 const std::string& dump_name) = 0; | 72 const std::string& dump_name) = 0; |
75 | 73 |
76 protected: | 74 protected: |
77 virtual ~GLImage() {} | 75 virtual ~GLImage() {} |
78 | 76 |
79 private: | 77 private: |
80 friend class base::RefCounted<GLImage>; | 78 friend class base::RefCounted<GLImage>; |
81 | 79 |
82 DISALLOW_COPY_AND_ASSIGN(GLImage); | 80 DISALLOW_COPY_AND_ASSIGN(GLImage); |
83 }; | 81 }; |
84 | 82 |
85 } // namespace gfx | 83 } // namespace gfx |
86 | 84 |
87 #endif // UI_GL_GL_IMAGE_H_ | 85 #endif // UI_GL_GL_IMAGE_H_ |
OLD | NEW |