Chromium Code Reviews| 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 ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_ | 5 #ifndef BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_ | 6 #define BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
| 13 #include "gpu/command_buffer/service/in_process_command_buffer.h" | 13 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 14 #include "skia/ext/refptr.h" | 14 #include "skia/ext/refptr.h" |
| 15 #include "ui/gl/gl_surface.h" | |
| 16 #include "ui/gl/gl_surface.h" | |
| 15 | 17 |
| 16 namespace gfx { | 18 namespace blimp { |
| 17 class GLSurface; | |
| 18 } | |
| 19 | 19 |
| 20 namespace gpu { | 20 // Helper class to provide a graphics context for the compositor. |
| 21 class GLInProcessContext; | 21 class BlimpContextProvider : public cc::ContextProvider { |
| 22 } | 22 public: |
| 23 static scoped_refptr<BlimpContextProvider> Create( | |
|
Wez
2015/08/27 02:01:52
n00b: cc::ContextProvider is ref-counted? *sob*
David Trainor- moved to gerrit
2015/08/28 01:23:47
:'(
| |
| 24 gfx::AcceleratedWidget widget); | |
| 23 | 25 |
| 24 namespace android_webview { | 26 void OnLostContext(); |
| 25 | 27 |
| 26 class AwRenderThreadContextProvider : public cc::ContextProvider { | 28 // cc::ContextProvider ------------------------------------------------------- |
| 27 public: | |
| 28 static scoped_refptr<AwRenderThreadContextProvider> Create( | |
| 29 scoped_refptr<gfx::GLSurface> surface, | |
| 30 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); | |
| 31 | |
| 32 private: | |
| 33 AwRenderThreadContextProvider( | |
| 34 scoped_refptr<gfx::GLSurface> surface, | |
| 35 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); | |
| 36 ~AwRenderThreadContextProvider() override; | |
| 37 | |
| 38 // cc::ContextProvider: | |
| 39 bool BindToCurrentThread() override; | 29 bool BindToCurrentThread() override; |
| 30 void DetachFromThread() override; | |
| 40 Capabilities ContextCapabilities() override; | 31 Capabilities ContextCapabilities() override; |
| 41 gpu::gles2::GLES2Interface* ContextGL() override; | 32 gpu::gles2::GLES2Interface* ContextGL() override; |
| 42 gpu::ContextSupport* ContextSupport() override; | 33 gpu::ContextSupport* ContextSupport() override; |
| 43 class GrContext* GrContext() override; | 34 class GrContext* GrContext() override; |
| 44 void InvalidateGrContext(uint32_t state) override; | 35 void InvalidateGrContext(uint32_t state) override; |
| 45 void SetupLock() override; | 36 void SetupLock() override; |
| 46 base::Lock* GetLock() override; | 37 base::Lock* GetLock() override; |
| 47 void VerifyContexts() override; | 38 void VerifyContexts() override; |
| 48 void DeleteCachedResources() override; | 39 void DeleteCachedResources() override; |
| 49 bool DestroyedOnMainThread() override; | 40 bool DestroyedOnMainThread() override; |
| 50 void SetLostContextCallback( | 41 void SetLostContextCallback( |
| 51 const LostContextCallback& lost_context_callback) override; | 42 const LostContextCallback& lost_context_callback) override; |
| 52 void SetMemoryPolicyChangedCallback( | 43 void SetMemoryPolicyChangedCallback( |
| 53 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 44 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 54 override; | 45 override; |
| 55 | 46 |
| 56 void OnLostContext(); | 47 protected: |
| 48 explicit BlimpContextProvider(gfx::AcceleratedWidget widget); | |
| 49 ~BlimpContextProvider() override; | |
| 57 | 50 |
| 51 private: | |
| 58 base::ThreadChecker main_thread_checker_; | 52 base::ThreadChecker main_thread_checker_; |
| 53 base::ThreadChecker context_thread_checker_; | |
| 59 | 54 |
| 60 scoped_ptr<gpu::GLInProcessContext> context_; | 55 scoped_ptr<gpu::GLInProcessContext> context_; |
| 61 skia::RefPtr<class GrContext> gr_context_; | 56 skia::RefPtr<class GrContext> gr_context_; |
| 62 | 57 |
| 63 cc::ContextProvider::Capabilities capabilities_; | 58 cc::ContextProvider::Capabilities capabilities_; |
| 64 | 59 |
| 65 LostContextCallback lost_context_callback_; | 60 LostContextCallback lost_context_callback_; |
| 66 | 61 |
| 62 base::Lock destroyed_lock_; | |
| 67 bool destroyed_; | 63 bool destroyed_; |
| 68 | 64 |
| 69 base::Lock context_lock_; | 65 base::Lock context_lock_; |
| 70 | 66 |
| 71 DISALLOW_COPY_AND_ASSIGN(AwRenderThreadContextProvider); | 67 DISALLOW_COPY_AND_ASSIGN(BlimpContextProvider); |
| 72 }; | 68 }; |
| 73 | 69 |
| 74 } // namespace android_webview | 70 } // namespace blimp |
| 75 | 71 |
| 76 #endif // ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_ | 72 #endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_ |
| OLD | NEW |