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

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

Issue 2530443004: Add target color profile to BitmapImage::draw (Closed)
Patch Set: Created 4 years 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.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 PassRefPtr<SharedBuffer> ImageSource::data() { 45 PassRefPtr<SharedBuffer> ImageSource::data() {
46 return m_decoder ? m_decoder->data() : nullptr; 46 return m_decoder ? m_decoder->data() : nullptr;
47 } 47 }
48 48
49 bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, 49 bool ImageSource::setData(PassRefPtr<SharedBuffer> passData,
50 bool allDataReceived) { 50 bool allDataReceived) {
51 RefPtr<SharedBuffer> data = passData; 51 RefPtr<SharedBuffer> data = passData;
52 52
53 if (m_decoder) { 53 if (m_decoder) {
54 m_data = data;
55 m_allDataReceived = allDataReceived;
54 m_decoder->setData(data.release(), allDataReceived); 56 m_decoder->setData(data.release(), allDataReceived);
55 // If the decoder is pre-instantiated, it means we've already validated the 57 // If the decoder is pre-instantiated, it means we've already validated the
56 // data/signature at some point. 58 // data/signature at some point.
57 return true; 59 return true;
58 } 60 }
59 61
60 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { 62 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) {
61 m_decoder = DeferredImageDecoder::create( 63 m_decoder = DeferredImageDecoder::create(
62 data, allDataReceived, ImageDecoder::AlphaPremultiplied, 64 data, allDataReceived, ImageDecoder::AlphaPremultiplied,
63 ImageDecoder::ColorSpaceTagged, nullptr); 65 ImageDecoder::ColorSpaceTagged, nullptr);
64 } else { 66 } else {
65 m_decoder = DeferredImageDecoder::create( 67 m_decoder = DeferredImageDecoder::create(
66 data, allDataReceived, ImageDecoder::AlphaPremultiplied, 68 data, allDataReceived, ImageDecoder::AlphaPremultiplied,
67 ImageDecoder::ColorSpaceTransformed, 69 ImageDecoder::ColorSpaceTransformed,
68 ImageDecoder::globalTargetColorSpace()); 70 ImageDecoder::globalTargetColorSpace());
69 } 71 }
70 72
71 // Insufficient data is not a failure. 73 // Insufficient data is not a failure.
72 return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data); 74 if (m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data)) {
75 m_data = data;
76 m_allDataReceived = allDataReceived;
77 return true;
78 }
79 m_data = nullptr;
80 m_allDataReceived = false;
81 return false;
73 } 82 }
74 83
75 String ImageSource::filenameExtension() const { 84 String ImageSource::filenameExtension() const {
76 return m_decoder ? m_decoder->filenameExtension() : String(); 85 return m_decoder ? m_decoder->filenameExtension() : String();
77 } 86 }
78 87
79 bool ImageSource::isSizeAvailable() { 88 bool ImageSource::isSizeAvailable() {
80 return m_decoder && m_decoder->isSizeAvailable(); 89 return m_decoder && m_decoder->isSizeAvailable();
81 } 90 }
82 91
(...skipping 25 matching lines...) Expand all
108 } 117 }
109 118
110 int ImageSource::repetitionCount() { 119 int ImageSource::repetitionCount() {
111 return m_decoder ? m_decoder->repetitionCount() : cAnimationNone; 120 return m_decoder ? m_decoder->repetitionCount() : cAnimationNone;
112 } 121 }
113 122
114 size_t ImageSource::frameCount() const { 123 size_t ImageSource::frameCount() const {
115 return m_decoder ? m_decoder->frameCount() : 0; 124 return m_decoder ? m_decoder->frameCount() : 0;
116 } 125 }
117 126
118 sk_sp<SkImage> ImageSource::createFrameAtIndex(size_t index) { 127 sk_sp<SkImage> ImageSource::createFrameAtIndex(
128 size_t index,
129 sk_sp<SkColorSpace> targetColorSpace) {
130 DCHECK(targetColorSpace);
119 if (!m_decoder) 131 if (!m_decoder)
120 return nullptr; 132 return nullptr;
121 133
134 if (!SkColorSpace::Equals(m_decoder->targetColorSpace().get(),
135 targetColorSpace.get())) {
136 std::unique_ptr<DeferredImageDecoder> newColorSpaceDecoder =
137 DeferredImageDecoder::create(
138 m_data, m_allDataReceived, ImageDecoder::AlphaPremultiplied,
139 ImageDecoder::ColorSpaceTransformed, targetColorSpace);
140 std::swap(m_decoder, newColorSpaceDecoder);
141 }
142
122 return m_decoder->createFrameAtIndex(index); 143 return m_decoder->createFrameAtIndex(index);
123 } 144 }
124 145
125 float ImageSource::frameDurationAtIndex(size_t index) const { 146 float ImageSource::frameDurationAtIndex(size_t index) const {
126 if (!m_decoder) 147 if (!m_decoder)
127 return 0; 148 return 0;
128 149
129 // Many annoying ads specify a 0 duration to make an image flash as quickly as 150 // Many annoying ads specify a 0 duration to make an image flash as quickly as
130 // possible. We follow Firefox's behavior and use a duration of 100 ms for any 151 // possible. We follow Firefox's behavior and use a duration of 100 ms for any
131 // frames that specify a duration of <= 10 ms. See <rdar://problem/7689300> 152 // frames that specify a duration of <= 10 ms. See <rdar://problem/7689300>
(...skipping 15 matching lines...) Expand all
147 168
148 bool ImageSource::frameIsCompleteAtIndex(size_t index) const { 169 bool ImageSource::frameIsCompleteAtIndex(size_t index) const {
149 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); 170 return m_decoder && m_decoder->frameIsCompleteAtIndex(index);
150 } 171 }
151 172
152 size_t ImageSource::frameBytesAtIndex(size_t index) const { 173 size_t ImageSource::frameBytesAtIndex(size_t index) const {
153 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; 174 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0;
154 } 175 }
155 176
156 } // namespace blink 177 } // 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