| OLD | NEW |
| (Empty) |
| 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_REQUEST_H_ | |
| 6 #define CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "cc/resources/single_release_callback.h" | |
| 11 #include "cc/resources/texture_mailbox.h" | |
| 12 #include "ui/gfx/geometry/rect.h" | |
| 13 | |
| 14 class SkBitmap; | |
| 15 | |
| 16 namespace cc { | |
| 17 class CopyOutputResult; | |
| 18 | |
| 19 class CopyOutputRequest { | |
| 20 public: | |
| 21 typedef base::Callback<void(scoped_ptr<CopyOutputResult> result)> | |
| 22 CopyOutputRequestCallback; | |
| 23 | |
| 24 static scoped_ptr<CopyOutputRequest> CreateEmptyRequest() { | |
| 25 return make_scoped_ptr(new CopyOutputRequest); | |
| 26 } | |
| 27 static scoped_ptr<CopyOutputRequest> CreateRequest( | |
| 28 const CopyOutputRequestCallback& result_callback) { | |
| 29 return make_scoped_ptr(new CopyOutputRequest(false, result_callback)); | |
| 30 } | |
| 31 static scoped_ptr<CopyOutputRequest> CreateBitmapRequest( | |
| 32 const CopyOutputRequestCallback& result_callback) { | |
| 33 return make_scoped_ptr(new CopyOutputRequest(true, result_callback)); | |
| 34 } | |
| 35 static scoped_ptr<CopyOutputRequest> CreateRelayRequest( | |
| 36 const CopyOutputRequest& original_request, | |
| 37 const CopyOutputRequestCallback& result_callback); | |
| 38 | |
| 39 ~CopyOutputRequest(); | |
| 40 | |
| 41 bool IsEmpty() const { return result_callback_.is_null(); } | |
| 42 | |
| 43 bool force_bitmap_result() const { return force_bitmap_result_; } | |
| 44 | |
| 45 // By default copy requests copy the entire layer's subtree output. If an | |
| 46 // area is given, then the intersection of this rect (in layer space) with | |
| 47 // the layer's subtree output will be returned. | |
| 48 void set_area(const gfx::Rect& area) { | |
| 49 has_area_ = true; | |
| 50 area_ = area; | |
| 51 } | |
| 52 bool has_area() const { return has_area_; } | |
| 53 gfx::Rect area() const { return area_; } | |
| 54 | |
| 55 // By default copy requests create a new TextureMailbox to return contents | |
| 56 // in. This allows a client to provide a TextureMailbox, and the compositor | |
| 57 // will place the result inside the TextureMailbox. | |
| 58 void SetTextureMailbox(const TextureMailbox& texture_mailbox); | |
| 59 bool has_texture_mailbox() const { return has_texture_mailbox_; } | |
| 60 const TextureMailbox& texture_mailbox() const { return texture_mailbox_; } | |
| 61 | |
| 62 void SendEmptyResult(); | |
| 63 void SendBitmapResult(scoped_ptr<SkBitmap> bitmap); | |
| 64 void SendTextureResult(const gfx::Size& size, | |
| 65 const TextureMailbox& texture_mailbox, | |
| 66 scoped_ptr<SingleReleaseCallback> release_callback); | |
| 67 | |
| 68 void SendResult(scoped_ptr<CopyOutputResult> result); | |
| 69 | |
| 70 private: | |
| 71 CopyOutputRequest(); | |
| 72 CopyOutputRequest(bool force_bitmap_result, | |
| 73 const CopyOutputRequestCallback& result_callback); | |
| 74 | |
| 75 bool force_bitmap_result_; | |
| 76 bool has_area_; | |
| 77 bool has_texture_mailbox_; | |
| 78 gfx::Rect area_; | |
| 79 TextureMailbox texture_mailbox_; | |
| 80 CopyOutputRequestCallback result_callback_; | |
| 81 }; | |
| 82 | |
| 83 } // namespace cc | |
| 84 | |
| 85 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ | |
| OLD | NEW |