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 #ifndef CC_OUTPUT_COPY_OUTPUT_RESULT_H_
      6 #define CC_OUTPUT_COPY_OUTPUT_RESULT_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "cc/base/cc_export.h"
     10 #include "ui/gfx/size.h"
     11 
     12 class SkBitmap;
     13 
     14 namespace cc {
     15 class TextureMailbox;
     16 
     17 class CC_EXPORT CopyOutputResult {
     18  public:
     19   static scoped_ptr<CopyOutputResult> CreateEmptyResult() {
     20     return make_scoped_ptr(new CopyOutputResult);
     21   }
     22   static scoped_ptr<CopyOutputResult> CreateBitmapResult(
     23       scoped_ptr<SkBitmap> bitmap) {
     24     return make_scoped_ptr(new CopyOutputResult(bitmap.Pass()));
     25   }
     26   static scoped_ptr<CopyOutputResult> CreateTextureResult(
     27       gfx::Size size,
     28       scoped_ptr<TextureMailbox> texture_mailbox) {
     29     return make_scoped_ptr(new CopyOutputResult(size, texture_mailbox.Pass()));
     30   }
     31 
     32   ~CopyOutputResult();
     33 
     34   bool IsEmpty() const { return !HasBitmap() && !HasTexture(); }
     35   bool HasBitmap() const { return !!bitmap_; }
     36   bool HasTexture() const { return !!texture_mailbox_; }
     37 
     38   gfx::Size size() const { return size_; }
     39   scoped_ptr<SkBitmap> TakeBitmap();
     40   scoped_ptr<TextureMailbox> TakeTexture();
     41 
     42  private:
     43   CopyOutputResult();
     44   explicit CopyOutputResult(scoped_ptr<SkBitmap> bitmap);
     45   explicit CopyOutputResult(gfx::Size size,
     46                             scoped_ptr<TextureMailbox> texture_mailbox);
     47 
     48   gfx::Size size_;
     49   scoped_ptr<SkBitmap> bitmap_;
     50   scoped_ptr<TextureMailbox> texture_mailbox_;
     51 };
     52 
     53 }  // namespace cc
     54 
     55 #endif  // CC_OUTPUT_COPY_OUTPUT_RESULT_H_
     56