| OLD | NEW |
| 1 // Copyright (c) 2013 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 WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_CONTEXT_PROVIDER_IN_PROCESS_H_ |
| 6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_CONTEXT_PROVIDER_IN_PROCESS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
| 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | |
| 16 #include "skia/ext/refptr.h" | 15 #include "skia/ext/refptr.h" |
| 17 #include "ui/gfx/native_widget_types.h" | |
| 18 | 16 |
| 19 namespace gpu { | 17 namespace gpu { |
| 20 class GLInProcessContext; | 18 class GLInProcessContext; |
| 21 } | 19 } |
| 22 | 20 |
| 23 namespace ui { | 21 namespace android_webview { |
| 24 | 22 |
| 25 class InProcessContextProvider : public cc::ContextProvider { | 23 class ContextProviderInProcess : public cc::ContextProvider { |
| 26 public: | 24 public: |
| 27 static scoped_refptr<InProcessContextProvider> Create( | 25 static scoped_refptr<ContextProviderInProcess> Create( |
| 28 const gpu::gles2::ContextCreationAttribHelper& attribs, | |
| 29 bool lose_context_when_out_of_memory, | |
| 30 gfx::AcceleratedWidget window, | |
| 31 const std::string& debug_name); | 26 const std::string& debug_name); |
| 32 | 27 |
| 33 // Uses default attributes for creating an offscreen context. | |
| 34 static scoped_refptr<InProcessContextProvider> CreateOffscreen( | |
| 35 bool lose_context_when_out_of_memory); | |
| 36 | |
| 37 private: | 28 private: |
| 38 InProcessContextProvider( | 29 ContextProviderInProcess(const std::string& debug_name); |
| 39 const gpu::gles2::ContextCreationAttribHelper& attribs, | 30 ~ContextProviderInProcess() override; |
| 40 bool lose_context_when_out_of_memory, | |
| 41 gfx::AcceleratedWidget window, | |
| 42 const std::string& debug_name); | |
| 43 ~InProcessContextProvider() override; | |
| 44 | 31 |
| 45 // cc::ContextProvider: | 32 // cc::ContextProvider: |
| 46 bool BindToCurrentThread() override; | 33 bool BindToCurrentThread() override; |
| 47 Capabilities ContextCapabilities() override; | 34 Capabilities ContextCapabilities() override; |
| 48 gpu::gles2::GLES2Interface* ContextGL() override; | 35 gpu::gles2::GLES2Interface* ContextGL() override; |
| 49 gpu::ContextSupport* ContextSupport() override; | 36 gpu::ContextSupport* ContextSupport() override; |
| 50 class GrContext* GrContext() override; | 37 class GrContext* GrContext() override; |
| 51 void SetupLock() override; | 38 void SetupLock() override; |
| 52 base::Lock* GetLock() override; | 39 base::Lock* GetLock() override; |
| 53 bool IsContextLost() override; | 40 bool IsContextLost() override; |
| 54 void VerifyContexts() override; | 41 void VerifyContexts() override; |
| 55 void DeleteCachedResources() override; | 42 void DeleteCachedResources() override; |
| 56 bool DestroyedOnMainThread() override; | 43 bool DestroyedOnMainThread() override; |
| 57 void SetLostContextCallback( | 44 void SetLostContextCallback( |
| 58 const LostContextCallback& lost_context_callback) override; | 45 const LostContextCallback& lost_context_callback) override; |
| 59 void SetMemoryPolicyChangedCallback( | 46 void SetMemoryPolicyChangedCallback( |
| 60 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 47 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 61 override; | 48 override; |
| 62 | 49 |
| 63 void OnLostContext(); | 50 void OnLostContext(); |
| 64 | 51 |
| 65 base::ThreadChecker main_thread_checker_; | 52 base::ThreadChecker main_thread_checker_; |
| 66 base::ThreadChecker context_thread_checker_; | 53 base::ThreadChecker context_thread_checker_; |
| 67 | 54 |
| 68 scoped_ptr<gpu::GLInProcessContext> context_; | 55 scoped_ptr<gpu::GLInProcessContext> context_; |
| 69 skia::RefPtr<class GrContext> gr_context_; | 56 skia::RefPtr<class GrContext> gr_context_; |
| 70 | 57 |
| 71 gpu::gles2::ContextCreationAttribHelper attribs_; | |
| 72 bool lose_context_when_out_of_memory_; | |
| 73 gfx::AcceleratedWidget window_; | |
| 74 std::string debug_name_; | 58 std::string debug_name_; |
| 75 cc::ContextProvider::Capabilities capabilities_; | 59 cc::ContextProvider::Capabilities capabilities_; |
| 76 | 60 |
| 77 LostContextCallback lost_context_callback_; | 61 LostContextCallback lost_context_callback_; |
| 78 | 62 |
| 79 base::Lock destroyed_lock_; | 63 base::Lock destroyed_lock_; |
| 80 bool destroyed_; | 64 bool destroyed_; |
| 81 | 65 |
| 82 base::Lock context_lock_; | 66 base::Lock context_lock_; |
| 83 | 67 |
| 84 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider); | 68 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); |
| 85 }; | 69 }; |
| 86 | 70 |
| 87 } // namespace ui | 71 } // namespace android_webview |
| 88 | 72 |
| 89 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 73 #endif // ANDROID_WEBVIEW_BROWSER_CONTEXT_PROVIDER_IN_PROCESS_H_ |
| OLD | NEW |