Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef SharedContextRateLimiter_h 5 #ifndef SharedContextRateLimiter_h
6 #define SharedContextRateLimiter_h 6 #define SharedContextRateLimiter_h
7 7
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Deque.h" 10 #include "wtf/Deque.h"
11 #include "wtf/Noncopyable.h" 11 #include "wtf/Noncopyable.h"
12 #include <memory> 12 #include "wtf/OwnPtr.h"
13 #include "wtf/PassOwnPtr.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class WebGraphicsContext3DProvider; 17 class WebGraphicsContext3DProvider;
17 18
18 // Purpose: to limit the amount of worked queued for execution 19 // Purpose: to limit the amount of worked queued for execution
19 // (backlog) on the GPU by blocking the main thread to allow the GPU 20 // (backlog) on the GPU by blocking the main thread to allow the GPU
20 // to catch up. The Prevents unsynchronized tight animation loops 21 // to catch up. The Prevents unsynchronized tight animation loops
21 // from cause a GPU denial of service. 22 // from cause a GPU denial of service.
22 // 23 //
23 // How it works: The rate limiter uses GPU fences to mark each tick 24 // How it works: The rate limiter uses GPU fences to mark each tick
24 // and makes sure there are never more that 'maxPendingTicks' fences 25 // and makes sure there are never more that 'maxPendingTicks' fences
25 // that are awaiting completion. On platforms that do not support 26 // that are awaiting completion. On platforms that do not support
26 // fences, we use glFinish instead. glFinish will only be called in 27 // fences, we use glFinish instead. glFinish will only be called in
27 // unsynchronized cases that submit more than maxPendingTicks animation 28 // unsynchronized cases that submit more than maxPendingTicks animation
28 // tick per compositor frame, which should be quite rare. 29 // tick per compositor frame, which should be quite rare.
29 // 30 //
30 // How to use it: Each unit of work that constitutes a complete animation 31 // How to use it: Each unit of work that constitutes a complete animation
31 // frame must call tick(). reset() must be called when the animation 32 // frame must call tick(). reset() must be called when the animation
32 // is consumed by committing to the compositor. Several rate limiters can 33 // is consumed by committing to the compositor. Several rate limiters can
33 // be used concurrently: they will each use their own sequences of 34 // be used concurrently: they will each use their own sequences of
34 // fences which may be interleaved. When the graphics context is lost 35 // fences which may be interleaved. When the graphics context is lost
35 // and later restored, the existing rate limiter must be destroyed and 36 // and later restored, the existing rate limiter must be destroyed and
36 // a new one created. 37 // a new one created.
37 38
38 class SharedContextRateLimiter final { 39 class SharedContextRateLimiter final {
39 USING_FAST_MALLOC(SharedContextRateLimiter); 40 USING_FAST_MALLOC(SharedContextRateLimiter);
40 WTF_MAKE_NONCOPYABLE(SharedContextRateLimiter); 41 WTF_MAKE_NONCOPYABLE(SharedContextRateLimiter);
41 public: 42 public:
42 static std::unique_ptr<SharedContextRateLimiter> create(unsigned maxPendingT icks); 43 static PassOwnPtr<SharedContextRateLimiter> create(unsigned maxPendingTicks) ;
43 void tick(); 44 void tick();
44 void reset(); 45 void reset();
45 private: 46 private:
46 SharedContextRateLimiter(unsigned maxPendingTicks); 47 SharedContextRateLimiter(unsigned maxPendingTicks);
47 48
48 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; 49 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
49 Deque<GLuint> m_queries; 50 Deque<GLuint> m_queries;
50 unsigned m_maxPendingTicks; 51 unsigned m_maxPendingTicks;
51 bool m_canUseSyncQueries; 52 bool m_canUseSyncQueries;
52 }; 53 };
53 54
54 } // namespace blink 55 } // namespace blink
55 56
56 #endif 57 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698