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

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

Issue 376683004: Pass resourceless software mode in BeginFrameArgs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tiny clean up Created 6 years, 5 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 client_->DidLoseOutputSurface(); 100 client_->DidLoseOutputSurface();
101 } 101 }
102 102
103 void OutputSurface::SetExternalStencilTest(bool enabled) { 103 void OutputSurface::SetExternalStencilTest(bool enabled) {
104 external_stencil_test_enabled_ = enabled; 104 external_stencil_test_enabled_ = enabled;
105 } 105 }
106 106
107 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, 107 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform,
108 const gfx::Rect& viewport, 108 const gfx::Rect& viewport,
109 const gfx::Rect& clip, 109 const gfx::Rect& clip,
110 bool resourceless_software_draw,
110 bool valid_for_tile_management) { 111 bool valid_for_tile_management) {
111 client_->SetExternalDrawConstraints( 112 client_->SetExternalDrawConstraints(transform,
112 transform, viewport, clip, valid_for_tile_management); 113 viewport,
114 clip,
115 resourceless_software_draw,
116 valid_for_tile_management);
113 } 117 }
114 118
115 OutputSurface::~OutputSurface() { 119 OutputSurface::~OutputSurface() {
116 ResetContext3d(); 120 ResetContext3d();
117 } 121 }
118 122
119 bool OutputSurface::HasExternalStencilTest() const { 123 bool OutputSurface::HasExternalStencilTest() const {
120 return external_stencil_test_enabled_; 124 return external_stencil_test_enabled_;
121 } 125 }
122 126
123 bool OutputSurface::ForcedDrawToSoftwareDevice() const { return false; }
124
125 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { 127 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
126 DCHECK(client); 128 DCHECK(client);
127 client_ = client; 129 client_ = client;
128 bool success = true; 130 bool success = true;
129 131
130 if (context_provider_) { 132 if (context_provider_) {
131 success = context_provider_->BindToCurrentThread(); 133 success = context_provider_->BindToCurrentThread();
132 if (success) 134 if (success)
133 SetUpContext3d(); 135 SetUpContext3d();
134 } 136 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 270
269 base::TimeDelta OutputSurface::GpuLatencyEstimate() { 271 base::TimeDelta OutputSurface::GpuLatencyEstimate() {
270 if (context_provider_ && !capabilities_.adjust_deadline_for_parent) 272 if (context_provider_ && !capabilities_.adjust_deadline_for_parent)
271 return gpu_latency_history_.Percentile(kGpuLatencyEstimationPercentile); 273 return gpu_latency_history_.Percentile(kGpuLatencyEstimationPercentile);
272 else 274 else
273 return base::TimeDelta(); 275 return base::TimeDelta();
274 } 276 }
275 277
276 void OutputSurface::UpdateAndMeasureGpuLatency() { 278 void OutputSurface::UpdateAndMeasureGpuLatency() {
277 // http://crbug.com/306690 tracks re-enabling latency queries. 279 // http://crbug.com/306690 tracks re-enabling latency queries.
278 #if 0
brianderson 2014/07/08 21:26:12 I'm removing this in https://codereview.chromium.o
boliu 2014/07/08 21:31:14 Yeah presubmit wouldn't let me upload if I don't r
279 // We only care about GPU latency for surfaces that do not have a parent
280 // compositor, since surfaces that do have a parent compositor can use
281 // mailboxes or delegated rendering to send frames to their parent without
282 // incurring GPU latency.
283 if (capabilities_.adjust_deadline_for_parent)
284 return;
285
286 while (pending_gpu_latency_query_ids_.size()) {
287 unsigned query_id = pending_gpu_latency_query_ids_.front();
288 unsigned query_complete = 1;
289 context_provider_->ContextGL()->GetQueryObjectuivEXT(
290 query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &query_complete);
291 if (!query_complete)
292 break;
293
294 unsigned value = 0;
295 context_provider_->ContextGL()->GetQueryObjectuivEXT(
296 query_id, GL_QUERY_RESULT_EXT, &value);
297 pending_gpu_latency_query_ids_.pop_front();
298 available_gpu_latency_query_ids_.push_back(query_id);
299
300 base::TimeDelta latency = base::TimeDelta::FromMicroseconds(value);
301 base::TimeDelta latency_estimate = GpuLatencyEstimate();
302 gpu_latency_history_.InsertSample(latency);
303
304 base::TimeDelta latency_overestimate;
305 base::TimeDelta latency_underestimate;
306 if (latency > latency_estimate)
307 latency_underestimate = latency - latency_estimate;
308 else
309 latency_overestimate = latency_estimate - latency;
310 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.GpuLatency",
311 latency,
312 base::TimeDelta::FromMilliseconds(1),
313 base::TimeDelta::FromMilliseconds(100),
314 50);
315 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.GpuLatencyUnderestimate",
316 latency_underestimate,
317 base::TimeDelta::FromMilliseconds(1),
318 base::TimeDelta::FromMilliseconds(100),
319 50);
320 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.GpuLatencyOverestimate",
321 latency_overestimate,
322 base::TimeDelta::FromMilliseconds(1),
323 base::TimeDelta::FromMilliseconds(100),
324 50);
325 }
326
327 unsigned gpu_latency_query_id;
328 if (available_gpu_latency_query_ids_.size()) {
329 gpu_latency_query_id = available_gpu_latency_query_ids_.front();
330 available_gpu_latency_query_ids_.pop_front();
331 } else {
332 context_provider_->ContextGL()->GenQueriesEXT(1, &gpu_latency_query_id);
333 }
334
335 context_provider_->ContextGL()->BeginQueryEXT(GL_LATENCY_QUERY_CHROMIUM,
336 gpu_latency_query_id);
337 context_provider_->ContextGL()->EndQueryEXT(GL_LATENCY_QUERY_CHROMIUM);
338 pending_gpu_latency_query_ids_.push_back(gpu_latency_query_id);
339 #endif
340 } 280 }
341 281
342 void OutputSurface::PostSwapBuffersComplete() { 282 void OutputSurface::PostSwapBuffersComplete() {
343 base::MessageLoop::current()->PostTask( 283 base::MessageLoop::current()->PostTask(
344 FROM_HERE, 284 FROM_HERE,
345 base::Bind(&OutputSurface::OnSwapBuffersComplete, 285 base::Bind(&OutputSurface::OnSwapBuffersComplete,
346 weak_ptr_factory_.GetWeakPtr())); 286 weak_ptr_factory_.GetWeakPtr()));
347 } 287 }
348 288
349 // We don't post tasks bound to the client directly since they might run 289 // We don't post tasks bound to the client directly since they might run
350 // after the OutputSurface has been destroyed. 290 // after the OutputSurface has been destroyed.
351 void OutputSurface::OnSwapBuffersComplete() { 291 void OutputSurface::OnSwapBuffersComplete() {
352 client_->DidSwapBuffersComplete(); 292 client_->DidSwapBuffersComplete();
353 } 293 }
354 294
355 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 295 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
356 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", 296 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy",
357 "bytes_limit_when_visible", policy.bytes_limit_when_visible); 297 "bytes_limit_when_visible", policy.bytes_limit_when_visible);
358 // Just ignore the memory manager when it says to set the limit to zero 298 // Just ignore the memory manager when it says to set the limit to zero
359 // bytes. This will happen when the memory manager thinks that the renderer 299 // bytes. This will happen when the memory manager thinks that the renderer
360 // is not visible (which the renderer knows better). 300 // is not visible (which the renderer knows better).
361 if (policy.bytes_limit_when_visible) 301 if (policy.bytes_limit_when_visible)
362 client_->SetMemoryPolicy(policy); 302 client_->SetMemoryPolicy(policy);
363 } 303 }
364 304
365 } // namespace cc 305 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698