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

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

Issue 2659703002: Implemented StructTraits for cc::CopyOutputResult (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_RESULT_H_ 5 #ifndef CC_OUTPUT_COPY_OUTPUT_RESULT_H_
6 #define CC_OUTPUT_COPY_OUTPUT_RESULT_H_ 6 #define CC_OUTPUT_COPY_OUTPUT_RESULT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/resources/single_release_callback.h" 12 #include "cc/resources/single_release_callback.h"
13 #include "cc/resources/texture_mailbox.h" 13 #include "cc/resources/texture_mailbox.h"
14 #include "mojo/public/cpp/bindings/struct_traits.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
15 17
16 class SkBitmap; 18 class SkBitmap;
17 19
18 namespace cc { 20 namespace cc {
21
22 namespace mojom {
23 class CopyOutputResultDataView;
24 }
25
19 class TextureMailbox; 26 class TextureMailbox;
20 27
21 class CC_EXPORT CopyOutputResult { 28 class CC_EXPORT CopyOutputResult {
22 public: 29 public:
23 static std::unique_ptr<CopyOutputResult> CreateEmptyResult() { 30 static std::unique_ptr<CopyOutputResult> CreateEmptyResult() {
24 return base::WrapUnique(new CopyOutputResult); 31 return base::WrapUnique(new CopyOutputResult);
25 } 32 }
26 static std::unique_ptr<CopyOutputResult> CreateBitmapResult( 33 static std::unique_ptr<CopyOutputResult> CreateBitmapResult(
27 std::unique_ptr<SkBitmap> bitmap) { 34 std::unique_ptr<SkBitmap> bitmap) {
28 return base::WrapUnique(new CopyOutputResult(std::move(bitmap))); 35 return base::WrapUnique(new CopyOutputResult(std::move(bitmap)));
29 } 36 }
30 static std::unique_ptr<CopyOutputResult> CreateTextureResult( 37 static std::unique_ptr<CopyOutputResult> CreateTextureResult(
31 const gfx::Size& size, 38 const gfx::Size& size,
32 const TextureMailbox& texture_mailbox, 39 const TextureMailbox& texture_mailbox,
33 std::unique_ptr<SingleReleaseCallback> release_callback) { 40 std::unique_ptr<SingleReleaseCallback> release_callback) {
34 return base::WrapUnique(new CopyOutputResult(size, texture_mailbox, 41 return base::WrapUnique(new CopyOutputResult(size, texture_mailbox,
35 std::move(release_callback))); 42 std::move(release_callback)));
36 } 43 }
37 44
45 CopyOutputResult();
38 ~CopyOutputResult(); 46 ~CopyOutputResult();
39 47
48 CopyOutputResult& operator=(CopyOutputResult&& other);
vmpstr 2017/01/31 21:32:19 Should this come with a corresponding move ctor?
Saman Sami 2017/02/01 15:51:57 Done.
49
40 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); } 50 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); }
41 bool HasBitmap() const { return !!bitmap_; } 51 bool HasBitmap() const { return !!bitmap_ && !bitmap_->isNull(); }
42 bool HasTexture() const { return texture_mailbox_.IsValid(); } 52 bool HasTexture() const { return texture_mailbox_.IsValid(); }
43 53
44 gfx::Size size() const { return size_; } 54 gfx::Size size() const { return size_; }
45 std::unique_ptr<SkBitmap> TakeBitmap(); 55 std::unique_ptr<SkBitmap> TakeBitmap();
46 void TakeTexture(TextureMailbox* texture_mailbox, 56 void TakeTexture(TextureMailbox* texture_mailbox,
47 std::unique_ptr<SingleReleaseCallback>* release_callback); 57 std::unique_ptr<SingleReleaseCallback>* release_callback);
48 58
49 private: 59 private:
50 CopyOutputResult(); 60 friend struct mojo::StructTraits<mojom::CopyOutputResultDataView,
61 CopyOutputResult>;
62
51 explicit CopyOutputResult(std::unique_ptr<SkBitmap> bitmap); 63 explicit CopyOutputResult(std::unique_ptr<SkBitmap> bitmap);
52 explicit CopyOutputResult( 64 explicit CopyOutputResult(
53 const gfx::Size& size, 65 const gfx::Size& size,
54 const TextureMailbox& texture_mailbox, 66 const TextureMailbox& texture_mailbox,
55 std::unique_ptr<SingleReleaseCallback> release_callback); 67 std::unique_ptr<SingleReleaseCallback> release_callback);
56 68
57 gfx::Size size_; 69 gfx::Size size_;
58 std::unique_ptr<SkBitmap> bitmap_; 70 std::unique_ptr<SkBitmap> bitmap_;
59 TextureMailbox texture_mailbox_; 71 TextureMailbox texture_mailbox_;
60 std::unique_ptr<SingleReleaseCallback> release_callback_; 72 std::unique_ptr<SingleReleaseCallback> release_callback_;
61 }; 73 };
62 74
63 } // namespace cc 75 } // namespace cc
64 76
65 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_ 77 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698