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

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
« no previous file with comments | « cc/output/DEPS ('k') | cc/output/copy_output_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/optional.h"
13 #include "base/unguessable_token.h" 13 #include "base/unguessable_token.h"
14 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
15 #include "cc/resources/single_release_callback.h" 15 #include "cc/resources/single_release_callback.h"
16 #include "cc/resources/texture_mailbox.h" 16 #include "cc/resources/texture_mailbox.h"
17 #include "mojo/public/cpp/bindings/struct_traits.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
18 19
19 class SkBitmap; 20 class SkBitmap;
20 21
21 namespace cc { 22 namespace cc {
23
24 namespace mojom {
25 class CopyOutputRequestDataView;
26 }
27
22 class CopyOutputResult; 28 class CopyOutputResult;
23 29
24 class CC_EXPORT CopyOutputRequest { 30 class CC_EXPORT CopyOutputRequest {
25 public: 31 public:
26 typedef base::Callback<void(std::unique_ptr<CopyOutputResult> result)> 32 typedef base::Callback<void(std::unique_ptr<CopyOutputResult> result)>
27 CopyOutputRequestCallback; 33 CopyOutputRequestCallback;
28 34
29 static std::unique_ptr<CopyOutputRequest> CreateEmptyRequest() { 35 static std::unique_ptr<CopyOutputRequest> CreateEmptyRequest() {
30 return base::WrapUnique(new CopyOutputRequest); 36 return base::WrapUnique(new CopyOutputRequest);
31 } 37 }
32 static std::unique_ptr<CopyOutputRequest> CreateRequest( 38 static std::unique_ptr<CopyOutputRequest> CreateRequest(
33 const CopyOutputRequestCallback& result_callback) { 39 const CopyOutputRequestCallback& result_callback) {
34 return base::WrapUnique(new CopyOutputRequest(false, result_callback)); 40 return base::WrapUnique(new CopyOutputRequest(false, result_callback));
35 } 41 }
36 static std::unique_ptr<CopyOutputRequest> CreateBitmapRequest( 42 static std::unique_ptr<CopyOutputRequest> CreateBitmapRequest(
37 const CopyOutputRequestCallback& result_callback) { 43 const CopyOutputRequestCallback& result_callback) {
38 return base::WrapUnique(new CopyOutputRequest(true, result_callback)); 44 return base::WrapUnique(new CopyOutputRequest(true, result_callback));
39 } 45 }
40 static std::unique_ptr<CopyOutputRequest> CreateRelayRequest( 46 static std::unique_ptr<CopyOutputRequest> CreateRelayRequest(
41 const CopyOutputRequest& original_request, 47 const CopyOutputRequest& original_request,
42 const CopyOutputRequestCallback& result_callback); 48 const CopyOutputRequestCallback& result_callback);
43 49
50 CopyOutputRequest();
51
44 ~CopyOutputRequest(); 52 ~CopyOutputRequest();
45 53
46 bool IsEmpty() const { return result_callback_.is_null(); } 54 bool IsEmpty() const { return result_callback_.is_null(); }
47 55
48 // Optionally specify the source of this copy request. If set when this copy 56 // Optionally specify the source of this copy request. If set when this copy
49 // request is submitted to a layer, a prior uncommitted copy request from the 57 // request is submitted to a layer, a prior uncommitted copy request from the
50 // same source will be aborted. 58 // same source will be aborted.
51 void set_source(const base::UnguessableToken& source) { source_ = source; } 59 void set_source(const base::UnguessableToken& source) { source_ = source; }
52 bool has_source() const { return source_.has_value(); } 60 bool has_source() const { return source_.has_value(); }
53 const base::UnguessableToken& source() const { return *source_; } 61 const base::UnguessableToken& source() const { return *source_; }
54 62
55 bool force_bitmap_result() const { return force_bitmap_result_; } 63 bool force_bitmap_result() const { return force_bitmap_result_; }
56 64
57 // By default copy requests copy the entire layer's subtree output. If an 65 // By default copy requests copy the entire layer's subtree output. If an
58 // area is given, then the intersection of this rect (in layer space) with 66 // area is given, then the intersection of this rect (in layer space) with
59 // the layer's subtree output will be returned. 67 // the layer's subtree output will be returned.
60 void set_area(const gfx::Rect& area) { 68 void set_area(const gfx::Rect& area) { area_ = area; }
61 has_area_ = true; 69 bool has_area() const { return area_.has_value(); }
62 area_ = area; 70 const gfx::Rect& area() const { return *area_; }
63 }
64 bool has_area() const { return has_area_; }
65 gfx::Rect area() const { return area_; }
66 71
67 // By default copy requests create a new TextureMailbox to return contents 72 // By default copy requests create a new TextureMailbox to return contents
68 // in. This allows a client to provide a TextureMailbox, and the compositor 73 // in. This allows a client to provide a TextureMailbox, and the compositor
69 // will place the result inside the TextureMailbox. 74 // will place the result inside the TextureMailbox.
70 void SetTextureMailbox(const TextureMailbox& texture_mailbox); 75 void SetTextureMailbox(const TextureMailbox& texture_mailbox);
71 bool has_texture_mailbox() const { return has_texture_mailbox_; } 76 bool has_texture_mailbox() const { return texture_mailbox_.has_value(); }
72 const TextureMailbox& texture_mailbox() const { return texture_mailbox_; } 77 const TextureMailbox& texture_mailbox() const { return *texture_mailbox_; }
73 78
74 void SendEmptyResult(); 79 void SendEmptyResult();
75 void SendBitmapResult(std::unique_ptr<SkBitmap> bitmap); 80 void SendBitmapResult(std::unique_ptr<SkBitmap> bitmap);
76 void SendTextureResult( 81 void SendTextureResult(
77 const gfx::Size& size, 82 const gfx::Size& size,
78 const TextureMailbox& texture_mailbox, 83 const TextureMailbox& texture_mailbox,
79 std::unique_ptr<SingleReleaseCallback> release_callback); 84 std::unique_ptr<SingleReleaseCallback> release_callback);
80 85
81 void SendResult(std::unique_ptr<CopyOutputResult> result); 86 void SendResult(std::unique_ptr<CopyOutputResult> result);
82 87
83 private: 88 private:
84 CopyOutputRequest(); 89 friend struct mojo::StructTraits<mojom::CopyOutputRequestDataView,
90 CopyOutputRequest>;
91
85 CopyOutputRequest(bool force_bitmap_result, 92 CopyOutputRequest(bool force_bitmap_result,
86 const CopyOutputRequestCallback& result_callback); 93 const CopyOutputRequestCallback& result_callback);
87 94
88 base::Optional<base::UnguessableToken> source_; 95 base::Optional<base::UnguessableToken> source_;
89 bool force_bitmap_result_; 96 bool force_bitmap_result_;
90 bool has_area_; 97 base::Optional<gfx::Rect> area_;
91 bool has_texture_mailbox_; 98 base::Optional<TextureMailbox> texture_mailbox_;
92 gfx::Rect area_;
93 TextureMailbox texture_mailbox_;
94 CopyOutputRequestCallback result_callback_; 99 CopyOutputRequestCallback result_callback_;
95 }; 100 };
96 101
97 } // namespace cc 102 } // namespace cc
98 103
99 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_ 104 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_
OLDNEW
« no previous file with comments | « cc/output/DEPS ('k') | cc/output/copy_output_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698