Index: blimp/client/feature/compositor/client_image_serialization_processor.h |
diff --git a/blimp/client/feature/compositor/client_image_serialization_processor.h b/blimp/client/feature/compositor/client_image_serialization_processor.h |
index 5118f428cf6b539e65cf1bc2dc03743a78c35f39..7caffc8573db980eecbc0fbf4a1972b6f297b8f6 100644 |
--- a/blimp/client/feature/compositor/client_image_serialization_processor.h |
+++ b/blimp/client/feature/compositor/client_image_serialization_processor.h |
@@ -5,29 +5,67 @@ |
#ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_CLIENT_IMAGE_SERIALIZATION_PROCESSOR_H_ |
#define BLIMP_CLIENT_FEATURE_COMPOSITOR_CLIENT_IMAGE_SERIALIZATION_PROCESSOR_H_ |
+#include <memory> |
+ |
#include "base/macros.h" |
+#include "base/memory/singleton.h" |
#include "cc/proto/image_serialization_processor.h" |
#include "third_party/skia/include/core/SkPicture.h" |
class SkPixelSerializer; |
namespace blimp { |
+ |
+class BlobChannelReceiver; |
+ |
namespace client { |
-// ClientImageSerializationProcessor provides functionality to deserialize Skia |
-// images. |
+// Adds BlobChannel image retrieval support to the Skia image decoding process. |
class ClientImageSerializationProcessor |
: public cc::ImageSerializationProcessor { |
public: |
+ class ErrorDelegate { |
+ public: |
+ virtual void OnImageDecodeError() = 0; |
+ }; |
+ |
+ static ClientImageSerializationProcessor* GetInstance(); |
+ |
+ // Sets the |blob_receiver| to use for reading images. |
+ // |blob_receiver| must outlive |this|. |
+ void set_blob_receiver(BlobChannelReceiver* blob_receiver) { |
+ blob_receiver_ = blob_receiver; |
+ } |
+ |
+ // |error_delegate| must outlive this. |
+ void set_error_delegate(ErrorDelegate* error_delegate) { |
+ error_delegate_ = error_delegate; |
+ } |
+ |
+ // Retrieves a bitmap with ID |input| from |blob_receiver_| and decodes it |
+ // to |bitmap|. |
+ bool GetAndDecodeBlob(const void* input, size_t input_size, SkBitmap* bitmap); |
+ |
+ private: |
+ friend struct base::DefaultSingletonTraits<ClientImageSerializationProcessor>; |
+ |
ClientImageSerializationProcessor(); |
- ~ClientImageSerializationProcessor(); |
+ virtual ~ClientImageSerializationProcessor(); |
- // cc::ImageSerializationProcessor implementation. |
+ // Adapts a bare function pointer call to a singleton call to |
+ // GetAndDecodeBlob(). |
+ static bool InstallPixelRefProc(const void* input, |
+ size_t input_size, |
+ SkBitmap* bitmap); |
+ |
+ // cc:ImageSerializationProcessor implementation. |
SkPixelSerializer* GetPixelSerializer() override; |
SkPicture::InstallPixelRefProc GetPixelDeserializer() override; |
- private: |
- SkPicture::InstallPixelRefProc pixel_deserializer_; |
+ // Interface for accessing stored images received over the Blob Channel. |
+ BlobChannelReceiver* blob_receiver_ = nullptr; |
+ |
+ ErrorDelegate* error_delegate_ = nullptr; |
DISALLOW_COPY_AND_ASSIGN(ClientImageSerializationProcessor); |
}; |