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