OLD | NEW |
1 // Copyright 2013 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_SHM_H_ | 5 #ifndef UI_GL_GL_IMAGE_MEMORY_H_ |
6 #define UI_GL_GL_IMAGE_SHM_H_ | 6 #define UI_GL_GL_IMAGE_MEMORY_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "ui/gl/gl_bindings.h" | |
10 #include "ui/gl/gl_image.h" | 8 #include "ui/gl/gl_image.h" |
11 | 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 |
12 namespace gfx { | 16 namespace gfx { |
13 | 17 |
14 class GL_EXPORT GLImageShm : public GLImage { | 18 class GL_EXPORT GLImageMemory : public GLImage { |
15 public: | 19 public: |
16 GLImageShm(gfx::Size size, unsigned internalformat); | 20 GLImageMemory(const gfx::Size& size, unsigned internalformat); |
17 | 21 |
18 bool Initialize(gfx::GpuMemoryBufferHandle buffer); | 22 bool Initialize(const unsigned char* memory); |
19 | 23 |
20 // Overridden from GLImage: | 24 // Overridden from GLImage: |
21 virtual void Destroy() OVERRIDE; | 25 virtual void Destroy() OVERRIDE; |
22 virtual gfx::Size GetSize() OVERRIDE; | 26 virtual gfx::Size GetSize() OVERRIDE; |
23 virtual bool BindTexImage(unsigned target) OVERRIDE; | 27 virtual bool BindTexImage(unsigned target) OVERRIDE; |
24 virtual void ReleaseTexImage(unsigned target) OVERRIDE {} | 28 virtual void ReleaseTexImage(unsigned target) OVERRIDE {} |
25 virtual void WillUseTexImage() OVERRIDE {} | 29 virtual void WillUseTexImage() OVERRIDE {} |
26 virtual void DidUseTexImage() OVERRIDE {} | 30 virtual void DidUseTexImage() OVERRIDE {} |
27 virtual void WillModifyTexImage() OVERRIDE {} | 31 virtual void WillModifyTexImage() OVERRIDE {} |
28 virtual void DidModifyTexImage() OVERRIDE {} | 32 virtual void DidModifyTexImage() OVERRIDE {} |
29 | 33 |
30 protected: | 34 protected: |
31 virtual ~GLImageShm(); | 35 virtual ~GLImageMemory(); |
| 36 |
| 37 bool HasValidFormat() const; |
| 38 size_t Bytes() const; |
32 | 39 |
33 private: | 40 private: |
34 scoped_ptr<base::SharedMemory> shared_memory_; | 41 const unsigned char* memory_; |
35 gfx::Size size_; | 42 const gfx::Size size_; |
36 unsigned internalformat_; | 43 const unsigned internalformat_; |
37 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ | 44 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
38 defined(USE_OZONE) | 45 defined(USE_OZONE) |
39 GLuint egl_texture_id_; | 46 unsigned egl_texture_id_; |
40 EGLImageKHR egl_image_; | 47 EGLImageKHR egl_image_; |
41 #endif | 48 #endif |
42 | 49 |
43 DISALLOW_COPY_AND_ASSIGN(GLImageShm); | 50 DISALLOW_COPY_AND_ASSIGN(GLImageMemory); |
44 }; | 51 }; |
45 | 52 |
46 } // namespace gfx | 53 } // namespace gfx |
47 | 54 |
48 #endif // UI_GL_GL_IMAGE_SHM_H_ | 55 #endif // UI_GL_GL_IMAGE_MEMORY_H_ |
OLD | NEW |