blob: 82b3e612d681344d71d0dbf603f51dcfc8f437a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TEST_TEST_CONTEXT_PROVIDER_H_
#define CC_TEST_TEST_CONTEXT_PROVIDER_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "cc/output/context_provider.h"
#include "cc/test/test_context_support.h"
#include "gpu/command_buffer/client/gles2_interface_stub.h"
#include "skia/ext/refptr.h"
namespace cc {
class TestWebGraphicsContext3D;
class TestGLES2Interface;
class TestContextProvider : public ContextProvider {
public:
typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)>
CreateCallback;
static scoped_refptr<TestContextProvider> Create();
static scoped_refptr<TestContextProvider> Create(
scoped_ptr<TestWebGraphicsContext3D> context);
bool BindToCurrentThread() override;
void DetachFromThread() override;
Capabilities ContextCapabilities() override;
gpu::gles2::GLES2Interface* ContextGL() override;
gpu::ContextSupport* ContextSupport() override;
class GrContext* GrContext() override;
void InvalidateGrContext(uint32_t state) override;
void SetupLock() override;
base::Lock* GetLock() override;
void VerifyContexts() override;
void DeleteCachedResources() override;
bool DestroyedOnMainThread() override;
void SetLostContextCallback(const LostContextCallback& cb) override;
void SetMemoryPolicyChangedCallback(
const MemoryPolicyChangedCallback& cb) override;
TestWebGraphicsContext3D* TestContext3d();
// This returns the TestWebGraphicsContext3D but is valid to call
// before the context is bound to a thread. This is needed to set up
// state on the test context before binding. Don't call
// InitializeOnCurrentThread on the context returned from this method.
TestWebGraphicsContext3D* UnboundTestContext3d();
TestContextSupport* support() { return &support_; }
void SetMemoryAllocation(const ManagedMemoryPolicy& policy);
void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes);
protected:
explicit TestContextProvider(scoped_ptr<TestWebGraphicsContext3D> context);
~TestContextProvider() override;
private:
void OnLostContext();
TestContextSupport support_;
scoped_ptr<TestWebGraphicsContext3D> context3d_;
scoped_ptr<TestGLES2Interface> context_gl_;
bool bound_;
base::ThreadChecker main_thread_checker_;
base::ThreadChecker context_thread_checker_;
base::Lock destroyed_lock_;
bool destroyed_;
base::Lock context_lock_;
LostContextCallback lost_context_callback_;
MemoryPolicyChangedCallback memory_policy_changed_callback_;
skia::RefPtr<class GrContext> gr_context_;
base::WeakPtrFactory<TestContextProvider> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(TestContextProvider);
};
} // namespace cc
#endif // CC_TEST_TEST_CONTEXT_PROVIDER_H_
|