| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ | 5 #ifndef CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ |
| 6 #define CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ | 6 #define CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/rect.h" |
| 12 | 12 |
| 13 class SkBitmap; | 13 class SkBitmap; |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 class CopyOutputResult; | 16 class CopyOutputResult; |
| 17 class TextureMailbox; | 17 class TextureMailbox; |
| 18 | 18 |
| 19 class CC_EXPORT CopyOutputRequest { | 19 class CC_EXPORT CopyOutputRequest { |
| 20 public: | 20 public: |
| 21 typedef base::Callback<void(scoped_ptr<CopyOutputResult> result)> | 21 typedef base::Callback<void(scoped_ptr<CopyOutputResult> result)> |
| 22 CopyOutputRequestCallback; | 22 CopyOutputRequestCallback; |
| 23 | 23 |
| 24 static scoped_ptr<CopyOutputRequest> CreateEmptyRequest() { | 24 static scoped_ptr<CopyOutputRequest> CreateEmptyRequest() { |
| 25 return make_scoped_ptr(new CopyOutputRequest); | 25 return make_scoped_ptr(new CopyOutputRequest); |
| 26 } | 26 } |
| 27 static scoped_ptr<CopyOutputRequest> CreateRequest( | 27 static scoped_ptr<CopyOutputRequest> CreateRequest( |
| 28 const CopyOutputRequestCallback& result_callback) { | 28 const CopyOutputRequestCallback& result_callback) { |
| 29 return make_scoped_ptr(new CopyOutputRequest(false, result_callback)); | 29 return make_scoped_ptr(new CopyOutputRequest(false, result_callback)); |
| 30 } | 30 } |
| 31 static scoped_ptr<CopyOutputRequest> CreateBitmapRequest( | 31 static scoped_ptr<CopyOutputRequest> CreateBitmapRequest( |
| 32 const CopyOutputRequestCallback& result_callback) { | 32 const CopyOutputRequestCallback& result_callback) { |
| 33 return make_scoped_ptr(new CopyOutputRequest(true, result_callback)); | 33 return make_scoped_ptr(new CopyOutputRequest(true, result_callback)); |
| 34 } | 34 } |
| 35 static scoped_ptr<CopyOutputRequest> CreateRelayRequest( | 35 static scoped_ptr<CopyOutputRequest> CreateRelayRequest( |
| 36 const CopyOutputRequest& original_request, | 36 const CopyOutputRequest& original_request, |
| 37 const CopyOutputRequestCallback& result_callback) { | 37 const CopyOutputRequestCallback& result_callback) { |
| 38 return make_scoped_ptr(new CopyOutputRequest( | 38 scoped_ptr<CopyOutputRequest> relay = CreateRequest(result_callback); |
| 39 original_request.force_bitmap_result(), result_callback)); | 39 relay->force_bitmap_result_ = original_request.force_bitmap_result_; |
| 40 relay->has_area_ = original_request.has_area_; |
| 41 relay->area_ = original_request.area_; |
| 42 return relay.Pass(); |
| 40 } | 43 } |
| 41 | 44 |
| 42 ~CopyOutputRequest(); | 45 ~CopyOutputRequest(); |
| 43 | 46 |
| 44 bool IsEmpty() const { return result_callback_.is_null(); } | 47 bool IsEmpty() const { return result_callback_.is_null(); } |
| 48 |
| 45 bool force_bitmap_result() const { return force_bitmap_result_; } | 49 bool force_bitmap_result() const { return force_bitmap_result_; } |
| 46 | 50 |
| 51 // By default copy requests copy the entire layer's subtree output. If an |
| 52 // area is given, then the intersection of this rect (in layer space) with |
| 53 // the layer's subtree output will be returned. |
| 54 void set_area(gfx::Rect area) { |
| 55 has_area_ = true; |
| 56 area_ = area; |
| 57 } |
| 58 bool has_area() const { return has_area_; } |
| 59 gfx::Rect area() const { return area_; } |
| 60 |
| 47 void SendResult(scoped_ptr<CopyOutputResult> result); | 61 void SendResult(scoped_ptr<CopyOutputResult> result); |
| 48 void SendBitmapResult(scoped_ptr<SkBitmap> bitmap); | 62 void SendBitmapResult(scoped_ptr<SkBitmap> bitmap); |
| 49 void SendTextureResult(gfx::Size size, | 63 void SendTextureResult(gfx::Size size, |
| 50 scoped_ptr<TextureMailbox> texture_mailbox); | 64 scoped_ptr<TextureMailbox> texture_mailbox); |
| 51 | 65 |
| 52 bool Equals(const CopyOutputRequest& other) const { | 66 bool Equals(const CopyOutputRequest& other) const { |
| 53 return result_callback_.Equals(other.result_callback_) && | 67 return result_callback_.Equals(other.result_callback_) && |
| 54 force_bitmap_result_ == other.force_bitmap_result_; | 68 force_bitmap_result_ == other.force_bitmap_result_; |
| 55 } | 69 } |
| 56 | 70 |
| 57 private: | 71 private: |
| 58 CopyOutputRequest(); | 72 CopyOutputRequest(); |
| 59 explicit CopyOutputRequest(bool force_bitmap_result, | 73 explicit CopyOutputRequest(bool force_bitmap_result, |
| 60 const CopyOutputRequestCallback& result_callback); | 74 const CopyOutputRequestCallback& result_callback); |
| 61 | 75 |
| 62 bool force_bitmap_result_; | 76 bool force_bitmap_result_; |
| 77 bool has_area_; |
| 78 gfx::Rect area_; |
| 63 CopyOutputRequestCallback result_callback_; | 79 CopyOutputRequestCallback result_callback_; |
| 64 }; | 80 }; |
| 65 | 81 |
| 66 } // namespace cc | 82 } // namespace cc |
| 67 | 83 |
| 68 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ | 84 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ |
| OLD | NEW |