Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / gl / gl_image_memory.h
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
3 // found in the LICENSE file.
4
5 #ifndef UI_GL_GL_IMAGE_MEMORY_H_
6 #define UI_GL_GL_IMAGE_MEMORY_H_
7
8 #include "ui/gl/gl_image.h"
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
16 namespace gfx {
17
18 class GL_EXPORT GLImageMemory : public GLImage {
19  public:
20   GLImageMemory(const gfx::Size& size, unsigned internalformat);
21
22   bool Initialize(const unsigned char* memory);
23
24   // Overridden from GLImage:
25   virtual void Destroy(bool have_context) OVERRIDE;
26   virtual gfx::Size GetSize() OVERRIDE;
27   virtual bool BindTexImage(unsigned target) OVERRIDE;
28   virtual void ReleaseTexImage(unsigned target) OVERRIDE {}
29   virtual void WillUseTexImage() OVERRIDE {}
30   virtual void DidUseTexImage() OVERRIDE {}
31   virtual void WillModifyTexImage() OVERRIDE {}
32   virtual void DidModifyTexImage() OVERRIDE {}
33   virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
34                                     int z_order,
35                                     OverlayTransform transform,
36                                     const Rect& bounds_rect,
37                                     const RectF& crop_rect) OVERRIDE;
38
39  protected:
40   virtual ~GLImageMemory();
41
42   bool HasValidFormat() const;
43   size_t Bytes() const;
44
45  private:
46   const unsigned char* memory_;
47   const gfx::Size size_;
48   const unsigned internalformat_;
49 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
50     defined(USE_OZONE)
51   unsigned egl_texture_id_;
52   EGLImageKHR egl_image_;
53 #endif
54
55   DISALLOW_COPY_AND_ASSIGN(GLImageMemory);
56 };
57
58 }  // namespace gfx
59
60 #endif  // UI_GL_GL_IMAGE_MEMORY_H_