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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageSource.cpp

Issue 2925623003: color: Remove unneeded ColorBehavior parameters from ImageSource (Closed)
Patch Set: Created 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageSource.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 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> 3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
4 * Copyright (C) 2008, Google Inc. All rights reserved. 4 * Copyright (C) 2008, Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "platform/graphics/ImageSource.h" 28 #include "platform/graphics/ImageSource.h"
29 29
30 #include "platform/RuntimeEnabledFeatures.h"
30 #include "platform/graphics/DeferredImageDecoder.h" 31 #include "platform/graphics/DeferredImageDecoder.h"
31 #include "platform/image-decoders/ImageDecoder.h" 32 #include "platform/image-decoders/ImageDecoder.h"
32 #include "third_party/skia/include/core/SkImage.h" 33 #include "third_party/skia/include/core/SkImage.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
36 ImageSource::ImageSource() 37 ImageSource::ImageSource() {}
37 : decoder_color_behavior_(ColorBehavior::TransformToGlobalTarget()) {}
38 38
39 ImageSource::~ImageSource() {} 39 ImageSource::~ImageSource() {}
40 40
41 size_t ImageSource::ClearCacheExceptFrame(size_t clear_except_frame) { 41 size_t ImageSource::ClearCacheExceptFrame(size_t clear_except_frame) {
42 return decoder_ ? decoder_->ClearCacheExceptFrame(clear_except_frame) : 0; 42 return decoder_ ? decoder_->ClearCacheExceptFrame(clear_except_frame) : 0;
43 } 43 }
44 44
45 PassRefPtr<SharedBuffer> ImageSource::Data() { 45 PassRefPtr<SharedBuffer> ImageSource::Data() {
46 return decoder_ ? decoder_->Data() : nullptr; 46 return decoder_ ? decoder_->Data() : nullptr;
47 } 47 }
48 48
49 bool ImageSource::SetData(RefPtr<SharedBuffer> data, bool all_data_received) { 49 bool ImageSource::SetData(RefPtr<SharedBuffer> data, bool all_data_received) {
50 all_data_received_ = all_data_received; 50 all_data_received_ = all_data_received;
51 51
52 if (decoder_) { 52 if (decoder_) {
53 decoder_->SetData(std::move(data), all_data_received); 53 decoder_->SetData(std::move(data), all_data_received);
54 // If the decoder is pre-instantiated, it means we've already validated the 54 // If the decoder is pre-instantiated, it means we've already validated the
55 // data/signature at some point. 55 // data/signature at some point.
56 return true; 56 return true;
57 } 57 }
58 58
59 ColorBehavior color_behavior =
60 RuntimeEnabledFeatures::colorCorrectRenderingEnabled()
61 ? ColorBehavior::Tag()
62 : ColorBehavior::TransformToGlobalTarget();
59 decoder_ = DeferredImageDecoder::Create(data, all_data_received, 63 decoder_ = DeferredImageDecoder::Create(data, all_data_received,
60 ImageDecoder::kAlphaPremultiplied, 64 ImageDecoder::kAlphaPremultiplied,
61 decoder_color_behavior_); 65 color_behavior);
62 66
63 // Insufficient data is not a failure. 67 // Insufficient data is not a failure.
64 return decoder_ || !ImageDecoder::HasSufficientDataToSniffImageType(*data); 68 return decoder_ || !ImageDecoder::HasSufficientDataToSniffImageType(*data);
65 } 69 }
66 70
67 String ImageSource::FilenameExtension() const { 71 String ImageSource::FilenameExtension() const {
68 return decoder_ ? decoder_->FilenameExtension() : String(); 72 return decoder_ ? decoder_->FilenameExtension() : String();
69 } 73 }
70 74
71 bool ImageSource::IsSizeAvailable() { 75 bool ImageSource::IsSizeAvailable() {
(...skipping 28 matching lines...) Expand all
100 } 104 }
101 105
102 int ImageSource::RepetitionCount() { 106 int ImageSource::RepetitionCount() {
103 return decoder_ ? decoder_->RepetitionCount() : kAnimationNone; 107 return decoder_ ? decoder_->RepetitionCount() : kAnimationNone;
104 } 108 }
105 109
106 size_t ImageSource::FrameCount() const { 110 size_t ImageSource::FrameCount() const {
107 return decoder_ ? decoder_->FrameCount() : 0; 111 return decoder_ ? decoder_->FrameCount() : 0;
108 } 112 }
109 113
110 sk_sp<SkImage> ImageSource::CreateFrameAtIndex( 114 sk_sp<SkImage> ImageSource::CreateFrameAtIndex(size_t index) {
111 size_t index,
112 const ColorBehavior& color_behavior) {
113 if (!decoder_) 115 if (!decoder_)
114 return nullptr; 116 return nullptr;
115 117
116 if (color_behavior != decoder_color_behavior_) {
117 decoder_ = DeferredImageDecoder::Create(Data(), all_data_received_,
118 ImageDecoder::kAlphaPremultiplied,
119 color_behavior);
120 decoder_color_behavior_ = color_behavior;
121 // The data has already been validated, so changing the color behavior
122 // should always result in a valid decoder.
123 DCHECK(decoder_);
124 }
125
126 return decoder_->CreateFrameAtIndex(index); 118 return decoder_->CreateFrameAtIndex(index);
127 } 119 }
128 120
129 float ImageSource::FrameDurationAtIndex(size_t index) const { 121 float ImageSource::FrameDurationAtIndex(size_t index) const {
130 if (!decoder_) 122 if (!decoder_)
131 return 0; 123 return 0;
132 124
133 // Many annoying ads specify a 0 duration to make an image flash as quickly as 125 // Many annoying ads specify a 0 duration to make an image flash as quickly as
134 // possible. We follow Firefox's behavior and use a duration of 100 ms for any 126 // possible. We follow Firefox's behavior and use a duration of 100 ms for any
135 // frames that specify a duration of <= 10 ms. See <rdar://problem/7689300> 127 // frames that specify a duration of <= 10 ms. See <rdar://problem/7689300>
(...skipping 15 matching lines...) Expand all
151 143
152 bool ImageSource::FrameIsCompleteAtIndex(size_t index) const { 144 bool ImageSource::FrameIsCompleteAtIndex(size_t index) const {
153 return decoder_ && decoder_->FrameIsCompleteAtIndex(index); 145 return decoder_ && decoder_->FrameIsCompleteAtIndex(index);
154 } 146 }
155 147
156 size_t ImageSource::FrameBytesAtIndex(size_t index) const { 148 size_t ImageSource::FrameBytesAtIndex(size_t index) const {
157 return decoder_ ? decoder_->FrameBytesAtIndex(index) : 0; 149 return decoder_ ? decoder_->FrameBytesAtIndex(index) : 0;
158 } 150 }
159 151
160 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698