OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "cc/proto/image_serialization_processor.h" | |
13 #include "third_party/skia/include/core/SkPicture.h" | |
14 | |
15 class SkPixelSerializer; | |
16 | |
17 namespace blimp { | |
18 | |
19 class BlobChannelReceiver; | |
20 | |
21 namespace client { | |
22 | |
23 // Adds BlobChannel image retrieval support to the Skia image decoding process. | |
24 class BlobImageSerializationProcessor : public cc::ImageSerializationProcessor { | |
25 public: | |
26 class ErrorDelegate { | |
27 public: | |
28 virtual void OnImageDecodeError() = 0; | |
29 }; | |
30 | |
31 static BlobImageSerializationProcessor* current(); | |
Wez
2016/06/10 22:29:54
nit: Brief comment to summarize that this returns
Kevin M
2016/06/10 23:51:50
Done. No threading constraints - this class is mea
| |
32 | |
33 BlobImageSerializationProcessor(); | |
34 virtual ~BlobImageSerializationProcessor(); | |
35 | |
36 // Sets the |blob_receiver| to use for reading images. | |
37 // |blob_receiver| must outlive |this|. | |
38 void set_blob_receiver(BlobChannelReceiver* blob_receiver) { | |
39 blob_receiver_ = blob_receiver; | |
40 } | |
41 | |
42 // |error_delegate| must outlive this. | |
43 void set_error_delegate(ErrorDelegate* error_delegate) { | |
44 error_delegate_ = error_delegate; | |
45 } | |
46 | |
47 // Retrieves a bitmap with ID |input| from |blob_receiver_| and decodes it | |
48 // to |bitmap|. | |
49 bool GetAndDecodeBlob(const void* input, size_t input_size, SkBitmap* bitmap); | |
50 | |
51 private: | |
52 friend struct base::DefaultSingletonTraits<BlobImageSerializationProcessor>; | |
53 | |
54 // Adapts a bare function pointer call to a singleton call to | |
55 // GetAndDecodeBlob(). | |
Wez
2016/06/10 22:29:54
nit: Suggest "to a GetAndDecodeBlob() call on the
Kevin M
2016/06/10 23:51:50
Done.
| |
56 static bool InstallPixelRefProc(const void* input, | |
57 size_t input_size, | |
58 SkBitmap* bitmap); | |
59 | |
60 // cc:ImageSerializationProcessor implementation. | |
61 SkPixelSerializer* GetPixelSerializer() override; | |
62 SkPicture::InstallPixelRefProc GetPixelDeserializer() override; | |
63 | |
64 // Interface for accessing stored images received over the Blob Channel. | |
65 BlobChannelReceiver* blob_receiver_ = nullptr; | |
66 | |
67 ErrorDelegate* error_delegate_ = nullptr; | |
68 | |
69 // Pointer is bound on object construction, and set to nullptr on object | |
70 // deletion. Only one BlobImageSerializationProcessor may live at a time. | |
Wez
2016/06/10 22:29:54
nit: "be live" would read more naturally that "liv
Kevin M
2016/06/10 23:51:50
I had to read that in my head a few times phonetic
| |
71 static BlobImageSerializationProcessor* current_instance_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(BlobImageSerializationProcessor); | |
74 }; | |
75 | |
76 } // namespace client | |
77 } // namespace blimp | |
78 | |
79 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
OLD | NEW |