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

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
« no previous file with comments | « cc/ipc/typemaps.gni ('k') | cc/output/copy_output_result.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_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();
46
47 CopyOutputResult(CopyOutputResult&& other);
48
38 ~CopyOutputResult(); 49 ~CopyOutputResult();
39 50
51 CopyOutputResult& operator=(CopyOutputResult&& other);
52
40 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); } 53 bool IsEmpty() const { return !HasBitmap() && !HasTexture(); }
41 bool HasBitmap() const { return !!bitmap_; } 54 bool HasBitmap() const { return !!bitmap_ && !bitmap_->isNull(); }
42 bool HasTexture() const { return texture_mailbox_.IsValid(); } 55 bool HasTexture() const { return texture_mailbox_.IsValid(); }
43 56
44 gfx::Size size() const { return size_; } 57 gfx::Size size() const { return size_; }
45 std::unique_ptr<SkBitmap> TakeBitmap(); 58 std::unique_ptr<SkBitmap> TakeBitmap();
46 void TakeTexture(TextureMailbox* texture_mailbox, 59 void TakeTexture(TextureMailbox* texture_mailbox,
47 std::unique_ptr<SingleReleaseCallback>* release_callback); 60 std::unique_ptr<SingleReleaseCallback>* release_callback);
48 61
49 private: 62 private:
50 CopyOutputResult(); 63 friend struct mojo::StructTraits<mojom::CopyOutputResultDataView,
64 CopyOutputResult>;
65
51 explicit CopyOutputResult(std::unique_ptr<SkBitmap> bitmap); 66 explicit CopyOutputResult(std::unique_ptr<SkBitmap> bitmap);
52 explicit CopyOutputResult( 67 explicit CopyOutputResult(
53 const gfx::Size& size, 68 const gfx::Size& size,
54 const TextureMailbox& texture_mailbox, 69 const TextureMailbox& texture_mailbox,
55 std::unique_ptr<SingleReleaseCallback> release_callback); 70 std::unique_ptr<SingleReleaseCallback> release_callback);
56 71
57 gfx::Size size_; 72 gfx::Size size_;
58 std::unique_ptr<SkBitmap> bitmap_; 73 std::unique_ptr<SkBitmap> bitmap_;
59 TextureMailbox texture_mailbox_; 74 TextureMailbox texture_mailbox_;
60 std::unique_ptr<SingleReleaseCallback> release_callback_; 75 std::unique_ptr<SingleReleaseCallback> release_callback_;
61 }; 76 };
62 77
63 } // namespace cc 78 } // namespace cc
64 79
65 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_ 80 #endif // CC_OUTPUT_COPY_OUTPUT_RESULT_H_
OLDNEW
« no previous file with comments | « cc/ipc/typemaps.gni ('k') | cc/output/copy_output_result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698