Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9046)

Unified Diff: cc/test/test_context_provider.h

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/test/test_context_provider.h
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index f294eb7ecd5ba42c7dfbda03498eb3b42026f0dc..73e056003445c680d657ffcfed45ccca7b1296d3 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -30,14 +30,30 @@ class TestContextProvider : public ContextProvider {
CreateCallback;
static scoped_refptr<TestContextProvider> Create();
- // Creates a worker context provider that can be used on any thread. This is
- // equivalent to: Create(); BindToCurrentThread().
- static scoped_refptr<TestContextProvider> CreateWorker();
static scoped_refptr<TestContextProvider> Create(
std::unique_ptr<TestWebGraphicsContext3D> context);
- bool BindToCurrentThread() override;
- void DetachFromThread() override;
+ class DeferredCreate : public ContextProvider::DeferredCreate {
+ public:
+ DeferredCreate();
+ explicit DeferredCreate(std::unique_ptr<TestWebGraphicsContext3D> context);
+ ~DeferredCreate();
+ scoped_refptr<ContextProvider> CreateContext() override;
+
+ // If true, CreateContext will return null, simulating failure to make the
+ // context.
+ bool fail_create = false;
+ // If set, this TestWebGraphicsContext3D will back the context provider.
+ std::unique_ptr<TestWebGraphicsContext3D> webcontext;
+ // Set on the new context unless a |webcontext| is specified, since it also
+ // contains capabilities.
+ gpu::Capabilities capabilities;
+
+ // Set to non-null to have CreateContext give a pointer to the
+ // TestContextProvider it makes.
+ TestContextProvider** created_context = nullptr;
+ };
+
gpu::Capabilities ContextCapabilities() override;
gpu::gles2::GLES2Interface* ContextGL() override;
gpu::ContextSupport* ContextSupport() override;
@@ -46,6 +62,7 @@ class TestContextProvider : public ContextProvider {
base::Lock* GetLock() override;
void DeleteCachedResources() override;
void SetLostContextCallback(const LostContextCallback& cb) override;
+ void DetachFromThread() override;
TestWebGraphicsContext3D* TestContext3d();
@@ -53,6 +70,7 @@ class TestContextProvider : public ContextProvider {
// 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.
+ // TODO(danakj): Delete me.
TestWebGraphicsContext3D* UnboundTestContext3d();
TestContextSupport* support() { return &support_; }
@@ -69,10 +87,8 @@ class TestContextProvider : public ContextProvider {
std::unique_ptr<TestWebGraphicsContext3D> context3d_;
std::unique_ptr<TestGLES2Interface> context_gl_;
- bool bound_;
- base::ThreadChecker main_thread_checker_;
- base::ThreadChecker context_thread_checker_;
+ base::ThreadChecker thread_checker_;
base::Lock context_lock_;

Powered by Google App Engine
This is Rietveld 408576698