Home | History | Annotate | Download | only in output
      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.
      4 
      5 #include "cc/output/copy_output_request.h"
      6 
      7 #include "base/bind.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"
     13 
     14 namespace cc {
     15 
     16 CopyOutputRequest::CopyOutputRequest() {}
     17 
     18 CopyOutputRequest::CopyOutputRequest(
     19     bool force_bitmap_result,
     20     const CopyOutputRequestCallback& result_callback)
     21     : force_bitmap_result_(force_bitmap_result),
     22       has_area_(false),
     23       result_callback_(result_callback) {
     24 }
     25 
     26 CopyOutputRequest::~CopyOutputRequest() {
     27   if (!result_callback_.is_null())
     28     SendResult(CopyOutputResult::CreateEmptyResult().Pass());
     29 }
     30 
     31 void CopyOutputRequest::SendResult(scoped_ptr<CopyOutputResult> result) {
     32   base::ResetAndReturn(&result_callback_).Run(result.Pass());
     33 }
     34 
     35 void CopyOutputRequest::SendEmptyResult() {
     36   SendResult(CopyOutputResult::CreateEmptyResult().Pass());
     37 }
     38 
     39 void CopyOutputRequest::SendBitmapResult(scoped_ptr<SkBitmap> bitmap) {
     40   SendResult(CopyOutputResult::CreateBitmapResult(bitmap.Pass()).Pass());
     41 }
     42 
     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());
     48 }
     49 
     50 }  // namespace cc
     51