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) || \
13 #include <EGL/eglext.h>
16 #include "ui/gfx/gpu_memory_buffer.h"
20 class GL_EXPORT GLImageMemory
: public GLImage
{
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
,
41 OverlayTransform transform
,
42 const Rect
& bounds_rect
,
43 const RectF
& crop_rect
) override
;
46 ~GLImageMemory() override
;
49 void DoBindTexImage(unsigned target
);
51 const gfx::Size size_
;
52 const unsigned internalformat_
;
53 const unsigned char* memory_
;
54 gfx::GpuMemoryBuffer::Format format_
;
57 bool need_do_bind_tex_image_
;
58 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
60 unsigned egl_texture_id_
;
61 EGLImageKHR egl_image_
;
64 DISALLOW_COPY_AND_ASSIGN(GLImageMemory
);
69 #endif // UI_GL_GL_IMAGE_MEMORY_H_