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

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

Issue 916723002: cc: Add threaded GPU rasterization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/output/managed_memory_policy.h" 10 #include "cc/output/managed_memory_policy.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 } 127 }
128 128
129 if (!success) 129 if (!success)
130 client_ = NULL; 130 client_ = NULL;
131 131
132 return success; 132 return success;
133 } 133 }
134 134
135 bool OutputSurface::InitializeAndSetContext3d( 135 bool OutputSurface::InitializeAndSetContext3d(
136 scoped_refptr<ContextProvider> context_provider) { 136 scoped_refptr<ContextProvider> context_provider,
137 scoped_refptr<ContextProvider> worker_context_provider) {
137 DCHECK(!context_provider_.get()); 138 DCHECK(!context_provider_.get());
138 DCHECK(context_provider.get()); 139 DCHECK(context_provider.get());
139 DCHECK(client_); 140 DCHECK(client_);
140 141
141 bool success = false; 142 bool success = context_provider->BindToCurrentThread();
142 if (context_provider->BindToCurrentThread()) { 143 if (success) {
143 context_provider_ = context_provider; 144 context_provider_ = context_provider;
144 SetUpContext3d(); 145 SetUpContext3d();
145 client_->DeferredInitialize(); 146 }
146 success = true; 147 if (success && worker_context_provider.get()) {
148 success = worker_context_provider->BindToCurrentThread();
149 if (success) {
150 worker_context_provider_ = worker_context_provider;
151 // The destructor resets the context lost callback, so base::Unretained
152 // is safe, as long as the worker threads stop using the context before
153 // the output surface is destroyed.
154 worker_context_provider_->SetLostContextCallback(base::Bind(
155 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
156 }
147 } 157 }
148 158
149 if (!success) 159 if (!success)
150 ResetContext3d(); 160 ResetContext3d();
161 else
162 client_->DeferredInitialize();
151 163
152 return success; 164 return success;
153 } 165 }
154 166
155 void OutputSurface::ReleaseGL() { 167 void OutputSurface::ReleaseGL() {
156 DCHECK(client_); 168 DCHECK(client_);
157 DCHECK(context_provider_.get()); 169 DCHECK(context_provider_.get());
158 client_->ReleaseGL(); 170 client_->ReleaseGL();
159 DCHECK(!context_provider_.get()); 171 DCHECK(!context_provider_.get());
160 } 172 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", 256 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy",
245 "bytes_limit_when_visible", policy.bytes_limit_when_visible); 257 "bytes_limit_when_visible", policy.bytes_limit_when_visible);
246 // Just ignore the memory manager when it says to set the limit to zero 258 // Just ignore the memory manager when it says to set the limit to zero
247 // bytes. This will happen when the memory manager thinks that the renderer 259 // bytes. This will happen when the memory manager thinks that the renderer
248 // is not visible (which the renderer knows better). 260 // is not visible (which the renderer knows better).
249 if (policy.bytes_limit_when_visible) 261 if (policy.bytes_limit_when_visible)
250 client_->SetMemoryPolicy(policy); 262 client_->SetMemoryPolicy(policy);
251 } 263 }
252 264
253 } // namespace cc 265 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698