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

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

Issue 2160363002: Move ImageSerializationProcessor code to blimp/client/core (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split-blimp-client-core
Patch Set: fix public_deps for //blimp/test Created 4 years, 5 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/blimp/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 // in addition to providing a cache for Skia images.
25 class BlobImageSerializationProcessor : public cc::ImageSerializationProcessor {
26 public:
27 class ErrorDelegate {
28 public:
29 virtual void OnImageDecodeError() = 0;
30 };
31
32 // Returns the BlobImageSerializationProcessor* instance that is active
33 // for the current process.
34 static BlobImageSerializationProcessor* current();
35
36 BlobImageSerializationProcessor();
37 ~BlobImageSerializationProcessor() override;
38
39 // Sets the |blob_receiver| to use for reading images.
40 // |blob_receiver| must outlive |this|.
41 void set_blob_receiver(BlobChannelReceiver* blob_receiver) {
42 blob_receiver_ = blob_receiver;
43 }
44
45 // |error_delegate| must outlive this.
46 void set_error_delegate(ErrorDelegate* error_delegate) {
47 error_delegate_ = error_delegate;
48 }
49
50 // Retrieves a bitmap with ID |input| from |blob_receiver_| and decodes it
51 // to |bitmap|.
52 bool GetAndDecodeBlob(const void* input,
53 size_t input_size,
54 SkBitmap* bitmap) const;
55
56 private:
57 friend struct base::DefaultSingletonTraits<BlobImageSerializationProcessor>;
58
59 // Adapts a bare function pointer call to a singleton call to
60 // GetAndDecodeBlob() call on the current() processor.
61 static bool InstallPixelRefProc(const void* input,
62 size_t input_size,
63 SkBitmap* bitmap);
64
65 // cc:ImageSerializationProcessor implementation.
66 std::unique_ptr<cc::EnginePictureCache> CreateEnginePictureCache() override;
67 std::unique_ptr<cc::ClientPictureCache> CreateClientPictureCache() override;
68
69 // Interface for accessing stored images received over the Blob Channel.
70 BlobChannelReceiver* blob_receiver_ = nullptr;
71
72 ErrorDelegate* error_delegate_ = nullptr;
73
74 // Pointer is bound on object construction, and set to nullptr on object
75 // deletion. Only one BlobImageSerializationProcessor may be live at a time.
76 static BlobImageSerializationProcessor* current_instance_;
77
78 DISALLOW_COPY_AND_ASSIGN(BlobImageSerializationProcessor);
79 };
80
81 } // namespace client
82 } // namespace blimp
83
84 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698