OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 #if USE(ACCELERATED_COMPOSITING) | 28 #if USE(ACCELERATED_COMPOSITING) |
29 | 29 |
30 #include "RateLimiter.h" | 30 #include "RateLimiter.h" |
31 | 31 |
32 #include "Extensions3DChromium.h" | 32 #include "Extensions3DChromium.h" |
33 #include "GraphicsContext3D.h" | 33 #include "GraphicsContext3D.h" |
34 #include "TraceEvent.h" | 34 #include "TraceEvent.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 PassRefPtr<RateLimiter> RateLimiter::create(GraphicsContext3D* context) | 38 PassRefPtr<RateLimiter> RateLimiter::create(GraphicsContext3D* context, RateLimi
terClient *client) |
39 { | 39 { |
40 return adoptRef(new RateLimiter(context)); | 40 return adoptRef(new RateLimiter(context, client)); |
41 } | 41 } |
42 | 42 |
43 RateLimiter::RateLimiter(GraphicsContext3D* context) | 43 RateLimiter::RateLimiter(GraphicsContext3D* context, RateLimiterClient *client) |
44 : m_context(context) | 44 : m_context(context) |
45 , m_timer(this, &RateLimiter::rateLimitContext) | 45 , m_timer(this, &RateLimiter::rateLimitContext) |
| 46 , m_client(client) |
46 { | 47 { |
47 ASSERT(context); | 48 ASSERT(context); |
48 ASSERT(context->getExtensions()); | 49 ASSERT(context->getExtensions()); |
49 m_contextSupportsRateLimitingExtension = context->getExtensions()->supports(
"GL_CHROMIUM_rate_limit_offscreen_context"); | 50 m_contextSupportsRateLimitingExtension = context->getExtensions()->supports(
"GL_CHROMIUM_rate_limit_offscreen_context"); |
50 } | 51 } |
51 | 52 |
52 RateLimiter::~RateLimiter() | 53 RateLimiter::~RateLimiter() |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
56 void RateLimiter::start() | 57 void RateLimiter::start() |
57 { | 58 { |
58 if (m_contextSupportsRateLimitingExtension && !m_timer.isActive()) | 59 if (m_contextSupportsRateLimitingExtension && !m_timer.isActive()) |
59 m_timer.startOneShot(0); | 60 m_timer.startOneShot(0); |
60 } | 61 } |
61 | 62 |
62 void RateLimiter::stop() | 63 void RateLimiter::stop() |
63 { | 64 { |
64 m_timer.stop(); | 65 m_timer.stop(); |
65 } | 66 } |
66 | 67 |
67 void RateLimiter::rateLimitContext(Timer<RateLimiter>*) | 68 void RateLimiter::rateLimitContext(Timer<RateLimiter>*) |
68 { | 69 { |
69 TRACE_EVENT("RateLimiter::rateLimitContext", this, 0); | 70 TRACE_EVENT("RateLimiter::rateLimitContext", this, 0); |
70 | 71 |
71 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont
ext->getExtensions()); | 72 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont
ext->getExtensions()); |
72 | 73 |
| 74 m_client->rateLimit(); |
73 extensions->rateLimitOffscreenContextCHROMIUM(); | 75 extensions->rateLimitOffscreenContextCHROMIUM(); |
74 } | 76 } |
75 | 77 |
76 } | 78 } |
77 #endif // USE(ACCELERATED_COMPOSITING) | 79 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |