summaryrefslogtreecommitdiffstats
path: root/cc/output/copy_output_result.h
blob: 04cf2c6d489bbd60595d8f8481e18ba3b9caa070 (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
46
47
48
49
50
51
52
53
54
55
// 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_RESULT_H_
#define CC_OUTPUT_COPY_OUTPUT_RESULT_H_

#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "ui/gfx/size.h"

class SkBitmap;

namespace cc {
class TextureMailbox;

class CC_EXPORT CopyOutputResult {
 public:
  static scoped_ptr<CopyOutputResult> CreateEmptyResult() {
    return make_scoped_ptr(new CopyOutputResult);
  }
  static scoped_ptr<CopyOutputResult> CreateBitmapResult(
      scoped_ptr<SkBitmap> bitmap) {
    return make_scoped_ptr(new CopyOutputResult(bitmap.Pass()));
  }
  static scoped_ptr<CopyOutputResult> CreateTextureResult(
      gfx::Size size,
      scoped_ptr<TextureMailbox> texture_mailbox) {
    return make_scoped_ptr(new CopyOutputResult(size, texture_mailbox.Pass()));
  }

  ~CopyOutputResult();

  bool IsEmpty() const { return !HasBitmap() && !HasTexture(); }
  bool HasBitmap() const { return !!bitmap_; }
  bool HasTexture() const { return !!texture_mailbox_; }

  gfx::Size size() const { return size_; }
  scoped_ptr<SkBitmap> TakeBitmap();
  scoped_ptr<TextureMailbox> TakeTexture();

 private:
  CopyOutputResult();
  explicit CopyOutputResult(scoped_ptr<SkBitmap> bitmap);
  explicit CopyOutputResult(gfx::Size size,
                            scoped_ptr<TextureMailbox> texture_mailbox);

  gfx::Size size_;
  scoped_ptr<SkBitmap> bitmap_;
  scoped_ptr<TextureMailbox> texture_mailbox_;
};

}  // namespace cc

#endif  // CC_OUTPUT_COPY_OUTPUT_RESULT_H_