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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/SharedGpuContext.cpp

Issue 2846843002: [blink] Unique pointers in Platform.h (Closed)
Patch Set: fix compilation (and again) Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "platform/graphics/gpu/SharedGpuContext.h" 5 #include "platform/graphics/gpu/SharedGpuContext.h"
6 6
7 #include "gpu/command_buffer/client/gles2_interface.h" 7 #include "gpu/command_buffer/client/gles2_interface.h"
8 #include "gpu/command_buffer/common/capabilities.h" 8 #include "gpu/command_buffer/common/capabilities.h"
9 #include "platform/CrossThreadFunctional.h" 9 #include "platform/CrossThreadFunctional.h"
10 #include "platform/WaitableEvent.h" 10 #include "platform/WaitableEvent.h"
(...skipping 13 matching lines...) Expand all
24 SharedGpuContext::SharedGpuContext() : context_id_(kNoSharedContext) { 24 SharedGpuContext::SharedGpuContext() : context_id_(kNoSharedContext) {
25 CreateContextProviderIfNeeded(); 25 CreateContextProviderIfNeeded();
26 } 26 }
27 27
28 void SharedGpuContext::CreateContextProviderOnMainThread( 28 void SharedGpuContext::CreateContextProviderOnMainThread(
29 WaitableEvent* waitable_event) { 29 WaitableEvent* waitable_event) {
30 DCHECK(IsMainThread()); 30 DCHECK(IsMainThread());
31 Platform::ContextAttributes context_attributes; 31 Platform::ContextAttributes context_attributes;
32 context_attributes.web_gl_version = 1; // GLES2 32 context_attributes.web_gl_version = 1; // GLES2
33 Platform::GraphicsInfo graphics_info; 33 Platform::GraphicsInfo graphics_info;
34 context_provider_ = WTF::WrapUnique( 34 context_provider_ =
35 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( 35 Platform::Current()->CreateOffscreenGraphicsContext3DProvider(
36 context_attributes, WebURL(), nullptr, &graphics_info)); 36 context_attributes, WebURL(), nullptr, &graphics_info);
37 if (waitable_event) 37 if (waitable_event)
38 waitable_event->Signal(); 38 waitable_event->Signal();
39 } 39 }
40 40
41 void SharedGpuContext::CreateContextProviderIfNeeded() { 41 void SharedGpuContext::CreateContextProviderIfNeeded() {
42 if (context_provider_ && 42 if (context_provider_ &&
43 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() == 43 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() ==
44 GL_NO_ERROR) 44 GL_NO_ERROR)
45 return; 45 return;
46 46
47 std::unique_ptr<WebGraphicsContext3DProvider> old_context_provider = 47 std::unique_ptr<WebGraphicsContext3DProvider> old_context_provider =
48 std::move(context_provider_); 48 std::move(context_provider_);
49 if (context_provider_factory_) { 49 if (context_provider_factory_) {
50 // This path should only be used in unit tests 50 // This path should only be used in unit tests
51 context_provider_ = context_provider_factory_(); 51 context_provider_ = context_provider_factory_();
52 } else if (IsMainThread()) { 52 } else if (IsMainThread()) {
53 context_provider_ = 53 context_provider_ = blink::Platform::Current()
54 WTF::WrapUnique(blink::Platform::Current() 54 ->CreateSharedOffscreenGraphicsContext3DProvider();
55 ->CreateSharedOffscreenGraphicsContext3DProvider());
56 } else { 55 } else {
57 // This synchronous round-trip to the main thread is the reason why 56 // This synchronous round-trip to the main thread is the reason why
58 // SharedGpuContext encasulates the context provider: so we only have to do 57 // SharedGpuContext encasulates the context provider: so we only have to do
59 // this once per thread. 58 // this once per thread.
60 WaitableEvent waitable_event; 59 WaitableEvent waitable_event;
61 RefPtr<WebTaskRunner> task_runner = 60 RefPtr<WebTaskRunner> task_runner =
62 Platform::Current()->MainThread()->GetWebTaskRunner(); 61 Platform::Current()->MainThread()->GetWebTaskRunner();
63 task_runner->PostTask( 62 task_runner->PostTask(
64 BLINK_FROM_HERE, 63 BLINK_FROM_HERE,
65 CrossThreadBind(&SharedGpuContext::CreateContextProviderOnMainThread, 64 CrossThreadBind(&SharedGpuContext::CreateContextProviderOnMainThread,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 129
131 bool SharedGpuContext::AllowSoftwareToAcceleratedCanvasUpgrade() { 130 bool SharedGpuContext::AllowSoftwareToAcceleratedCanvasUpgrade() {
132 if (!IsValid()) 131 if (!IsValid())
133 return kNoSharedContext; 132 return kNoSharedContext;
134 SharedGpuContext* this_ptr = GetInstanceForCurrentThread(); 133 SharedGpuContext* this_ptr = GetInstanceForCurrentThread();
135 return this_ptr->context_provider_->GetCapabilities() 134 return this_ptr->context_provider_->GetCapabilities()
136 .software_to_accelerated_canvas_upgrade; 135 .software_to_accelerated_canvas_upgrade;
137 } 136 }
138 137
139 } // blink 138 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698