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

Side by Side Diff: webkit/gpu/test_context_provider_factory.cc

Issue 12217099: Implement the Platform::sharedOffscreenGraphicsContext3D method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop was_created Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // 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
5 #include "webkit/gpu/test_context_provider_factory.h"
6
7 #include "base/logging.h"
8 #include "cc/context_provider.h"
9 #include "webkit/gpu/context_provider_in_process.h"
10
11 namespace webkit {
12 namespace gpu {
13
14 #ifndef NDEBUG
15 static bool factory_set_up = false;
16 #endif
17 static ContextProviderInProcess::InProcessType context_provider_type;
18 static TestContextProviderFactory* context_provider_instance = NULL;
19 static int context_provider_instance_refs = 0;
20
21 // static
22 void TestContextProviderFactory::SetUpFactoryForTesting(
23 webkit_support::GraphicsContext3DImplementation implementation) {
24 factory_set_up = true;
25
26 switch (implementation) {
27 case webkit_support::IN_PROCESS:
28 context_provider_type = webkit::gpu::ContextProviderInProcess::IN_PROCESS;
29 return;
30 case webkit_support::IN_PROCESS_COMMAND_BUFFER:
31 context_provider_type =
32 webkit::gpu::ContextProviderInProcess::IN_PROCESS_COMMAND_BUFFER;
33 return;
34 }
35 NOTREACHED();
36 context_provider_type = webkit::gpu::ContextProviderInProcess::IN_PROCESS;
37 }
38
39 // static
40 TestContextProviderFactory* TestContextProviderFactory::GetInstance() {
41 DCHECK(factory_set_up);
42 if (!context_provider_instance) {
43 context_provider_instance = new TestContextProviderFactory();
44 ++context_provider_instance_refs;
45 }
46 return context_provider_instance;
47 }
48
49 // static
50 void TestContextProviderFactory::DestroyInstance() {
51 --context_provider_instance_refs;
52 if (!context_provider_instance_refs) {
53 delete context_provider_instance;
54 context_provider_instance = NULL;
55 }
56 }
57
58 TestContextProviderFactory::TestContextProviderFactory() {}
59
60 TestContextProviderFactory::~TestContextProviderFactory() {}
61
62 scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
63 OffscreenContextProviderForMainThread() {
64 if (!main_thread_ || main_thread_->DestroyedOnMainThread()) {
65 main_thread_ = new ContextProviderInProcess(context_provider_type);
66 }
67 return main_thread_;
68 }
69
70 scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
71 OffscreenContextProviderForCompositorThread() {
72 if (!compositor_thread_ ||
73 compositor_thread_->DestroyedOnMainThread()) {
74 compositor_thread_ = new ContextProviderInProcess(context_provider_type);
75 }
76 return compositor_thread_;
77 }
78
79 } // namespace gpu
80 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698