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