base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / ui / gl / gl_image_memory.h
blobfd659e76e58b221b91dcddff360ae6fe8a377723
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.
5 #ifndef UI_GL_GL_IMAGE_MEMORY_H_
6 #define UI_GL_GL_IMAGE_MEMORY_H_
8 #include "ui/gl/gl_image.h"
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
16 #include "ui/gfx/gpu_memory_buffer.h"
18 namespace gfx {
20 class GL_EXPORT GLImageMemory : public GLImage {
21 public:
22 GLImageMemory(const gfx::Size& size, unsigned internalformat);
24 static size_t BytesPerPixel(gfx::GpuMemoryBuffer::Format format);
26 bool Initialize(const unsigned char* memory,
27 gfx::GpuMemoryBuffer::Format format);
29 // Overridden from GLImage:
30 void Destroy(bool have_context) override;
31 gfx::Size GetSize() override;
32 bool BindTexImage(unsigned target) override;
33 void ReleaseTexImage(unsigned target) override {}
34 bool CopyTexImage(unsigned target) override;
35 void WillUseTexImage() override;
36 void DidUseTexImage() override;
37 void WillModifyTexImage() override {}
38 void DidModifyTexImage() override {}
39 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
40 int z_order,
41 OverlayTransform transform,
42 const Rect& bounds_rect,
43 const RectF& crop_rect) override;
45 protected:
46 ~GLImageMemory() override;
48 private:
49 void DoBindTexImage(unsigned target);
51 const gfx::Size size_;
52 const unsigned internalformat_;
53 const unsigned char* memory_;
54 gfx::GpuMemoryBuffer::Format format_;
55 bool in_use_;
56 unsigned target_;
57 bool need_do_bind_tex_image_;
58 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
59 defined(USE_OZONE)
60 unsigned egl_texture_id_;
61 EGLImageKHR egl_image_;
62 #endif
64 DISALLOW_COPY_AND_ASSIGN(GLImageMemory);
67 } // namespace gfx
69 #endif // UI_GL_GL_IMAGE_MEMORY_H_