Move VISUAL_STATE promise to activation
[chromium-blink-merge.git] / ui / ozone / demo / surfaceless_gl_renderer.h
blobb6bc877922871c927e396efe3cf8f5d67083d3a8
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_OZONE_DEMO_SURFACELESS_GL_RENDERER_H_
6 #define UI_OZONE_DEMO_SURFACELESS_GL_RENDERER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "ui/ozone/demo/gl_renderer.h"
11 namespace gfx {
12 class GLImage;
13 } // namespace gfx
15 namespace ui {
17 class GpuMemoryBufferFactoryOzoneNativeBuffer;
19 class SurfacelessGlRenderer : public GlRenderer {
20 public:
21 SurfacelessGlRenderer(
22 gfx::AcceleratedWidget widget,
23 const gfx::Size& size,
24 GpuMemoryBufferFactoryOzoneNativeBuffer* buffer_factory);
25 ~SurfacelessGlRenderer() override;
27 // Renderer:
28 bool Initialize() override;
29 void RenderFrame() override;
31 private:
32 // Called by swap buffers when the actual swap finished.
33 void OnSwapBuffersAck();
35 // GlRenderer:
36 scoped_refptr<gfx::GLSurface> CreateSurface() override;
38 class BufferWrapper {
39 public:
40 BufferWrapper();
41 ~BufferWrapper();
43 bool Initialize(GpuMemoryBufferFactoryOzoneNativeBuffer* buffer_factory,
44 gfx::AcceleratedWidget widget,
45 const gfx::Size& size);
46 void BindFramebuffer();
47 void SchedulePlane();
49 private:
50 gfx::AcceleratedWidget widget_;
51 gfx::Size size_;
53 scoped_refptr<gfx::GLImage> image_;
54 unsigned int gl_fb_;
55 unsigned int gl_tex_;
58 GpuMemoryBufferFactoryOzoneNativeBuffer* buffer_factory_;
60 BufferWrapper buffers_[2];
61 int back_buffer_;
62 bool is_swapping_buffers_;
64 base::WeakPtrFactory<SurfacelessGlRenderer> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(SurfacelessGlRenderer);
69 } // namespace ui
71 #endif // UI_OZONE_DEMO_SURFACELESS_GL_RENDERER_H_