summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/sync_point_helper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/resources/sync_point_helper.cc')
-rw-r--r--chromium/cc/resources/sync_point_helper.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/chromium/cc/resources/sync_point_helper.cc b/chromium/cc/resources/sync_point_helper.cc
new file mode 100644
index 00000000000..f5822a41ae9
--- /dev/null
+++ b/chromium/cc/resources/sync_point_helper.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/resources/sync_point_helper.h"
+
+#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
+
+namespace cc {
+
+class SignalSyncPointCallbackClass
+ : public WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback {
+ public:
+ explicit SignalSyncPointCallbackClass(const base::Closure& closure)
+ : closure_(closure) {}
+
+ virtual void onSyncPointReached() {
+ if (!closure_.is_null())
+ closure_.Run();
+ }
+
+ private:
+ base::Closure closure_;
+};
+
+void SyncPointHelper::SignalSyncPoint(
+ WebKit::WebGraphicsContext3D* context3d,
+ unsigned sync_point,
+ const base::Closure& closure) {
+ SignalSyncPointCallbackClass* callback_class =
+ new SignalSyncPointCallbackClass(closure);
+
+ // Pass ownership of the CallbackClass to WebGraphicsContext3D.
+ context3d->signalSyncPoint(sync_point, callback_class);
+}
+
+void SyncPointHelper::SignalQuery(
+ WebKit::WebGraphicsContext3D* context3d,
+ WebKit::WebGLId query,
+ const base::Closure& closure) {
+ SignalSyncPointCallbackClass* callback_class =
+ new SignalSyncPointCallbackClass(closure);
+
+ // Pass ownership of the CallbackClass to WebGraphicsContext3D.
+ context3d->signalQuery(query, callback_class);
+}
+
+} // namespace cc