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

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

Issue 23796002: cc: Implement deadine scheduling disabled by default (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedReadback4
Patch Set: rebase? Created 7 years, 3 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 <algorithm>
7 #include <set> 8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 skipped_begin_frame_args_ = args; 155 skipped_begin_frame_args_ = args;
155 } else { 156 } else {
156 begin_frame_pending_ = true; 157 begin_frame_pending_ = true;
157 client_->BeginFrame(args); 158 client_->BeginFrame(args);
158 // args might be an alias for skipped_begin_frame_args_. 159 // args might be an alias for skipped_begin_frame_args_.
159 // Do not reset it before calling BeginFrame! 160 // Do not reset it before calling BeginFrame!
160 skipped_begin_frame_args_ = BeginFrameArgs(); 161 skipped_begin_frame_args_ = BeginFrameArgs();
161 } 162 }
162 } 163 }
163 164
164 base::TimeDelta OutputSurface::AlternateRetroactiveBeginFramePeriod() { 165 base::TimeTicks OutputSurface::RetroactiveBeginFrameDeadline() {
165 return BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); 166 // TODO(brianderson): Remove the alternative deadline once we have better
167 // deadline estimations.
168 base::TimeTicks alternative_deadline =
169 skipped_begin_frame_args_.frame_time +
170 BeginFrameArgs::DefaultRetroactiveBeginFramePeriod();
171 return std::max(skipped_begin_frame_args_.deadline, alternative_deadline);
166 } 172 }
167 173
168 void OutputSurface::PostCheckForRetroactiveBeginFrame() { 174 void OutputSurface::PostCheckForRetroactiveBeginFrame() {
169 if (!skipped_begin_frame_args_.IsValid() || 175 if (!skipped_begin_frame_args_.IsValid() ||
170 check_for_retroactive_begin_frame_pending_) 176 check_for_retroactive_begin_frame_pending_)
171 return; 177 return;
172 178
173 base::MessageLoop::current()->PostTask( 179 base::MessageLoop::current()->PostTask(
174 FROM_HERE, 180 FROM_HERE,
175 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, 181 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame,
176 weak_ptr_factory_.GetWeakPtr())); 182 weak_ptr_factory_.GetWeakPtr()));
177 check_for_retroactive_begin_frame_pending_ = true; 183 check_for_retroactive_begin_frame_pending_ = true;
178 } 184 }
179 185
180 void OutputSurface::CheckForRetroactiveBeginFrame() { 186 void OutputSurface::CheckForRetroactiveBeginFrame() {
181 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); 187 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame");
182 check_for_retroactive_begin_frame_pending_ = false; 188 check_for_retroactive_begin_frame_pending_ = false;
183 base::TimeTicks now = base::TimeTicks::Now(); 189 if (base::TimeTicks::Now() < RetroactiveBeginFrameDeadline())
184 // TODO(brianderson): Remove the alternative deadline once we have better
185 // deadline estimations.
186 base::TimeTicks alternative_deadline =
187 skipped_begin_frame_args_.frame_time +
188 AlternateRetroactiveBeginFramePeriod();
189 if (now < skipped_begin_frame_args_.deadline ||
190 now < alternative_deadline) {
191 BeginFrame(skipped_begin_frame_args_); 190 BeginFrame(skipped_begin_frame_args_);
192 }
193 } 191 }
194 192
195 void OutputSurface::DidSwapBuffers() { 193 void OutputSurface::DidSwapBuffers() {
196 begin_frame_pending_ = false; 194 begin_frame_pending_ = false;
197 pending_swap_buffers_++; 195 pending_swap_buffers_++;
198 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", 196 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers",
199 "pending_swap_buffers_", pending_swap_buffers_); 197 "pending_swap_buffers_", pending_swap_buffers_);
200 if (frame_rate_controller_) 198 if (frame_rate_controller_)
201 frame_rate_controller_->DidSwapBuffers(); 199 frame_rate_controller_->DidSwapBuffers();
202 PostCheckForRetroactiveBeginFrame(); 200 PostCheckForRetroactiveBeginFrame();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 "discard_backbuffer", discard_backbuffer); 396 "discard_backbuffer", discard_backbuffer);
399 // Just ignore the memory manager when it says to set the limit to zero 397 // Just ignore the memory manager when it says to set the limit to zero
400 // bytes. This will happen when the memory manager thinks that the renderer 398 // bytes. This will happen when the memory manager thinks that the renderer
401 // is not visible (which the renderer knows better). 399 // is not visible (which the renderer knows better).
402 if (policy.bytes_limit_when_visible) 400 if (policy.bytes_limit_when_visible)
403 client_->SetMemoryPolicy(policy); 401 client_->SetMemoryPolicy(policy);
404 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); 402 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer);
405 } 403 }
406 404
407 } // namespace cc 405 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698