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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/rate_limiter.h" | 7 #include "cc/rate_limiter.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/proxy.h" | |
11 #include "cc/thread.h" | 10 #include "cc/thread.h" |
12 #include <public/WebGraphicsContext3D.h> | 11 #include <public/WebGraphicsContext3D.h> |
13 | 12 |
14 namespace cc { | 13 namespace cc { |
15 | 14 |
16 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con
text, RateLimiterClient *client) | 15 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con
text, RateLimiterClient *client, Thread* thread) |
17 { | 16 { |
18 return make_scoped_refptr(new RateLimiter(context, client)); | 17 return make_scoped_refptr(new RateLimiter(context, client, thread)); |
19 } | 18 } |
20 | 19 |
21 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien
t *client) | 20 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien
t *client, Thread* thread) |
22 : m_context(context) | 21 : m_thread(thread) |
| 22 , m_context(context) |
23 , m_active(false) | 23 , m_active(false) |
24 , m_client(client) | 24 , m_client(client) |
25 { | 25 { |
26 DCHECK(context); | 26 DCHECK(context); |
27 } | 27 } |
28 | 28 |
29 RateLimiter::~RateLimiter() | 29 RateLimiter::~RateLimiter() |
30 { | 30 { |
31 } | 31 } |
32 | 32 |
33 void RateLimiter::start() | 33 void RateLimiter::start() |
34 { | 34 { |
35 if (m_active) | 35 if (m_active) |
36 return; | 36 return; |
37 | 37 |
38 TRACE_EVENT0("cc", "RateLimiter::start"); | 38 TRACE_EVENT0("cc", "RateLimiter::start"); |
39 m_active = true; | 39 m_active = true; |
40 Proxy::mainThread()->postTask(base::Bind(&RateLimiter::rateLimitContext, thi
s)); | 40 m_thread->postTask(base::Bind(&RateLimiter::rateLimitContext, this)); |
41 } | 41 } |
42 | 42 |
43 void RateLimiter::stop() | 43 void RateLimiter::stop() |
44 { | 44 { |
45 TRACE_EVENT0("cc", "RateLimiter::stop"); | 45 TRACE_EVENT0("cc", "RateLimiter::stop"); |
46 m_client = 0; | 46 m_client = 0; |
47 } | 47 } |
48 | 48 |
49 void RateLimiter::rateLimitContext() | 49 void RateLimiter::rateLimitContext() |
50 { | 50 { |
51 if (!m_client) | 51 if (!m_client) |
52 return; | 52 return; |
53 | 53 |
54 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); | 54 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); |
55 | 55 |
56 m_active = false; | 56 m_active = false; |
57 m_client->rateLimit(); | 57 m_client->rateLimit(); |
58 m_context->rateLimitOffscreenContextCHROMIUM(); | 58 m_context->rateLimitOffscreenContextCHROMIUM(); |
59 } | 59 } |
60 | 60 |
61 } // namespace cc | 61 } // namespace cc |
OLD | NEW |