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

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

Issue 1985863002: Incorporate BlobChannel into Blimp image encode/decode pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-helium
Patch Set: moved the blob serialization processor to the compositor manager Created 4 years, 6 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 #include "blimp/client/feature/compositor/blob_image_serialization_processor.h"
6
7 #include <stddef.h>
8 #include <string>
9 #include <vector>
10
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/sha1.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "blimp/client/feature/compositor/blimp_image_decoder.h"
16 #include "blimp/common/blob_cache/blob_cache.h"
17 #include "blimp/common/blob_cache/id_util.h"
18 #include "blimp/common/proto/blob_cache.pb.h"
19 #include "blimp/net/blob_channel/blob_channel_receiver.h"
20
21 namespace blimp {
22 namespace client {
23
24 // static
Wez 2016/06/10 22:29:54 nit: Do we need a // static comment in front of me
Kevin M 2016/06/10 23:51:50 Done.
25 BlobImageSerializationProcessor*
26 BlobImageSerializationProcessor::current_instance_ = nullptr;
27
28 BlobImageSerializationProcessor* BlobImageSerializationProcessor::current() {
29 CHECK(current_instance_);
Wez 2016/06/10 22:29:54 nit: DCHECK here and below?
Kevin M 2016/06/10 23:51:50 Done.
30 return current_instance_;
31 }
32
33 BlobImageSerializationProcessor::BlobImageSerializationProcessor() {
34 CHECK(!current_instance_);
35 current_instance_ = this;
36 }
37
38 BlobImageSerializationProcessor::~BlobImageSerializationProcessor() {
39 current_instance_ = nullptr;
40 }
41
42 // static
43 bool BlobImageSerializationProcessor::InstallPixelRefProc(const void* input,
44 size_t input_size,
45 SkBitmap* bitmap) {
46 DCHECK(input);
47 DCHECK(bitmap);
Wez 2016/06/10 22:29:54 nit: GetAndDecodeBlob will touch |input| at least,
Kevin M 2016/06/10 23:51:50 Done.
48
49 return current()->GetAndDecodeBlob(input, input_size, bitmap);
50 }
51
52 bool BlobImageSerializationProcessor::GetAndDecodeBlob(const void* input,
53 size_t input_size,
54 SkBitmap* bitmap) {
55 BlobCacheImageMetadata parsed_metadata;
56 if (!parsed_metadata.ParseFromArray(input, input_size)) {
57 LOG(ERROR) << "Couldn't parse blob metadata structure.";
58 error_delegate_->OnImageDecodeError();
59 return false;
60 }
61 if (!IsValidBlobId(parsed_metadata.id())) {
62 LOG(ERROR) << "Image payload is not a valid blob ID.";
63 error_delegate_->OnImageDecodeError();
64 return false;
65 }
66
67 // Get the image blob synchronously.
68 // TODO(kmarshall): Add support for asynchronous Get() completion after Skia
69 // supports image replacement.
70 BlobDataPtr blob = blob_receiver_->Get(parsed_metadata.id());
71 if (!blob) {
72 LOG(ERROR) << "No blob found with ID: "
73 << BlobIdToString(parsed_metadata.id());
74 error_delegate_->OnImageDecodeError();
75 return false;
76 }
77
78 DVLOG(1) << "GetAndDecodeBlob(" << BlobIdToString(parsed_metadata.id())
79 << ")";
80
81 return BlimpImageDecoder(reinterpret_cast<const void*>(&blob->data[0]),
82 blob->data.size(), bitmap);
83 }
84
85 SkPixelSerializer* BlobImageSerializationProcessor::GetPixelSerializer() {
86 NOTREACHED();
87 return nullptr;
88 }
89
90 SkPicture::InstallPixelRefProc
91 BlobImageSerializationProcessor::GetPixelDeserializer() {
92 return &BlobImageSerializationProcessor::InstallPixelRefProc;
93 }
94
95 } // namespace client
96 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698