blob: dcb053a648db3a9bbea7dd6b16b11427f885cf49 [file] [log] [blame]
[email protected]d03d7842013-02-28 23:08:171// Copyright (c) 2013 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
[email protected]1fb9e7e2013-05-26 03:23:485#ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
6#define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
[email protected]d03d7842013-02-28 23:08:177
tfarina9c951cf2015-01-16 23:26:538#include <string>
9
10#include "base/macros.h"
[email protected]d03d7842013-02-28 23:08:1711#include "base/memory/scoped_ptr.h"
12#include "base/synchronization/lock.h"
[email protected]6b144232013-07-30 22:27:5513#include "base/threading/thread_checker.h"
tfarinaae8232df2015-02-04 13:10:0214#include "cc/blink/context_provider_web_context.h"
[email protected]1fb9e7e2013-05-26 03:23:4815#include "webkit/common/gpu/webkit_gpu_export.h"
[email protected]d03d7842013-02-28 23:08:1716
[email protected]c32e27082013-11-07 06:58:2017namespace blink { class WebGraphicsContext3D; }
[email protected]59fe2c32013-06-21 10:03:3718
tfarina9c951cf2015-01-16 23:26:5319namespace gpu_blink {
20class WebGraphicsContext3DInProcessCommandBufferImpl;
21}
22
[email protected]d03d7842013-02-28 23:08:1723namespace webkit {
24namespace gpu {
25class GrContextForWebGraphicsContext3D;
26
[email protected]372a3372013-03-13 16:35:0227class WEBKIT_GPU_EXPORT ContextProviderInProcess
tfarinaae8232df2015-02-04 13:10:0228 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) {
[email protected]d03d7842013-02-28 23:08:1729 public:
[email protected]3d6b5122013-08-14 22:25:3430 static scoped_refptr<ContextProviderInProcess> Create(
tfarina70da38b2015-01-09 03:16:1031 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl>
32 context3d,
[email protected]af13d832013-09-13 06:56:2733 const std::string& debug_name);
[email protected]3d6b5122013-08-14 22:25:3434
[email protected]828a3932014-04-02 14:43:1335 // Uses default attributes for creating an offscreen context.
36 static scoped_refptr<ContextProviderInProcess> CreateOffscreen(
37 bool lose_context_when_out_of_memory);
[email protected]d03d7842013-02-28 23:08:1738
tfarina9c951cf2015-01-16 23:26:5339 private:
40 ContextProviderInProcess(
41 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl>
42 context3d,
43 const std::string& debug_name);
44 ~ContextProviderInProcess() override;
45
tfarinaae8232df2015-02-04 13:10:0246 // cc_blink::ContextProviderWebContext:
dcheng5794dbf2014-12-23 00:00:2747 blink::WebGraphicsContext3D* WebContext3D() override;
[email protected]e7e7ebd2014-01-16 00:11:1148
tfarina9c951cf2015-01-16 23:26:5349 // cc::ContextProvider:
dcheng5794dbf2014-12-23 00:00:2750 bool BindToCurrentThread() override;
vmiura78b69282015-02-14 00:01:1751 void DetachFromThread() override;
dcheng5794dbf2014-12-23 00:00:2752 Capabilities ContextCapabilities() override;
53 ::gpu::gles2::GLES2Interface* ContextGL() override;
54 ::gpu::ContextSupport* ContextSupport() override;
55 class GrContext* GrContext() override;
jbauman35952092015-02-13 00:57:4856 void SetupLock() override;
57 base::Lock* GetLock() override;
dcheng5794dbf2014-12-23 00:00:2758 bool IsContextLost() override;
59 void VerifyContexts() override;
60 void DeleteCachedResources() override;
61 bool DestroyedOnMainThread() override;
62 void SetLostContextCallback(
anujk.sharmac4fa57e2014-10-07 07:31:1563 const LostContextCallback& lost_context_callback) override;
dcheng5794dbf2014-12-23 00:00:2764 void SetMemoryPolicyChangedCallback(
[email protected]0634cdd42013-08-16 00:46:0965 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
anujk.sharmac4fa57e2014-10-07 07:31:1566 override;
[email protected]d03d7842013-02-28 23:08:1767
[email protected]6b144232013-07-30 22:27:5568 void OnLostContext();
[email protected]6d668892013-12-04 21:37:1269 void InitializeCapabilities();
70
[email protected]6b144232013-07-30 22:27:5571 base::ThreadChecker main_thread_checker_;
72 base::ThreadChecker context_thread_checker_;
73
tfarina70da38b2015-01-09 03:16:1074 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl>
[email protected]0634cdd42013-08-16 00:46:0975 context3d_;
tfarina9c951cf2015-01-16 23:26:5376 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_;
[email protected]d03d7842013-02-28 23:08:1777
[email protected]6b144232013-07-30 22:27:5578 LostContextCallback lost_context_callback_;
79
[email protected]d03d7842013-02-28 23:08:1780 base::Lock destroyed_lock_;
81 bool destroyed_;
82
jbauman7dc26052015-02-14 00:22:4583 base::Lock context_lock_;
[email protected]af13d832013-09-13 06:56:2784 std::string debug_name_;
[email protected]d03d7842013-02-28 23:08:1785 class LostContextCallbackProxy;
86 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
87
[email protected]6d668892013-12-04 21:37:1288 cc::ContextProvider::Capabilities capabilities_;
89
[email protected]f44d5552013-10-29 04:56:2990 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess);
[email protected]d03d7842013-02-28 23:08:1791};
92
93} // namespace gpu
94} // namespace webkit
95
[email protected]1fb9e7e2013-05-26 03:23:4896#endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_