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.
8 #if USE(ACCELERATED_COMPOSITING)
10 #include <wtf/PassRefPtr.h>
11 #include <wtf/RefCounted.h>
14 class WebGraphicsContext3D
;
19 class RateLimiterClient
{
21 virtual void rateLimit() = 0;
24 // A RateLimiter can be used to make sure that a single context does not dominate all execution time.
25 // To use, construct a RateLimiter class around the context and call start() whenever calls are made on the
26 // context outside of normal flow control. RateLimiter will block if the context is too far ahead of the
28 class RateLimiter
: public RefCounted
<RateLimiter
> {
30 static PassRefPtr
<RateLimiter
> create(WebKit::WebGraphicsContext3D
*, RateLimiterClient
*);
35 // Context and client will not be accessed after stop().
39 RateLimiter(WebKit::WebGraphicsContext3D
*, RateLimiterClient
*);
43 void rateLimitContext();
45 WebKit::WebGraphicsContext3D
* m_context
;
47 RateLimiterClient
*m_client
;
51 #endif // USE(ACCELERATED_COMPOSITING)