Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / cc / scheduler / rate_limiter.h
blob0d2de38ebfcc251a6246e3ad4e6ae678379edaae
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.
5 #ifndef CC_SCHEDULER_RATE_LIMITER_H_
6 #define CC_SCHEDULER_RATE_LIMITER_H_
8 #include "base/memory/ref_counted.h"
10 namespace WebKit { class WebGraphicsContext3D; }
12 namespace cc {
14 class Thread;
16 class RateLimiterClient {
17 public:
18 virtual void RateLimit() = 0;
20 protected:
21 virtual ~RateLimiterClient() {}
24 // A RateLimiter can be used to make sure that a single context does not
25 // dominate all execution time. To use, construct a RateLimiter class around
26 // the context and call Start() whenever calls are made on the context outside
27 // of normal flow control. RateLimiter will block if the context is too far
28 // ahead of the compositor.
29 class RateLimiter : public base::RefCounted<RateLimiter> {
30 public:
31 static scoped_refptr<RateLimiter> Create(
32 WebKit::WebGraphicsContext3D* context,
33 RateLimiterClient* client,
34 Thread* thread);
36 void Start();
38 // Context and client will not be accessed after Stop().
39 void Stop();
41 private:
42 friend class base::RefCounted<RateLimiter>;
44 RateLimiter(WebKit::WebGraphicsContext3D* context,
45 RateLimiterClient* client,
46 Thread* thread);
47 ~RateLimiter();
49 void RateLimitContext();
51 WebKit::WebGraphicsContext3D* context_;
52 bool active_;
53 RateLimiterClient* client_;
54 Thread* thread_;
56 DISALLOW_COPY_AND_ASSIGN(RateLimiter);
59 } // namespace cc
61 #endif // CC_SCHEDULER_RATE_LIMITER_H_