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