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
3 // found in the LICENSE file.
5 #include "cc/output/copy_output_request.h"
8 #include "base/callback_helpers.h"
9 #include "base/logging.h"
10 #include "cc/output/copy_output_result.h"
11 #include "cc/resources/texture_mailbox.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
16 CopyOutputRequest::CopyOutputRequest() {}
18 CopyOutputRequest::CopyOutputRequest(
19 bool force_bitmap_result
,
20 const CopyOutputRequestCallback
& result_callback
)
21 : force_bitmap_result_(force_bitmap_result
),
23 result_callback_(result_callback
) {
26 CopyOutputRequest::~CopyOutputRequest() {
27 if (!result_callback_
.is_null())
28 SendResult(CopyOutputResult::CreateEmptyResult().Pass());
31 void CopyOutputRequest::SendResult(scoped_ptr
<CopyOutputResult
> result
) {
32 base::ResetAndReturn(&result_callback_
).Run(result
.Pass());
35 void CopyOutputRequest::SendEmptyResult() {
36 SendResult(CopyOutputResult::CreateEmptyResult().Pass());
39 void CopyOutputRequest::SendBitmapResult(scoped_ptr
<SkBitmap
> bitmap
) {
40 SendResult(CopyOutputResult::CreateBitmapResult(bitmap
.Pass()).Pass());
43 void CopyOutputRequest::SendTextureResult(gfx::Size size
,
44 scoped_ptr
<TextureMailbox
> texture
) {
45 DCHECK(texture
->IsTexture());
46 SendResult(CopyOutputResult::CreateTextureResult(size
,
47 texture
.Pass()).Pass());