OLD | NEW |
| (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 | |
OLD | NEW |