Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: cc/output/copy_output_request.h

Issue 2655963006: Implemented StructTraits for cc::CopyOutputRequest (Closed)
Patch Set: c Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/optional.h"
12 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
13 #include "cc/resources/single_release_callback.h" 14 #include "cc/resources/single_release_callback.h"
14 #include "cc/resources/texture_mailbox.h" 15 #include "cc/resources/texture_mailbox.h"
16 #include "mojo/public/cpp/bindings/struct_traits.h"
15 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
16 18
17 class SkBitmap; 19 class SkBitmap;
18 20
19 namespace cc { 21 namespace cc {
22
23 namespace mojom {
24 class CopyOutputRequestDataView;
25 }
26
20 class CopyOutputResult; 27 class CopyOutputResult;
21 28
22 class CC_EXPORT CopyOutputRequest { 29 class CC_EXPORT CopyOutputRequest {
23 public: 30 public:
24 typedef base::Callback<void(std::unique_ptr<CopyOutputResult> result)> 31 typedef base::Callback<void(std::unique_ptr<CopyOutputResult> result)>
25 CopyOutputRequestCallback; 32 CopyOutputRequestCallback;
26 33
27 static std::unique_ptr<CopyOutputRequest> CreateEmptyRequest() { 34 static std::unique_ptr<CopyOutputRequest> CreateEmptyRequest() {
28 return base::WrapUnique(new CopyOutputRequest); 35 return base::WrapUnique(new CopyOutputRequest);
29 } 36 }
30 static std::unique_ptr<CopyOutputRequest> CreateRequest( 37 static std::unique_ptr<CopyOutputRequest> CreateRequest(
31 const CopyOutputRequestCallback& result_callback) { 38 const CopyOutputRequestCallback& result_callback) {
32 return base::WrapUnique(new CopyOutputRequest(false, result_callback)); 39 return base::WrapUnique(new CopyOutputRequest(false, result_callback));
33 } 40 }
34 static std::unique_ptr<CopyOutputRequest> CreateBitmapRequest( 41 static std::unique_ptr<CopyOutputRequest> CreateBitmapRequest(
35 const CopyOutputRequestCallback& result_callback) { 42 const CopyOutputRequestCallback& result_callback) {
36 return base::WrapUnique(new CopyOutputRequest(true, result_callback)); 43 return base::WrapUnique(new CopyOutputRequest(true, result_callback));
37 } 44 }
38 static std::unique_ptr<CopyOutputRequest> CreateRelayRequest( 45 static std::unique_ptr<CopyOutputRequest> CreateRelayRequest(
39 const CopyOutputRequest& original_request, 46 const CopyOutputRequest& original_request,
40 const CopyOutputRequestCallback& result_callback); 47 const CopyOutputRequestCallback& result_callback);
41 48
49 CopyOutputRequest();
50
42 ~CopyOutputRequest(); 51 ~CopyOutputRequest();
43 52
44 bool IsEmpty() const { return result_callback_.is_null(); } 53 bool IsEmpty() const { return result_callback_.is_null(); }
45 54
46 // Optionally specify the source of this copy request. If set when this copy 55 // Optionally specify the source of this copy request. If set when this copy
47 // request is submitted to a layer, a prior uncommitted copy request from the 56 // request is submitted to a layer, a prior uncommitted copy request from the
48 // same |source| will be aborted. 57 // same |source| will be aborted.
49 void set_source(void* source) { source_ = source; } 58 void set_source(void* source) { source_ = source; }
50 void* source() const { return source_; } 59 void* source() const { return source_; }
51 60
52 bool force_bitmap_result() const { return force_bitmap_result_; } 61 bool force_bitmap_result() const { return force_bitmap_result_; }
53 62
54 // By default copy requests copy the entire layer's subtree output. If an 63 // By default copy requests copy the entire layer's subtree output. If an
55 // area is given, then the intersection of this rect (in layer space) with 64 // area is given, then the intersection of this rect (in layer space) with
56 // the layer's subtree output will be returned. 65 // the layer's subtree output will be returned.
57 void set_area(const gfx::Rect& area) { 66 void set_area(const gfx::Rect& area) { area_ = area; }
58 has_area_ = true; 67 bool has_area() const { return area_.has_value(); }
59 area_ = area; 68 const gfx::Rect& area() const { return *area_; }
60 }
61 bool has_area() const { return has_area_; }
62 gfx::Rect area() const { return area_; }
63 69
64 // By default copy requests create a new TextureMailbox to return contents 70 // By default copy requests create a new TextureMailbox to return contents
65 // in. This allows a client to provide a TextureMailbox, and the compositor 71 // in. This allows a client to provide a TextureMailbox, and the compositor
66 // will place the result inside the TextureMailbox. 72 // will place the result inside the TextureMailbox.
67 void SetTextureMailbox(const TextureMailbox& texture_mailbox); 73 void SetTextureMailbox(const TextureMailbox& texture_mailbox);
68 bool has_texture_mailbox() const { return has_texture_mailbox_; } 74 bool has_texture_mailbox() const { return texture_mailbox_.has_value(); }
69 const TextureMailbox& texture_mailbox() const { return texture_mailbox_; } 75 const TextureMailbox& texture_mailbox() const { return *texture_mailbox_; }
70 76
71 void SendEmptyResult(); 77 void SendEmptyResult();
72 void SendBitmapResult(std::unique_ptr<SkBitmap> bitmap); 78 void SendBitmapResult(std::unique_ptr<SkBitmap> bitmap);
73 void SendTextureResult( 79 void SendTextureResult(
74 const gfx::Size& size, 80 const gfx::Size& size,
75 const TextureMailbox& texture_mailbox, 81 const TextureMailbox& texture_mailbox,
76 std::unique_ptr<SingleReleaseCallback> release_callback); 82 std::unique_ptr<SingleReleaseCallback> release_callback);
77 83
78 void SendResult(std::unique_ptr<CopyOutputResult> result); 84 void SendResult(std::unique_ptr<CopyOutputResult> result);
79 85
80 private: 86 private:
81 CopyOutputRequest(); 87 friend struct mojo::StructTraits<mojom::CopyOutputRequestDataView,
88 CopyOutputRequest>;
89
82 CopyOutputRequest(bool force_bitmap_result, 90 CopyOutputRequest(bool force_bitmap_result,
83 const CopyOutputRequestCallback& result_callback); 91 const CopyOutputRequestCallback& result_callback);
84 92
85 void* source_; 93 void* source_;
86 bool force_bitmap_result_; 94 bool force_bitmap_result_;
87 bool has_area_; 95 base::Optional<gfx::Rect> area_;
88 bool has_texture_mailbox_; 96 base::Optional<TextureMailbox> texture_mailbox_;
89 gfx::Rect area_;
90 TextureMailbox texture_mailbox_;
91 CopyOutputRequestCallback result_callback_; 97 CopyOutputRequestCallback result_callback_;
92 }; 98 };
93 99
94 } // namespace cc 100 } // namespace cc
95 101
96 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ 102 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698