| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ | 5 #ifndef BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| 6 #define BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ | 6 #define BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "cc/output/context_provider.h" | 15 #include "cc/output/context_provider.h" |
| 16 #include "gpu/ipc/common/surface_handle.h" |
| 16 #include "gpu/ipc/gl_in_process_context.h" | 17 #include "gpu/ipc/gl_in_process_context.h" |
| 17 #include "ui/gl/gl_surface.h" | 18 #include "ui/gl/gl_surface.h" |
| 18 | 19 |
| 19 namespace skia_bindings { | 20 namespace skia_bindings { |
| 20 class GrContextForGLES2Interface; | 21 class GrContextForGLES2Interface; |
| 21 } // namespace skia_bindings | 22 } // namespace skia_bindings |
| 22 | 23 |
| 23 namespace blimp { | 24 namespace blimp { |
| 24 namespace client { | 25 namespace client { |
| 25 | 26 |
| 26 // Helper class to provide a graphics context for the compositor. | 27 // Helper class to provide a graphics context for the compositor. |
| 27 class BlimpContextProvider : public cc::ContextProvider { | 28 class BlimpContextProvider : public cc::ContextProvider { |
| 28 public: | 29 public: |
| 29 static scoped_refptr<BlimpContextProvider> Create( | 30 static scoped_refptr<BlimpContextProvider> Create( |
| 30 gfx::AcceleratedWidget widget, | 31 gpu::SurfaceHandle widget, |
| 31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
| 32 | 33 |
| 33 // cc::ContextProvider implementation. | 34 // cc::ContextProvider implementation. |
| 34 bool BindToCurrentThread() override; | 35 bool BindToCurrentThread() override; |
| 35 void DetachFromThread() override; | 36 void DetachFromThread() override; |
| 36 gpu::Capabilities ContextCapabilities() override; | 37 gpu::Capabilities ContextCapabilities() override; |
| 37 gpu::gles2::GLES2Interface* ContextGL() override; | 38 gpu::gles2::GLES2Interface* ContextGL() override; |
| 38 gpu::ContextSupport* ContextSupport() override; | 39 gpu::ContextSupport* ContextSupport() override; |
| 39 class GrContext* GrContext() override; | 40 class GrContext* GrContext() override; |
| 40 cc::ContextCacheController* CacheController() override; | 41 cc::ContextCacheController* CacheController() override; |
| 41 void InvalidateGrContext(uint32_t state) override; | 42 void InvalidateGrContext(uint32_t state) override; |
| 42 base::Lock* GetLock() override; | 43 base::Lock* GetLock() override; |
| 43 void SetLostContextCallback( | 44 void SetLostContextCallback( |
| 44 const LostContextCallback& lost_context_callback) override; | 45 const LostContextCallback& lost_context_callback) override; |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 BlimpContextProvider(gfx::AcceleratedWidget widget, | 48 BlimpContextProvider(gpu::SurfaceHandle widget, |
| 48 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 49 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
| 49 ~BlimpContextProvider() override; | 50 ~BlimpContextProvider() override; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 void OnLostContext(); | 53 void OnLostContext(); |
| 53 | 54 |
| 54 base::ThreadChecker main_thread_checker_; | 55 base::ThreadChecker main_thread_checker_; |
| 55 base::ThreadChecker context_thread_checker_; | 56 base::ThreadChecker context_thread_checker_; |
| 56 | 57 |
| 57 std::unique_ptr<gpu::GLInProcessContext> context_; | 58 std::unique_ptr<gpu::GLInProcessContext> context_; |
| 58 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; | 59 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; |
| 59 std::unique_ptr<cc::ContextCacheController> cache_controller_; | 60 std::unique_ptr<cc::ContextCacheController> cache_controller_; |
| 60 | 61 |
| 61 LostContextCallback lost_context_callback_; | 62 LostContextCallback lost_context_callback_; |
| 62 | 63 |
| 63 base::Lock context_lock_; | 64 base::Lock context_lock_; |
| 64 | 65 |
| 65 DISALLOW_COPY_AND_ASSIGN(BlimpContextProvider); | 66 DISALLOW_COPY_AND_ASSIGN(BlimpContextProvider); |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 } // namespace client | 69 } // namespace client |
| 69 } // namespace blimp | 70 } // namespace blimp |
| 70 | 71 |
| 71 #endif // BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ | 72 #endif // BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| OLD | NEW |