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

Side by Side Diff: blimp/client/feature/compositor/blob_image_serialization_processor.h

Issue 1985863002: Incorporate BlobChannel into Blimp image encode/decode pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-helium
Patch Set: fix gn dependency warning & rebase Created 4 years, 6 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
(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 // Returns the BlobImageSerializationProcessor* instance that is active
32 // for the current process.
33 static BlobImageSerializationProcessor* current();
34
35 BlobImageSerializationProcessor();
36 virtual ~BlobImageSerializationProcessor();
37
38 // Sets the |blob_receiver| to use for reading images.
39 // |blob_receiver| must outlive |this|.
40 void set_blob_receiver(BlobChannelReceiver* blob_receiver) {
41 blob_receiver_ = blob_receiver;
42 }
43
44 // |error_delegate| must outlive this.
45 void set_error_delegate(ErrorDelegate* error_delegate) {
46 error_delegate_ = error_delegate;
47 }
48
49 // Retrieves a bitmap with ID |input| from |blob_receiver_| and decodes it
50 // to |bitmap|.
51 bool GetAndDecodeBlob(const void* input,
52 size_t input_size,
53 SkBitmap* bitmap) const;
54
55 private:
56 friend struct base::DefaultSingletonTraits<BlobImageSerializationProcessor>;
57
58 // Adapts a bare function pointer call to a singleton call to
59 // GetAndDecodeBlob() call on the current() processor.
60 static bool InstallPixelRefProc(const void* input,
61 size_t input_size,
62 SkBitmap* bitmap);
63
64 // cc:ImageSerializationProcessor implementation.
65 SkPixelSerializer* GetPixelSerializer() override;
66 SkPicture::InstallPixelRefProc GetPixelDeserializer() override;
67
68 // Interface for accessing stored images received over the Blob Channel.
69 BlobChannelReceiver* blob_receiver_ = nullptr;
70
71 ErrorDelegate* error_delegate_ = nullptr;
72
73 // Pointer is bound on object construction, and set to nullptr on object
74 // deletion. Only one BlobImageSerializationProcessor may be live at a time.
75 static BlobImageSerializationProcessor* current_instance_;
76
77 DISALLOW_COPY_AND_ASSIGN(BlobImageSerializationProcessor);
78 };
79
80 } // namespace client
81 } // namespace blimp
82
83 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698