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