| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
| 6 #define SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "cc/output/context_provider.h" | |
| 16 #include "ui/gfx/native_widget_types.h" | |
| 17 #include "ui/gl/gl_surface.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class SingleThreadTaskRunner; | |
| 21 } | |
| 22 | |
| 23 namespace gpu { | |
| 24 | |
| 25 class CommandBufferProxyImpl; | |
| 26 class GpuChannelHost; | |
| 27 struct GpuProcessHostedCALayerTreeParamsMac; | |
| 28 class TransferBuffer; | |
| 29 | |
| 30 namespace gles2 { | |
| 31 class GLES2CmdHelper; | |
| 32 class GLES2Implementation; | |
| 33 } | |
| 34 | |
| 35 } // namespace gpu | |
| 36 | |
| 37 namespace ui { | |
| 38 class LatencyInfo; | |
| 39 } | |
| 40 | |
| 41 namespace ui { | |
| 42 | |
| 43 class CommandBufferDriver; | |
| 44 class CommandBufferImpl; | |
| 45 class SurfacesContextProviderDelegate; | |
| 46 | |
| 47 // TODO(fsamuel): This can probably be merged with ContextProviderCommandBuffer. | |
| 48 class SurfacesContextProvider : public cc::ContextProvider, | |
| 49 public base::NonThreadSafe { | |
| 50 public: | |
| 51 SurfacesContextProvider(gfx::AcceleratedWidget widget, | |
| 52 scoped_refptr<gpu::GpuChannelHost> gpu_channel); | |
| 53 | |
| 54 void SetDelegate(SurfacesContextProviderDelegate* delegate); | |
| 55 | |
| 56 // cc::ContextProvider implementation. | |
| 57 bool BindToCurrentThread() override; | |
| 58 gpu::gles2::GLES2Interface* ContextGL() override; | |
| 59 gpu::ContextSupport* ContextSupport() override; | |
| 60 class GrContext* GrContext() override; | |
| 61 cc::ContextCacheController* CacheController() override; | |
| 62 void InvalidateGrContext(uint32_t state) override; | |
| 63 gpu::Capabilities ContextCapabilities() override; | |
| 64 void SetLostContextCallback( | |
| 65 const LostContextCallback& lost_context_callback) override; | |
| 66 base::Lock* GetLock() override; | |
| 67 | |
| 68 // SurfacesContextProvider API. | |
| 69 void SetSwapBuffersCompletionCallback( | |
| 70 gl::GLSurface::SwapCompletionCallback callback); | |
| 71 | |
| 72 protected: | |
| 73 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; | |
| 74 ~SurfacesContextProvider() override; | |
| 75 | |
| 76 private: | |
| 77 // Callbacks for CommandBufferProxyImpl: | |
| 78 void OnGpuSwapBuffersCompleted( | |
| 79 const std::vector<ui::LatencyInfo>& latency_info, | |
| 80 gfx::SwapResult result, | |
| 81 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac); | |
| 82 void OnUpdateVSyncParameters(base::TimeTicks timebase, | |
| 83 base::TimeDelta interval); | |
| 84 | |
| 85 // From GLES2Context: | |
| 86 // Initialized in BindToCurrentThread. | |
| 87 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | |
| 88 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; | |
| 89 std::unique_ptr<gpu::gles2::GLES2Implementation> implementation_; | |
| 90 std::unique_ptr<cc::ContextCacheController> cache_controller_; | |
| 91 | |
| 92 gpu::Capabilities capabilities_; | |
| 93 LostContextCallback lost_context_callback_; | |
| 94 | |
| 95 SurfacesContextProviderDelegate* delegate_; | |
| 96 gfx::AcceleratedWidget widget_; | |
| 97 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_proxy_impl_; | |
| 98 gl::GLSurface::SwapCompletionCallback swap_buffers_completion_callback_; | |
| 99 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); | |
| 102 }; | |
| 103 | |
| 104 } // namespace ui | |
| 105 | |
| 106 #endif // SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
| OLD | NEW |