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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2807073002: Removed local RefPtr objects created from PassRefPtr arguments. (Closed)
Patch Set: Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 inline bool MatchesBMPSignature(const char* contents) { 62 inline bool MatchesBMPSignature(const char* contents) {
63 return !memcmp(contents, "BM", 2); 63 return !memcmp(contents, "BM", 2);
64 } 64 }
65 65
66 // This needs to be updated if we ever add a matches*Signature() which requires 66 // This needs to be updated if we ever add a matches*Signature() which requires
67 // more characters. 67 // more characters.
68 static constexpr size_t kLongestSignatureLength = sizeof("RIFF????WEBPVP") - 1; 68 static constexpr size_t kLongestSignatureLength = sizeof("RIFF????WEBPVP") - 1;
69 69
70 std::unique_ptr<ImageDecoder> ImageDecoder::Create( 70 std::unique_ptr<ImageDecoder> ImageDecoder::Create(
71 PassRefPtr<SegmentReader> pass_data, 71 RefPtr<SegmentReader> data,
72 bool data_complete, 72 bool data_complete,
73 AlphaOption alpha_option, 73 AlphaOption alpha_option,
74 const ColorBehavior& color_behavior) { 74 const ColorBehavior& color_behavior) {
75 RefPtr<SegmentReader> data = pass_data;
76
77 // We need at least kLongestSignatureLength bytes to run the signature 75 // We need at least kLongestSignatureLength bytes to run the signature
78 // matcher. 76 // matcher.
79 if (data->size() < kLongestSignatureLength) 77 if (data->size() < kLongestSignatureLength)
80 return nullptr; 78 return nullptr;
81 79
82 const size_t max_decoded_bytes = 80 const size_t max_decoded_bytes =
83 Platform::Current() ? Platform::Current()->MaxDecodedImageBytes() 81 Platform::Current() ? Platform::Current()->MaxDecodedImageBytes()
84 : kNoDecodedImageByteLimit; 82 : kNoDecodedImageByteLimit;
85 83
86 // Access the first kLongestSignatureLength chars to sniff the signature. 84 // Access the first kLongestSignatureLength chars to sniff the signature.
(...skipping 28 matching lines...) Expand all
115 break; 113 break;
116 case SniffResult::BMP: 114 case SniffResult::BMP:
117 decoder.reset( 115 decoder.reset(
118 new BMPImageDecoder(alpha_option, color_behavior, max_decoded_bytes)); 116 new BMPImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
119 break; 117 break;
120 case SniffResult::kInvalid: 118 case SniffResult::kInvalid:
121 break; 119 break;
122 } 120 }
123 121
124 if (decoder) 122 if (decoder)
125 decoder->SetData(data.Release(), data_complete); 123 decoder->SetData(std::move(data), data_complete);
126 124
127 return decoder; 125 return decoder;
128 } 126 }
129 127
130 bool ImageDecoder::HasSufficientDataToSniffImageType(const SharedBuffer& data) { 128 bool ImageDecoder::HasSufficientDataToSniffImageType(const SharedBuffer& data) {
131 return data.size() >= kLongestSignatureLength; 129 return data.size() >= kLongestSignatureLength;
132 } 130 }
133 131
134 ImageDecoder::SniffResult ImageDecoder::DetermineImageType(const char* contents, 132 ImageDecoder::SniffResult ImageDecoder::DetermineImageType(const char* contents,
135 size_t length) { 133 size_t length) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 sk_sp<SkColorSpace> ImageDecoder::ColorSpaceForSkImages() const { 547 sk_sp<SkColorSpace> ImageDecoder::ColorSpaceForSkImages() const {
550 if (!color_behavior_.IsTag()) 548 if (!color_behavior_.IsTag())
551 return nullptr; 549 return nullptr;
552 550
553 if (embedded_color_space_) 551 if (embedded_color_space_)
554 return embedded_color_space_; 552 return embedded_color_space_;
555 return SkColorSpace::MakeSRGB(); 553 return SkColorSpace::MakeSRGB();
556 } 554 }
557 555
558 } // namespace blink 556 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698