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

Side by Side Diff: cc/scheduler/rate_limiter.cc

Issue 53153006: Simplify rate limiting since it's main thread shared context only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 years, 1 month 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
« no previous file with comments | « cc/scheduler/rate_limiter.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/scheduler/rate_limiter.h"
6
7 #include "base/bind.h"
8 #include "base/debug/trace_event.h"
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h"
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
13
14 namespace cc {
15
16 scoped_refptr<RateLimiter> RateLimiter::Create(
17 WebKit::WebGraphicsContext3D* context,
18 RateLimiterClient* client,
19 base::SingleThreadTaskRunner* task_runner) {
20 return make_scoped_refptr(new RateLimiter(context, client, task_runner));
21 }
22
23 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context,
24 RateLimiterClient* client,
25 base::SingleThreadTaskRunner* task_runner)
26 : context_(context),
27 active_(false),
28 client_(client),
29 task_runner_(task_runner) {
30 DCHECK(context);
31 }
32
33 RateLimiter::~RateLimiter() {}
34
35 void RateLimiter::Start() {
36 if (active_)
37 return;
38
39 TRACE_EVENT0("cc", "RateLimiter::Start");
40 active_ = true;
41 task_runner_->PostTask(FROM_HERE,
42 base::Bind(&RateLimiter::RateLimitContext, this));
43 }
44
45 void RateLimiter::Stop() {
46 TRACE_EVENT0("cc", "RateLimiter::Stop");
47 client_ = NULL;
48 }
49
50 void RateLimiter::RateLimitContext() {
51 if (!client_)
52 return;
53
54 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext");
55
56 active_ = false;
57 client_->RateLimit();
58 context_->rateLimitOffscreenContextCHROMIUM();
59 }
60
61 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/rate_limiter.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698