Chromium Code Reviews| Index: blimp/client/feature/compositor/blob_image_serialization_processor.h |
| diff --git a/blimp/client/feature/compositor/blob_image_serialization_processor.h b/blimp/client/feature/compositor/blob_image_serialization_processor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..deb1ddb1bbe89989b3830e22e756167887c093e0 |
| --- /dev/null |
| +++ b/blimp/client/feature/compositor/blob_image_serialization_processor.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_ |
| +#define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_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 { |
| + |
| +// Adds BlobChannel image retrieval support to the Skia image decoding process. |
| +class BlobImageSerializationProcessor : public cc::ImageSerializationProcessor { |
| + public: |
| + class ErrorDelegate { |
| + public: |
| + virtual void OnImageDecodeError() = 0; |
| + }; |
| + |
| + 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
|
| + |
| + BlobImageSerializationProcessor(); |
| + virtual ~BlobImageSerializationProcessor(); |
| + |
| + // 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<BlobImageSerializationProcessor>; |
| + |
| + // Adapts a bare function pointer call to a singleton call to |
| + // 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.
|
| + static bool InstallPixelRefProc(const void* input, |
| + size_t input_size, |
| + SkBitmap* bitmap); |
| + |
| + // cc:ImageSerializationProcessor implementation. |
| + SkPixelSerializer* GetPixelSerializer() override; |
| + SkPicture::InstallPixelRefProc GetPixelDeserializer() override; |
| + |
| + // Interface for accessing stored images received over the Blob Channel. |
| + BlobChannelReceiver* blob_receiver_ = nullptr; |
| + |
| + ErrorDelegate* error_delegate_ = nullptr; |
| + |
| + // Pointer is bound on object construction, and set to nullptr on object |
| + // 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
|
| + static BlobImageSerializationProcessor* current_instance_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlobImageSerializationProcessor); |
| +}; |
| + |
| +} // namespace client |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLOB_IMAGE_SERIALIZATION_PROCESSOR_H_ |