| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (!success) | 156 if (!success) |
| 157 ResetContext3d(); | 157 ResetContext3d(); |
| 158 | 158 |
| 159 return success; | 159 return success; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void OutputSurface::ReleaseGL() { | 162 void OutputSurface::ReleaseGL() { |
| 163 DCHECK(client_); | 163 DCHECK(client_); |
| 164 DCHECK(context_provider_); | 164 DCHECK(context_provider_); |
| 165 client_->ReleaseGL(); | 165 client_->ReleaseGL(); |
| 166 ResetContext3d(); | 166 DCHECK(!context_provider_); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void OutputSurface::SetUpContext3d() { | 169 void OutputSurface::SetUpContext3d() { |
| 170 DCHECK(context_provider_); | 170 DCHECK(context_provider_); |
| 171 DCHECK(client_); | 171 DCHECK(client_); |
| 172 | 172 |
| 173 context_provider_->SetLostContextCallback( | 173 context_provider_->SetLostContextCallback( |
| 174 base::Bind(&OutputSurface::DidLoseOutputSurface, | 174 base::Bind(&OutputSurface::DidLoseOutputSurface, |
| 175 base::Unretained(this))); | 175 base::Unretained(this))); |
| 176 context_provider_->ContextSupport()->SetSwapBuffersCompleteCallback( | 176 context_provider_->ContextSupport()->SetSwapBuffersCompleteCallback( |
| 177 base::Bind(&OutputSurface::OnSwapBuffersComplete, | 177 base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 178 base::Unretained(this))); | 178 base::Unretained(this))); |
| 179 context_provider_->SetMemoryPolicyChangedCallback( | 179 context_provider_->SetMemoryPolicyChangedCallback( |
| 180 base::Bind(&OutputSurface::SetMemoryPolicy, | 180 base::Bind(&OutputSurface::SetMemoryPolicy, |
| 181 base::Unretained(this))); | 181 base::Unretained(this))); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void OutputSurface::ReleaseContextProvider() { |
| 185 DCHECK(client_); |
| 186 DCHECK(context_provider_); |
| 187 ResetContext3d(); |
| 188 } |
| 189 |
| 184 void OutputSurface::ResetContext3d() { | 190 void OutputSurface::ResetContext3d() { |
| 185 if (context_provider_.get()) { | 191 if (context_provider_.get()) { |
| 186 while (!pending_gpu_latency_query_ids_.empty()) { | 192 while (!pending_gpu_latency_query_ids_.empty()) { |
| 187 unsigned query_id = pending_gpu_latency_query_ids_.front(); | 193 unsigned query_id = pending_gpu_latency_query_ids_.front(); |
| 188 pending_gpu_latency_query_ids_.pop_front(); | 194 pending_gpu_latency_query_ids_.pop_front(); |
| 189 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); | 195 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); |
| 190 } | 196 } |
| 191 while (!available_gpu_latency_query_ids_.empty()) { | 197 while (!available_gpu_latency_query_ids_.empty()) { |
| 192 unsigned query_id = available_gpu_latency_query_ids_.front(); | 198 unsigned query_id = available_gpu_latency_query_ids_.front(); |
| 193 available_gpu_latency_query_ids_.pop_front(); | 199 available_gpu_latency_query_ids_.pop_front(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", | 356 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", |
| 351 "bytes_limit_when_visible", policy.bytes_limit_when_visible); | 357 "bytes_limit_when_visible", policy.bytes_limit_when_visible); |
| 352 // Just ignore the memory manager when it says to set the limit to zero | 358 // Just ignore the memory manager when it says to set the limit to zero |
| 353 // bytes. This will happen when the memory manager thinks that the renderer | 359 // bytes. This will happen when the memory manager thinks that the renderer |
| 354 // is not visible (which the renderer knows better). | 360 // is not visible (which the renderer knows better). |
| 355 if (policy.bytes_limit_when_visible) | 361 if (policy.bytes_limit_when_visible) |
| 356 client_->SetMemoryPolicy(policy); | 362 client_->SetMemoryPolicy(policy); |
| 357 } | 363 } |
| 358 | 364 |
| 359 } // namespace cc | 365 } // namespace cc |
| OLD | NEW |