summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/page_flip_request.cc
blob: 4d1b60d76d05f2900fef0ef0ab163f54403d4ca9 (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
// Copyright 2014 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 "ui/ozone/platform/drm/gpu/page_flip_request.h"

namespace ui {

PageFlipRequest::PageFlipRequest(int crtc_count,
                                 const SwapCompletionCallback& callback)
    : callback_(callback),
      crtc_count_(crtc_count),
      result_(gfx::SwapResult::SWAP_ACK) {
}

PageFlipRequest::~PageFlipRequest() {
}

void PageFlipRequest::Signal(gfx::SwapResult result) {
  if (result == gfx::SwapResult::SWAP_FAILED)
    result_ = gfx::SwapResult::SWAP_FAILED;
  else if (result != gfx::SwapResult::SWAP_ACK)
    result_ = result;

  if (!--crtc_count_) {
    callback_.Run(result_);
    callback_.Reset();
  }
}

}  // namespace ui