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/single_release_callback.h"
12 #include "cc/resources/texture_mailbox.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
17 CopyOutputRequest::CopyOutputRequest() {}
19 CopyOutputRequest::CopyOutputRequest(
20 bool force_bitmap_result
,
21 const CopyOutputRequestCallback
& result_callback
)
22 : force_bitmap_result_(force_bitmap_result
),
24 result_callback_(result_callback
) {
27 CopyOutputRequest::~CopyOutputRequest() {
28 if (!result_callback_
.is_null())
29 SendResult(CopyOutputResult::CreateEmptyResult().Pass());
32 void CopyOutputRequest::SendResult(scoped_ptr
<CopyOutputResult
> result
) {
33 base::ResetAndReturn(&result_callback_
).Run(result
.Pass());
36 void CopyOutputRequest::SendEmptyResult() {
37 SendResult(CopyOutputResult::CreateEmptyResult().Pass());
40 void CopyOutputRequest::SendBitmapResult(scoped_ptr
<SkBitmap
> bitmap
) {
41 SendResult(CopyOutputResult::CreateBitmapResult(bitmap
.Pass()).Pass());
44 void CopyOutputRequest::SendTextureResult(
46 const TextureMailbox
& texture_mailbox
,
47 scoped_ptr
<SingleReleaseCallback
> release_callback
) {
48 DCHECK(texture_mailbox
.IsTexture());
49 SendResult(CopyOutputResult::CreateTextureResult(
50 size
, texture_mailbox
, release_callback
.Pass()));