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 #include "cc/output/copy_output_result.h" | 5 #include "cc/output/copy_output_result.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/resources/single_release_callback.h" |
8 #include "cc/resources/texture_mailbox.h" | 9 #include "cc/resources/texture_mailbox.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 CopyOutputResult::CopyOutputResult() {} | 14 CopyOutputResult::CopyOutputResult() {} |
14 | 15 |
15 CopyOutputResult::CopyOutputResult(scoped_ptr<SkBitmap> bitmap) | 16 CopyOutputResult::CopyOutputResult(scoped_ptr<SkBitmap> bitmap) |
16 : size_(bitmap->width(), bitmap->height()), | 17 : size_(bitmap->width(), bitmap->height()), |
17 bitmap_(bitmap.Pass()) { | 18 bitmap_(bitmap.Pass()) { |
18 DCHECK(bitmap_); | 19 DCHECK(bitmap_); |
19 } | 20 } |
20 | 21 |
21 CopyOutputResult::CopyOutputResult(gfx::Size size, | 22 CopyOutputResult::CopyOutputResult( |
22 scoped_ptr<TextureMailbox> texture_mailbox) | 23 gfx::Size size, |
| 24 const TextureMailbox& texture_mailbox, |
| 25 scoped_ptr<SingleReleaseCallback> release_callback) |
23 : size_(size), | 26 : size_(size), |
24 texture_mailbox_(texture_mailbox.Pass()) { | 27 texture_mailbox_(texture_mailbox), |
25 DCHECK(texture_mailbox_); | 28 release_callback_(release_callback.Pass()) { |
26 DCHECK(texture_mailbox_->IsTexture()); | 29 DCHECK(texture_mailbox_.IsTexture()); |
27 } | 30 } |
28 | 31 |
29 CopyOutputResult::~CopyOutputResult() { | 32 CopyOutputResult::~CopyOutputResult() { |
30 if (texture_mailbox_) | 33 if (release_callback_) |
31 texture_mailbox_->RunReleaseCallback(0, false); | 34 release_callback_->Run(0, false); |
32 } | 35 } |
33 | 36 |
34 scoped_ptr<SkBitmap> CopyOutputResult::TakeBitmap() { | 37 scoped_ptr<SkBitmap> CopyOutputResult::TakeBitmap() { |
35 return bitmap_.Pass(); | 38 return bitmap_.Pass(); |
36 } | 39 } |
37 | 40 |
38 scoped_ptr<TextureMailbox> CopyOutputResult::TakeTexture() { | 41 void CopyOutputResult::TakeTexture( |
39 return texture_mailbox_.Pass(); | 42 TextureMailbox* texture_mailbox, |
| 43 scoped_ptr<SingleReleaseCallback>* release_callback) { |
| 44 *texture_mailbox = texture_mailbox_; |
| 45 *release_callback = release_callback_.Pass(); |
| 46 |
| 47 texture_mailbox_ = TextureMailbox(); |
40 } | 48 } |
41 | 49 |
42 } // namespace cc | 50 } // namespace cc |
OLD | NEW |