summaryrefslogtreecommitdiffstats
path: root/cc/resources/sync_point_helper.cc
blob: f4eea70eb9d09d3670b46cd14ff244a7404fd319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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);
}

}  // namespace cc