cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / scheduler / rate_limiter.cc
blobd89d95b8cf23acfbb5ae886fbf3b972de9d9c51e
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.
5 #include "cc/scheduler/rate_limiter.h"
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"
14 namespace cc {
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));
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);
33 RateLimiter::~RateLimiter() {}
35 void RateLimiter::Start() {
36 if (active_)
37 return;
39 TRACE_EVENT0("cc", "RateLimiter::Start");
40 active_ = true;
41 task_runner_->PostTask(FROM_HERE,
42 base::Bind(&RateLimiter::RateLimitContext, this));
45 void RateLimiter::Stop() {
46 TRACE_EVENT0("cc", "RateLimiter::Stop");
47 client_ = NULL;
50 void RateLimiter::RateLimitContext() {
51 if (!client_)
52 return;
54 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext");
56 active_ = false;
57 client_->RateLimit();
58 context_->rateLimitOffscreenContextCHROMIUM();
61 } // namespace cc