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

Side by Side Diff: cc/output/output_surface.cc

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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "cc/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 base::trace_event::ProcessMemoryDump* pmd_; 113 base::trace_event::ProcessMemoryDump* pmd_;
114 uint64_t share_group_tracing_guid_; 114 uint64_t share_group_tracing_guid_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(SkiaGpuTraceMemoryDump); 116 DISALLOW_COPY_AND_ASSIGN(SkiaGpuTraceMemoryDump);
117 }; 117 };
118 118
119 } // namespace 119 } // namespace
120 120
121 OutputSurface::OutputSurface( 121 OutputSurface::OutputSurface(
122 scoped_refptr<ContextProvider> context_provider, 122 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
123 scoped_refptr<ContextProvider> worker_context_provider, 123 scoped_refptr<ContextProvider> worker_context_provider,
124 scoped_refptr<VulkanContextProvider> vulkan_context_provider, 124 scoped_refptr<VulkanContextProvider> vulkan_context_provider,
125 std::unique_ptr<SoftwareOutputDevice> software_device) 125 std::unique_ptr<SoftwareOutputDevice> software_device)
126 : client_(NULL), 126 : client_(NULL),
127 context_provider_(std::move(context_provider)), 127 context_provider_create_(std::move(context_provider_create)),
128 worker_context_provider_(std::move(worker_context_provider)), 128 worker_context_provider_(std::move(worker_context_provider)),
129 vulkan_context_provider_(vulkan_context_provider), 129 vulkan_context_provider_(vulkan_context_provider),
130 software_device_(std::move(software_device)), 130 software_device_(std::move(software_device)),
131 device_scale_factor_(-1), 131 device_scale_factor_(-1),
132 has_alpha_(true), 132 has_alpha_(true),
133 external_stencil_test_enabled_(false), 133 external_stencil_test_enabled_(false),
134 weak_ptr_factory_(this) { 134 weak_ptr_factory_(this) {
135 client_thread_checker_.DetachFromThread(); 135 client_thread_checker_.DetachFromThread();
136 } 136 }
137 137
138 OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) 138 OutputSurface::OutputSurface(
139 : OutputSurface(std::move(context_provider), 139 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create)
140 : OutputSurface(std::move(context_provider_create),
140 nullptr, 141 nullptr,
141 nullptr, 142 nullptr,
142 nullptr) { 143 nullptr) {}
143 }
144 144
145 OutputSurface::OutputSurface( 145 OutputSurface::OutputSurface(
146 scoped_refptr<ContextProvider> context_provider, 146 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
147 scoped_refptr<ContextProvider> worker_context_provider) 147 scoped_refptr<ContextProvider> worker_context_provider)
148 : OutputSurface(std::move(context_provider), 148 : OutputSurface(std::move(context_provider_create),
149 std::move(worker_context_provider), 149 std::move(worker_context_provider),
150 nullptr, 150 nullptr,
151 nullptr) { 151 nullptr) {}
152 }
153 152
154 OutputSurface::OutputSurface( 153 OutputSurface::OutputSurface(
155 std::unique_ptr<SoftwareOutputDevice> software_device) 154 std::unique_ptr<SoftwareOutputDevice> software_device)
156 : OutputSurface(nullptr, 155 : OutputSurface(nullptr,
157 nullptr, 156 nullptr,
158 nullptr, 157 nullptr,
159 std::move(software_device)) { 158 std::move(software_device)) {
160 } 159 }
161 160
162 OutputSurface::OutputSurface( 161 OutputSurface::OutputSurface(
163 scoped_refptr<ContextProvider> context_provider, 162 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
164 std::unique_ptr<SoftwareOutputDevice> software_device) 163 std::unique_ptr<SoftwareOutputDevice> software_device)
165 : OutputSurface(std::move(context_provider), 164 : OutputSurface(std::move(context_provider_create),
166 nullptr, 165 nullptr,
167 nullptr, 166 nullptr,
168 std::move(software_device)) { 167 std::move(software_device)) {}
169 }
170 168
171 // Forwarded to OutputSurfaceClient 169 // Forwarded to OutputSurfaceClient
172 void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { 170 void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
173 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect"); 171 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect");
174 client_->SetNeedsRedrawRect(damage_rect); 172 client_->SetNeedsRedrawRect(damage_rect);
175 } 173 }
176 174
177 void OutputSurface::ReclaimResources(const CompositorFrameAck* ack) { 175 void OutputSurface::ReclaimResources(const CompositorFrameAck* ack) {
178 client_->ReclaimResources(ack); 176 client_->ReclaimResources(ack);
179 } 177 }
(...skipping 18 matching lines...) Expand all
198 196
199 void OutputSurface::ApplyExternalStencil() {} 197 void OutputSurface::ApplyExternalStencil() {}
200 198
201 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { 199 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
202 DCHECK(client_thread_checker_.CalledOnValidThread()); 200 DCHECK(client_thread_checker_.CalledOnValidThread());
203 DCHECK(client); 201 DCHECK(client);
204 DCHECK(!client_); 202 DCHECK(!client_);
205 client_ = client; 203 client_ = client;
206 bool success = true; 204 bool success = true;
207 205
208 if (context_provider_.get()) { 206 if (context_provider_create_) {
209 success = context_provider_->BindToCurrentThread(); 207 context_provider_ = context_provider_create_->CreateContext();
210 if (success) { 208 if (context_provider_) {
211 context_provider_->SetLostContextCallback(base::Bind( 209 context_provider_->SetLostContextCallback(base::Bind(
212 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); 210 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
213 } 211 }
212 success = !!context_provider_;
213 // Don't keep around the dead DeferredCreate.
214 context_provider_create_ = nullptr;
214 } 215 }
215 216
216 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 217 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
217 // Don't register a dump provider in these cases. 218 // Don't register a dump provider in these cases.
218 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 219 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
219 if (base::ThreadTaskRunnerHandle::IsSet()) { 220 if (base::ThreadTaskRunnerHandle::IsSet()) {
220 // Now that we are on the context thread, register a dump provider with this 221 // Now that we are on the context thread, register a dump provider with this
221 // thread's task runner. This will overwrite any previous dump provider 222 // thread's task runner. This will overwrite any previous dump provider
222 // registered. 223 // registered.
223 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 224 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (context_provider_.get()) { 361 if (context_provider_.get()) {
361 context_provider_->SetLostContextCallback( 362 context_provider_->SetLostContextCallback(
362 ContextProvider::LostContextCallback()); 363 ContextProvider::LostContextCallback());
363 } 364 }
364 context_provider_ = nullptr; 365 context_provider_ = nullptr;
365 client_ = nullptr; 366 client_ = nullptr;
366 weak_ptr_factory_.InvalidateWeakPtrs(); 367 weak_ptr_factory_.InvalidateWeakPtrs();
367 } 368 }
368 369
369 } // namespace cc 370 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698