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

Side by Side Diff: blimp/engine/renderer/engine_image_serialization_processor.cc

Issue 1859753002: Blimp: create Mojo component for renderer/browser communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yzshen and nyquist feedback Created 4 years, 8 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
« no previous file with comments | « blimp/engine/renderer/engine_image_serialization_processor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/common/compositor/blimp_image_serialization_processor.h" 5 #include "blimp/engine/renderer/engine_image_serialization_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "blimp/common/compositor/webp_decoder.h" 11 #include "blimp/common/compositor/webp_decoder.h"
12 #include "content/public/renderer/render_frame.h"
12 #include "third_party/libwebp/webp/encode.h" 13 #include "third_party/libwebp/webp/encode.h"
13 #include "third_party/skia/include/core/SkData.h" 14 #include "third_party/skia/include/core/SkData.h"
14 #include "third_party/skia/include/core/SkPicture.h" 15 #include "third_party/skia/include/core/SkPicture.h"
15 #include "third_party/skia/include/core/SkPixelSerializer.h" 16 #include "third_party/skia/include/core/SkPixelSerializer.h"
16 #include "third_party/skia/include/core/SkUnPreMultiply.h" 17 #include "third_party/skia/include/core/SkUnPreMultiply.h"
17 18
18 namespace { 19 namespace {
19 // TODO(nyquist): Make sure encoder does not serialize images more than once. 20 // TODO(nyquist): Make sure encoder does not serialize images more than once.
20 // See crbug.com/548434. 21 // See crbug.com/548434.
21 class WebPImageEncoder : public SkPixelSerializer { 22 class WebPImageEncoder : public SkPixelSerializer {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 if (SK_B32_SHIFT) // Android 134 if (SK_B32_SHIFT) // Android
134 return WebPPictureImportRGBA(picture, unpremul_pixels.data(), row_stride); 135 return WebPPictureImportRGBA(picture, unpremul_pixels.data(), row_stride);
135 return WebPPictureImportBGRA(picture, unpremul_pixels.data(), row_stride); 136 return WebPPictureImportBGRA(picture, unpremul_pixels.data(), row_stride);
136 } 137 }
137 }; 138 };
138 139
139 } // namespace 140 } // namespace
140 141
141 namespace blimp { 142 namespace blimp {
143 namespace engine {
142 144
143 BlimpImageSerializationProcessor::BlimpImageSerializationProcessor(Mode mode) { 145 EngineImageSerializationProcessor::EngineImageSerializationProcessor(
144 switch (mode) { 146 mojom::BlobChannelPtr blob_channel)
145 case Mode::SERIALIZATION: 147 : blob_channel_(std::move(blob_channel)) {
146 pixel_serializer_.reset(new WebPImageEncoder); 148 DCHECK(blob_channel_);
147 pixel_deserializer_ = nullptr; 149
148 break; 150 pixel_serializer_.reset(new WebPImageEncoder);
149 case Mode::DESERIALIZATION: 151
150 pixel_serializer_ = nullptr; 152 // Dummy BlobChannel command.
151 pixel_deserializer_ = &WebPDecoder; 153 // TODO(nyquist): Remove this after integrating BlobChannel.
152 break; 154 blob_channel_->Push("foo");
153 default:
154 NOTREACHED() << "Unknown serialization mode";
155 }
156 } 155 }
157 156
158 BlimpImageSerializationProcessor::~BlimpImageSerializationProcessor() {} 157 EngineImageSerializationProcessor::~EngineImageSerializationProcessor() {}
159 158
160 SkPixelSerializer* BlimpImageSerializationProcessor::GetPixelSerializer() { 159 SkPixelSerializer* EngineImageSerializationProcessor::GetPixelSerializer() {
161 return pixel_serializer_.get(); 160 return pixel_serializer_.get();
162 } 161 }
163 162
164 SkPicture::InstallPixelRefProc 163 SkPicture::InstallPixelRefProc
165 BlimpImageSerializationProcessor::GetPixelDeserializer() { 164 EngineImageSerializationProcessor::GetPixelDeserializer() {
166 return pixel_deserializer_; 165 return nullptr;
167 } 166 }
168 167
168 } // namespace engine
169 } // namespace blimp 169 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/engine_image_serialization_processor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698