diff options
Diffstat (limited to 'cc/output/copy_output_request.cc')
-rw-r--r-- | cc/output/copy_output_request.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/cc/output/copy_output_request.cc b/cc/output/copy_output_request.cc index 437cce5..90ece04 100644 --- a/cc/output/copy_output_request.cc +++ b/cc/output/copy_output_request.cc @@ -4,27 +4,42 @@ #include "cc/output/copy_output_request.h" +#include "base/bind.h" #include "base/callback_helpers.h" #include "base/logging.h" +#include "cc/output/copy_output_result.h" +#include "cc/resources/texture_mailbox.h" #include "third_party/skia/include/core/SkBitmap.h" namespace cc { -CopyOutputRequest::CopyOutputRequest(const CopyAsBitmapCallback& callback) - : bitmap_callback_(callback) {} +CopyOutputRequest::CopyOutputRequest() {} + +CopyOutputRequest::CopyOutputRequest( + bool force_bitmap_result, + const CopyOutputRequestCallback& result_callback) + : force_bitmap_result_(force_bitmap_result), + result_callback_(result_callback) { +} CopyOutputRequest::~CopyOutputRequest() { - SendEmptyResult(); + if (!result_callback_.is_null()) + SendResult(CopyOutputResult::CreateEmptyResult().Pass()); } -void CopyOutputRequest::SendEmptyResult() { - if (!bitmap_callback_.is_null()) - base::ResetAndReturn(&bitmap_callback_).Run(scoped_ptr<SkBitmap>()); +void CopyOutputRequest::SendResult(scoped_ptr<CopyOutputResult> result) { + base::ResetAndReturn(&result_callback_).Run(result.Pass()); } void CopyOutputRequest::SendBitmapResult(scoped_ptr<SkBitmap> bitmap) { - DCHECK(HasBitmapRequest()); - base::ResetAndReturn(&bitmap_callback_).Run(bitmap.Pass()); + SendResult(CopyOutputResult::CreateBitmapResult(bitmap.Pass()).Pass()); +} + +void CopyOutputRequest::SendTextureResult(gfx::Size size, + scoped_ptr<TextureMailbox> texture) { + DCHECK(texture->IsTexture()); + SendResult(CopyOutputResult::CreateTextureResult(size, + texture.Pass()).Pass()); } } // namespace cc |