OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #ifndef SERVICES_GFX_COMPOSITOR_BACKEND_GPU_RASTERIZER_H_ |
| 6 #define SERVICES_GFX_COMPOSITOR_BACKEND_GPU_RASTERIZER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/task_runner.h" |
| 15 #include "mojo/gpu/gl_context.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "mojo/public/cpp/system/functions.h" |
| 18 #include "mojo/services/gpu/interfaces/context_provider.mojom.h" |
| 19 #include "mojo/skia/ganesh_context.h" |
| 20 #include "mojo/skia/ganesh_framebuffer_surface.h" |
| 21 |
| 22 namespace compositor { |
| 23 |
| 24 class RenderFrame; |
| 25 class VsyncScheduler; |
| 26 |
| 27 // Ganesh-based rasterizer which runs on a separate thread from the compositor. |
| 28 // Calls into this object, including its creation, must be posted to the |
| 29 // correct message loop by the output. |
| 30 class GpuRasterizer : public mojo::ViewportParameterListener, |
| 31 public mojo::GLContext::Observer { |
| 32 public: |
| 33 GpuRasterizer(mojo::ContextProviderPtr context_provider, |
| 34 const std::shared_ptr<VsyncScheduler>& scheduler, |
| 35 const scoped_refptr<base::TaskRunner>& task_runner, |
| 36 const base::Closure& error_callback); |
| 37 ~GpuRasterizer() override; |
| 38 |
| 39 void SubmitFrame(const std::shared_ptr<RenderFrame>& frame); |
| 40 |
| 41 private: |
| 42 // |ViewportParameterListener|: |
| 43 void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; |
| 44 |
| 45 // |GLContext::Observer|: |
| 46 void OnContextLost() override; |
| 47 |
| 48 void CreateContext(); |
| 49 void InitContext(mojo::CommandBufferPtr command_buffer); |
| 50 void DestroyContext(); |
| 51 void OnContextProviderConnectionError(); |
| 52 |
| 53 void Draw(); |
| 54 |
| 55 void PostErrorCallback(); |
| 56 |
| 57 mojo::ContextProviderPtr context_provider_; |
| 58 std::shared_ptr<VsyncScheduler> scheduler_; |
| 59 scoped_refptr<base::TaskRunner> task_runner_; |
| 60 base::Closure error_callback_; |
| 61 |
| 62 base::WeakPtr<mojo::GLContext> gl_context_; |
| 63 std::unique_ptr<mojo::skia::GaneshContext> ganesh_context_; |
| 64 std::unique_ptr<mojo::skia::GaneshFramebufferSurface> ganesh_surface_; |
| 65 |
| 66 std::shared_ptr<RenderFrame> current_frame_; |
| 67 |
| 68 mojo::Binding<ViewportParameterListener> viewport_parameter_listener_binding_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(GpuRasterizer); |
| 71 }; |
| 72 |
| 73 } // namespace compositor |
| 74 |
| 75 #endif // SERVICES_GFX_COMPOSITOR_BACKEND_GPU_RASTERIZER_H_ |
OLD | NEW |