| 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_ENGINE_RENDERER_ENGINE_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
| 6 #define BLIMP_ENGINE_RENDERER_ENGINE_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "blimp/common/blimp_common_export.h" | |
| 13 #include "blimp/common/blob_cache/id_util.h" | |
| 14 #include "blimp/engine/mojo/blob_channel.mojom.h" | |
| 15 #include "cc/blimp/client_picture_cache.h" | |
| 16 #include "cc/blimp/engine_picture_cache.h" | |
| 17 #include "cc/blimp/image_serialization_processor.h" | |
| 18 #include "third_party/libwebp/webp/encode.h" | |
| 19 #include "third_party/skia/include/core/SkPixelSerializer.h" | |
| 20 | |
| 21 namespace blimp { | |
| 22 namespace engine { | |
| 23 | |
| 24 class BlobChannelSenderProxy; | |
| 25 | |
| 26 // EngineImageSerializationProcessor provides functionality to serialize | |
| 27 // and temporarily cache Skia images. | |
| 28 class BLIMP_COMMON_EXPORT EngineImageSerializationProcessor | |
| 29 : public cc::ImageSerializationProcessor, | |
| 30 public SkPixelSerializer { | |
| 31 public: | |
| 32 explicit EngineImageSerializationProcessor( | |
| 33 std::unique_ptr<BlobChannelSenderProxy> blob_channel); | |
| 34 ~EngineImageSerializationProcessor() override; | |
| 35 | |
| 36 // cc::ImageSerializationProcessor implementation. | |
| 37 std::unique_ptr<cc::EnginePictureCache> CreateEnginePictureCache() override; | |
| 38 std::unique_ptr<cc::ClientPictureCache> CreateClientPictureCache() override; | |
| 39 | |
| 40 // SkPixelSerializer implementation. | |
| 41 bool onUseEncodedData(const void* data, size_t len) override; | |
| 42 SkData* onEncode(const SkPixmap& pixmap) override; | |
| 43 | |
| 44 private: | |
| 45 scoped_refptr<BlobData> EncodeImageAsBlob(const SkPixmap& pixmap); | |
| 46 | |
| 47 // A serializer that be used to pass in to SkPicture::serialize(...) for | |
| 48 // serializing the SkPicture to a stream. | |
| 49 std::unique_ptr<SkPixelSerializer> pixel_serializer_; | |
| 50 | |
| 51 // Sends image data as blobs to the browser process. | |
| 52 std::unique_ptr<BlobChannelSenderProxy> blob_channel_; | |
| 53 | |
| 54 // Reusable output buffer for image encoding. | |
| 55 WebPMemoryWriter writer_state_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(EngineImageSerializationProcessor); | |
| 58 }; | |
| 59 | |
| 60 } // namespace engine | |
| 61 } // namespace blimp | |
| 62 | |
| 63 #endif // BLIMP_ENGINE_RENDERER_ENGINE_IMAGE_SERIALIZATION_PROCESSOR_H_ | |
| OLD | NEW |