OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 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/scheduler/rate_limiter.h" | 5 #include "cc/scheduler/rate_limiter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 12 #include "cc/layers/texture_layer_client.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 scoped_refptr<RateLimiter> RateLimiter::Create( | 16 scoped_refptr<RateLimiter> RateLimiter::Create( |
17 WebKit::WebGraphicsContext3D* context, | 17 TextureLayerClient* texture_layer_client, |
18 RateLimiterClient* client, | 18 RateLimiterClient* client, |
19 base::SingleThreadTaskRunner* task_runner) { | 19 base::SingleThreadTaskRunner* task_runner) { |
20 return make_scoped_refptr(new RateLimiter(context, client, task_runner)); | 20 return make_scoped_refptr( |
| 21 new RateLimiter(texture_layer_client, client, task_runner)); |
21 } | 22 } |
22 | 23 |
23 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, | 24 RateLimiter::RateLimiter(TextureLayerClient* texture_layer_client, |
24 RateLimiterClient* client, | 25 RateLimiterClient* client, |
25 base::SingleThreadTaskRunner* task_runner) | 26 base::SingleThreadTaskRunner* task_runner) |
26 : context_(context), | 27 : texture_layer_client_(texture_layer_client), |
27 active_(false), | 28 active_(false), |
28 client_(client), | 29 client_(client), |
29 task_runner_(task_runner) { | 30 task_runner_(task_runner) { |
30 DCHECK(context); | 31 DCHECK(texture_layer_client); |
31 } | 32 } |
32 | 33 |
33 RateLimiter::~RateLimiter() {} | 34 RateLimiter::~RateLimiter() {} |
34 | 35 |
35 void RateLimiter::Start() { | 36 void RateLimiter::Start() { |
36 if (active_) | 37 if (active_) |
37 return; | 38 return; |
38 | 39 |
39 TRACE_EVENT0("cc", "RateLimiter::Start"); | 40 TRACE_EVENT0("cc", "RateLimiter::Start"); |
40 active_ = true; | 41 active_ = true; |
41 task_runner_->PostTask(FROM_HERE, | 42 task_runner_->PostTask(FROM_HERE, |
42 base::Bind(&RateLimiter::RateLimitContext, this)); | 43 base::Bind(&RateLimiter::RateLimitContext, this)); |
43 } | 44 } |
44 | 45 |
45 void RateLimiter::Stop() { | 46 void RateLimiter::Stop() { |
46 TRACE_EVENT0("cc", "RateLimiter::Stop"); | 47 TRACE_EVENT0("cc", "RateLimiter::Stop"); |
47 client_ = NULL; | 48 client_ = NULL; |
48 } | 49 } |
49 | 50 |
50 void RateLimiter::RateLimitContext() { | 51 void RateLimiter::RateLimitContext() { |
51 if (!client_) | 52 if (!client_) |
52 return; | 53 return; |
53 | 54 |
54 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext"); | 55 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext"); |
55 | 56 |
56 active_ = false; | 57 active_ = false; |
57 client_->RateLimit(); | 58 client_->RateLimit(); |
58 context_->rateLimitOffscreenContextCHROMIUM(); | 59 texture_layer_client_->RateLimitContext(); |
59 } | 60 } |
60 | 61 |
61 } // namespace cc | 62 } // namespace cc |
OLD | NEW |