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

Side by Side Diff: cc/test/test_in_process_context_provider.h

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: contextfactory: . 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ 5 #ifndef CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
6 #define CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ 6 #define CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 #include "cc/output/context_provider.h" 14 #include "cc/output/context_provider.h"
14 #include "cc/test/test_gpu_memory_buffer_manager.h" 15 #include "cc/test/test_gpu_memory_buffer_manager.h"
15 #include "cc/test/test_image_factory.h" 16 #include "cc/test/test_image_factory.h"
16 17
17 class GrContext; 18 class GrContext;
18 19
19 namespace gpu { 20 namespace gpu {
20 class GLInProcessContext; 21 class GLInProcessContext;
21 } 22 }
22 23
23 namespace skia_bindings { 24 namespace skia_bindings {
24 class GrContextForGLES2Interface; 25 class GrContextForGLES2Interface;
25 } 26 }
26 27
27 namespace cc { 28 namespace cc {
28 29
29 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(); 30 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext();
30 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( 31 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(
31 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, 32 TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
32 TestImageFactory* image_factory, 33 TestImageFactory* image_factory,
33 gpu::GLInProcessContext* shared_context); 34 gpu::GLInProcessContext* shared_context);
34 35
35 class TestInProcessContextProvider : public ContextProvider { 36 class TestInProcessContextProvider : public ContextProvider {
36 public: 37 public:
37 explicit TestInProcessContextProvider( 38 explicit TestInProcessContextProvider(
38 TestInProcessContextProvider* shared_context); 39 TestInProcessContextProvider* shared_context);
39 40
40 bool BindToCurrentThread() override; 41 class Factory : public ContextProvider::Factory {
42 public:
43 explicit Factory(TestInProcessContextProvider* shared_context)
44 : shared_context_(shared_context) {}
45 scoped_refptr<ContextProvider> CreateContext() override;
46
47 private:
48 TestInProcessContextProvider* const shared_context_;
49
50 DISALLOW_COPY_AND_ASSIGN(Factory);
51 };
52
41 gpu::gles2::GLES2Interface* ContextGL() override; 53 gpu::gles2::GLES2Interface* ContextGL() override;
42 gpu::ContextSupport* ContextSupport() override; 54 gpu::ContextSupport* ContextSupport() override;
43 class GrContext* GrContext() override; 55 class GrContext* GrContext() override;
44 void InvalidateGrContext(uint32_t state) override; 56 void InvalidateGrContext(uint32_t state) override;
45 base::Lock* GetLock() override; 57 base::Lock* GetLock() override;
46 gpu::Capabilities ContextCapabilities() override; 58 gpu::Capabilities ContextCapabilities() override;
47 void DeleteCachedResources() override; 59 void DeleteCachedResources() override;
48 void SetLostContextCallback( 60 void SetLostContextCallback(
49 const LostContextCallback& lost_context_callback) override; 61 const LostContextCallback& lost_context_callback) override;
50 62
51 protected: 63 protected:
52 friend class base::RefCountedThreadSafe<TestInProcessContextProvider>; 64 friend class base::RefCountedThreadSafe<TestInProcessContextProvider>;
53 ~TestInProcessContextProvider() override; 65 ~TestInProcessContextProvider() override;
54 66
55 private: 67 private:
56 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; 68 TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
57 TestImageFactory image_factory_; 69 TestImageFactory image_factory_;
58 std::unique_ptr<gpu::GLInProcessContext> context_; 70 std::unique_ptr<gpu::GLInProcessContext> context_;
59 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; 71 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_;
60 base::Lock context_lock_; 72 base::Lock context_lock_;
61 }; 73 };
62 74
63 } // namespace cc 75 } // namespace cc
64 76
65 #endif // CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ 77 #endif // CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698