summaryrefslogtreecommitdiffstats
path: root/cc/output/copy_output_request.h
blob: d0ef48b3809a912af89d1837784cc9feeb680ec7 (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
38
39
40
41
42
43
44
45
// 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.

#ifndef CC_OUTPUT_COPY_OUTPUT_REQUEST_H_
#define CC_OUTPUT_COPY_OUTPUT_REQUEST_H_

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"

class SkBitmap;

namespace cc {

class CC_EXPORT CopyOutputRequest {
 public:
  typedef base::Callback<void(scoped_ptr<SkBitmap>)> CopyAsBitmapCallback;

  static scoped_ptr<CopyOutputRequest> CreateBitmapRequest(
      const CopyAsBitmapCallback& bitmap_callback) {
    return make_scoped_ptr(new CopyOutputRequest(bitmap_callback));
  }

  ~CopyOutputRequest();

  bool IsEmpty() const { return !HasBitmapRequest(); }
  bool HasBitmapRequest() const { return !bitmap_callback_.is_null(); }

  void SendEmptyResult();
  void SendBitmapResult(scoped_ptr<SkBitmap> bitmap);

  bool Equals(const CopyOutputRequest& other) const {
    return bitmap_callback_.Equals(other.bitmap_callback_);
  }

 private:
  explicit CopyOutputRequest(const CopyAsBitmapCallback& callback);

  CopyAsBitmapCallback bitmap_callback_;
};

}  // namespace cc

#endif  // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_