1 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GPU_MEMORY_BUFFER_IMAGE_COPY_H_
2 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GPU_MEMORY_BUFFER_IMAGE_COPY_H_
3 
4 #include <memory>
5 #include "gpu/command_buffer/client/gles2_interface.h"
6 #include "third_party/blink/renderer/platform/platform_export.h"
7 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
8 #include "ui/gfx/gpu_memory_buffer.h"
9 
10 namespace blink {
11 
12 class Image;
13 
14 class PLATFORM_EXPORT GpuMemoryBufferImageCopy {
15   USING_FAST_MALLOC(GpuMemoryBufferImageCopy);
16 
17  public:
18   GpuMemoryBufferImageCopy(gpu::gles2::GLES2Interface*);
19   ~GpuMemoryBufferImageCopy();
20 
21   gfx::GpuMemoryBuffer* CopyImage(Image*);
22 
23  private:
24   bool EnsureMemoryBuffer(int width, int height);
25   void OnContextLost();
26   void OnContextError(const char* msg, int32_t id);
27 
28   std::unique_ptr<gfx::GpuMemoryBuffer> m_currentBuffer;
29 
30   int last_width_ = 0;
31   int last_height_ = 0;
32   gpu::gles2::GLES2Interface* gl_;
33   std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
34 
35   // TODO(billorr): Add error handling for context loss or GL errors before we
36   // enable this by default.
37 };
38 
39 }  // namespace blink
40 
41 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GPU_MEMORY_BUFFER_IMAGE_COPY_H_
42