OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_COPY_OUTPUT_RESULT_H_ | 5 #ifndef CC_OUTPUT_COPY_OUTPUT_RESULT_H_ |
6 #define CC_OUTPUT_COPY_OUTPUT_RESULT_H_ | 6 #define CC_OUTPUT_COPY_OUTPUT_RESULT_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/resources/texture_mailbox.h" | 10 #include "cc/resources/texture_mailbox.h" |
11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
12 | 12 |
13 class SkBitmap; | 13 class SkBitmap; |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 class SingleReleaseCallback; | 16 class SingleReleaseCallback; |
17 class TextureMailbox; | 17 class TextureMailbox; |
18 | 18 |
19 class CC_EXPORT CopyOutputResult { | 19 class CC_EXPORT CopyOutputResult { |
20 public: | 20 public: |
21 static scoped_ptr<CopyOutputResult> CreateEmptyResult() { | 21 static scoped_ptr<CopyOutputResult> CreateEmptyResult() { |
22 return make_scoped_ptr(new CopyOutputResult); | 22 return make_scoped_ptr(new CopyOutputResult); |
23 } | 23 } |
24 static scoped_ptr<CopyOutputResult> CreateBitmapResult( | 24 static scoped_ptr<CopyOutputResult> CreateBitmapResult( |
25 scoped_ptr<SkBitmap> bitmap) { | 25 scoped_ptr<SkBitmap> bitmap) { |
26 return make_scoped_ptr(new CopyOutputResult(bitmap.Pass())); | 26 return make_scoped_ptr(new CopyOutputResult(bitmap.Pass())); |
27 } | 27 } |
28 static scoped_ptr<CopyOutputResult> CreateTextureResult( | 28 static scoped_ptr<CopyOutputResult> CreateTextureResult( |
29 const gfx::Size& size, | 29 gfx::Size size, |
30 const TextureMailbox& texture_mailbox, | 30 const TextureMailbox& texture_mailbox, |
31 scoped_ptr<SingleReleaseCallback> release_callback) { | 31 scoped_ptr<SingleReleaseCallback> release_callback) { |
32 return make_scoped_ptr( | 32 return make_scoped_ptr( |
33 new CopyOutputResult(size, texture_mailbox, release_callback.Pass())); | 33 new CopyOutputResult(size, texture_mailbox, release_callback.Pass())); |
34 } | 34 } |
35 | 35 |
36 ~CopyOutputResult(); | 36 ~CopyOutputResult(); |
37 | 37 |
38 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); } | 38 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); } |
39 bool HasBitmap() const { return !!bitmap_; } | 39 bool HasBitmap() const { return !!bitmap_; } |
40 bool HasTexture() const { return texture_mailbox_.IsValid(); } | 40 bool HasTexture() const { return texture_mailbox_.IsValid(); } |
41 | 41 |
42 gfx::Size size() const { return size_; } | 42 gfx::Size size() const { return size_; } |
43 scoped_ptr<SkBitmap> TakeBitmap(); | 43 scoped_ptr<SkBitmap> TakeBitmap(); |
44 void TakeTexture(TextureMailbox* texture_mailbox, | 44 void TakeTexture(TextureMailbox* texture_mailbox, |
45 scoped_ptr<SingleReleaseCallback>* release_callback); | 45 scoped_ptr<SingleReleaseCallback>* release_callback); |
46 | 46 |
47 private: | 47 private: |
48 CopyOutputResult(); | 48 CopyOutputResult(); |
49 explicit CopyOutputResult(scoped_ptr<SkBitmap> bitmap); | 49 explicit CopyOutputResult(scoped_ptr<SkBitmap> bitmap); |
50 explicit CopyOutputResult(const gfx::Size& size, | 50 explicit CopyOutputResult(gfx::Size size, |
51 const TextureMailbox& texture_mailbox, | 51 const TextureMailbox& texture_mailbox, |
52 scoped_ptr<SingleReleaseCallback> release_callback); | 52 scoped_ptr<SingleReleaseCallback> release_callback); |
53 | 53 |
54 gfx::Size size_; | 54 gfx::Size size_; |
55 scoped_ptr<SkBitmap> bitmap_; | 55 scoped_ptr<SkBitmap> bitmap_; |
56 TextureMailbox texture_mailbox_; | 56 TextureMailbox texture_mailbox_; |
57 scoped_ptr<SingleReleaseCallback> release_callback_; | 57 scoped_ptr<SingleReleaseCallback> release_callback_; |
58 }; | 58 }; |
59 | 59 |
60 } // namespace cc | 60 } // namespace cc |
61 | 61 |
62 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_ | 62 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_ |
OLD | NEW |