Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / ozone / demo / surfaceless_gl_renderer.h
blobef90885ec98e8b1797251e5d2cb3d11a7e313d6f
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 "ui/ozone/demo/gl_renderer.h"
10 namespace gfx {
11 class GLImage;
12 } // namespace gfx
14 namespace ui {
16 class SurfacelessGlRenderer : public GlRenderer {
17 public:
18 SurfacelessGlRenderer(gfx::AcceleratedWidget widget,
19 const scoped_refptr<gfx::GLSurface>& surface,
20 const gfx::Size& size);
21 ~SurfacelessGlRenderer() override;
23 // Renderer:
24 bool Initialize() override;
26 private:
27 // GlRenderer:
28 void RenderFrame() override;
29 void PostRenderFrameTask(gfx::SwapResult result) override;
31 class BufferWrapper {
32 public:
33 BufferWrapper();
34 ~BufferWrapper();
36 gfx::GLImage* image() const { return image_.get(); }
38 bool Initialize(gfx::AcceleratedWidget widget, const gfx::Size& size);
39 void BindFramebuffer();
41 private:
42 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
43 gfx::Size size_;
45 scoped_refptr<gfx::GLImage> image_;
46 unsigned int gl_fb_ = 0;
47 unsigned int gl_tex_ = 0;
50 scoped_ptr<BufferWrapper> buffers_[2];
51 int back_buffer_ = 0;
53 base::WeakPtrFactory<SurfacelessGlRenderer> weak_ptr_factory_;
55 DISALLOW_COPY_AND_ASSIGN(SurfacelessGlRenderer);
58 } // namespace ui
60 #endif // UI_OZONE_DEMO_SURFACELESS_GL_RENDERER_H_