OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MEMORY_H_ | 5 #ifndef UI_GL_GL_IMAGE_MEMORY_H_ |
6 #define UI_GL_GL_IMAGE_MEMORY_H_ | 6 #define UI_GL_GL_IMAGE_MEMORY_H_ |
7 | 7 |
8 #include "ui/gl/gl_image.h" | 8 #include "ui/gl/gl_image.h" |
9 | 9 |
| 10 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
| 11 defined(USE_OZONE) |
| 12 #include <EGL/egl.h> |
| 13 #include <EGL/eglext.h> |
| 14 #endif |
| 15 |
10 #include "base/numerics/safe_math.h" | 16 #include "base/numerics/safe_math.h" |
11 #include "ui/gfx/buffer_types.h" | 17 #include "ui/gfx/gpu_memory_buffer.h" |
12 | 18 |
13 namespace gfx { | 19 namespace gfx { |
14 | 20 |
15 class GL_EXPORT GLImageMemory : public GLImage { | 21 class GL_EXPORT GLImageMemory : public GLImage { |
16 public: | 22 public: |
17 GLImageMemory(const Size& size, unsigned internalformat); | 23 GLImageMemory(const Size& size, unsigned internalformat); |
18 | 24 |
19 static bool StrideInBytes(size_t width, | 25 static bool StrideInBytes(size_t width, |
20 BufferFormat format, | 26 BufferFormat format, |
21 size_t* stride_in_bytes); | 27 size_t* stride_in_bytes); |
22 | 28 |
23 bool Initialize(const unsigned char* memory, BufferFormat format); | 29 bool Initialize(const unsigned char* memory, BufferFormat format); |
24 | 30 |
25 // Overridden from GLImage: | 31 // Overridden from GLImage: |
26 void Destroy(bool have_context) override; | 32 void Destroy(bool have_context) override; |
27 Size GetSize() override; | 33 Size GetSize() override; |
28 unsigned GetInternalFormat() override; | 34 unsigned GetInternalFormat() override; |
29 bool BindTexImage(unsigned target) override; | 35 bool BindTexImage(unsigned target) override; |
30 void ReleaseTexImage(unsigned target) override {} | 36 void ReleaseTexImage(unsigned target) override {} |
31 bool CopyTexImage(unsigned target) override; | |
32 bool CopyTexSubImage(unsigned target, | 37 bool CopyTexSubImage(unsigned target, |
33 const Point& offset, | 38 const Point& offset, |
34 const Rect& rect) override; | 39 const Rect& rect) override; |
| 40 void WillUseTexImage() override; |
| 41 void DidUseTexImage() override; |
| 42 void WillModifyTexImage() override {} |
| 43 void DidModifyTexImage() override {} |
35 bool ScheduleOverlayPlane(AcceleratedWidget widget, | 44 bool ScheduleOverlayPlane(AcceleratedWidget widget, |
36 int z_order, | 45 int z_order, |
37 OverlayTransform transform, | 46 OverlayTransform transform, |
38 const Rect& bounds_rect, | 47 const Rect& bounds_rect, |
39 const RectF& crop_rect) override; | 48 const RectF& crop_rect) override; |
40 | 49 |
| 50 // Only dumps the GLTexture portion of the memory usage. Subclasses are |
| 51 // responsible for dumping the CPU-side memory. |
| 52 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 53 uint64_t process_tracing_id, |
| 54 const std::string& dump_name) override; |
| 55 |
41 protected: | 56 protected: |
42 ~GLImageMemory() override; | 57 ~GLImageMemory() override; |
43 | 58 |
44 BufferFormat format() const { return format_; } | 59 BufferFormat format() const { return format_; } |
45 | 60 |
46 private: | 61 private: |
| 62 void DoBindTexImage(unsigned target); |
| 63 |
47 const Size size_; | 64 const Size size_; |
48 const unsigned internalformat_; | 65 const unsigned internalformat_; |
49 const unsigned char* memory_; | 66 const unsigned char* memory_; |
50 BufferFormat format_; | 67 BufferFormat format_; |
| 68 bool in_use_; |
| 69 unsigned target_; |
| 70 bool need_do_bind_tex_image_; |
| 71 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
| 72 defined(USE_OZONE) |
| 73 unsigned egl_texture_id_; |
| 74 EGLImageKHR egl_image_; |
| 75 #endif |
51 | 76 |
52 DISALLOW_COPY_AND_ASSIGN(GLImageMemory); | 77 DISALLOW_COPY_AND_ASSIGN(GLImageMemory); |
53 }; | 78 }; |
54 | 79 |
55 } // namespace gfx | 80 } // namespace gfx |
56 | 81 |
57 #endif // UI_GL_GL_IMAGE_MEMORY_H_ | 82 #endif // UI_GL_GL_IMAGE_MEMORY_H_ |
OLD | NEW |