Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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. | |
| 4 | |
| 5 #include "cc/resources/sync_point_helper.h" | |
| 6 | |
| 7 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | |
| 8 | |
| 9 namespace cc { | |
| 10 | |
| 11 class SignalSyncPointCallbackClass | |
| 12 : public WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback { | |
| 13 public: | |
| 14 SignalSyncPointCallbackClass(const base::Closure& closure) | |
|
piman
2013/04/26 01:20:52
nit: explicit
| |
| 15 : closure_(closure) {} | |
|
piman
2013/04/26 01:20:52
nit: indent (':' at +4)
| |
| 16 | |
| 17 virtual void onSyncPointReached() { | |
| 18 if (!closure_.is_null()) | |
| 19 closure_.Run(); | |
| 20 } | |
| 21 | |
| 22 private: | |
| 23 base::Closure closure_; | |
| 24 }; | |
| 25 | |
| 26 scoped_ptr<SyncPointHelper> SyncPointHelper::SignalSyncPoint( | |
| 27 WebKit::WebGraphicsContext3D* context3d, | |
| 28 unsigned sync_point, | |
| 29 const base::Closure& closure) { | |
| 30 scoped_ptr<SignalSyncPointCallbackClass> callback_class( | |
| 31 new SignalSyncPointCallbackClass(closure)); | |
| 32 | |
| 33 // Give a pointer to the CallbackClass to WebGraphicsContext3D. | |
| 34 context3d->signalSyncPoint(sync_point, callback_class.get()); | |
| 35 | |
| 36 // Store the ownership of the CallbackClass inside a SyncPointHelper and | |
| 37 // return it. | |
| 38 scoped_ptr<SyncPointHelper> helper( | |
| 39 new SyncPointHelper(callback_class.Pass())); | |
| 40 return helper.Pass(); | |
| 41 } | |
| 42 | |
| 43 SyncPointHelper::SyncPointHelper( | |
| 44 scoped_ptr<SignalSyncPointCallbackClass> callback_class) | |
| 45 : callback_class_(callback_class.Pass()) {} | |
| 46 | |
| 47 SyncPointHelper::~SyncPointHelper() {} | |
| 48 | |
| 49 } // namespace cc | |
| OLD | NEW |