OLD | NEW |
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 if (index >= frameCount()) | 167 if (index >= frameCount()) |
168 return 0; | 168 return 0; |
169 | 169 |
170 ImageFrame* frame = &m_frameBufferCache[index]; | 170 ImageFrame* frame = &m_frameBufferCache[index]; |
171 if (frame->getStatus() != ImageFrame::FrameComplete) { | 171 if (frame->getStatus() != ImageFrame::FrameComplete) { |
172 PlatformInstrumentation::willDecodeImage(filenameExtension()); | 172 PlatformInstrumentation::willDecodeImage(filenameExtension()); |
173 decode(index); | 173 decode(index); |
174 PlatformInstrumentation::didDecodeImage(); | 174 PlatformInstrumentation::didDecodeImage(); |
175 } | 175 } |
176 | 176 |
| 177 if (!m_hasHistogrammedColorSpace) { |
| 178 BitmapImageMetrics::countImageGamma(m_embeddedColorSpace.get()); |
| 179 m_hasHistogrammedColorSpace = true; |
| 180 } |
| 181 |
177 frame->notifyBitmapIfPixelsChanged(); | 182 frame->notifyBitmapIfPixelsChanged(); |
178 return frame; | 183 return frame; |
179 } | 184 } |
180 | 185 |
181 bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const { | 186 bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const { |
182 return !frameIsCompleteAtIndex(index) || m_frameBufferCache[index].hasAlpha(); | 187 return !frameIsCompleteAtIndex(index) || m_frameBufferCache[index].hasAlpha(); |
183 } | 188 } |
184 | 189 |
185 bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const { | 190 bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const { |
186 return (index < m_frameBufferCache.size()) && | 191 return (index < m_frameBufferCache.size()) && |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 SpinLock::Guard guard(gTargetColorSpaceLock); | 353 SpinLock::Guard guard(gTargetColorSpaceLock); |
349 | 354 |
350 // Layout tests expect that only the first call will take effect. | 355 // Layout tests expect that only the first call will take effect. |
351 if (gTargetColorSpace) | 356 if (gTargetColorSpace) |
352 return; | 357 return; |
353 | 358 |
354 gTargetColorSpace = | 359 gTargetColorSpace = |
355 SkColorSpace::MakeICC(profile.data(), profile.size()).release(); | 360 SkColorSpace::MakeICC(profile.data(), profile.size()).release(); |
356 | 361 |
357 // UMA statistics. | 362 // UMA statistics. |
358 BitmapImageMetrics::countGamma(gTargetColorSpace); | 363 BitmapImageMetrics::countOutputGamma(gTargetColorSpace); |
359 } | 364 } |
360 | 365 |
361 sk_sp<SkColorSpace> ImageDecoder::colorSpace() const { | 366 sk_sp<SkColorSpace> ImageDecoder::colorSpace() const { |
362 // TODO(ccameron): This should always return a non-null SkColorSpace. This is | 367 // TODO(ccameron): This should always return a non-null SkColorSpace. This is |
363 // disabled for now because specifying a non-renderable color space results in | 368 // disabled for now because specifying a non-renderable color space results in |
364 // errors. | 369 // errors. |
365 // https://bugs.chromium.org/p/skia/issues/detail?id=5907 | 370 // https://bugs.chromium.org/p/skia/issues/detail?id=5907 |
366 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | 371 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
367 return nullptr; | 372 return nullptr; |
368 | 373 |
369 if (m_embeddedColorSpace) | 374 if (m_embeddedColorSpace) |
370 return m_embeddedColorSpace; | 375 return m_embeddedColorSpace; |
371 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); | 376 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); |
372 } | 377 } |
373 | 378 |
374 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData, | 379 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData, |
375 unsigned iccLength) { | 380 unsigned iccLength) { |
376 sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(iccData, iccLength); | 381 sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(iccData, iccLength); |
377 if (!colorSpace) | 382 if (!colorSpace) |
378 DLOG(ERROR) << "Failed to parse image ICC profile"; | 383 DLOG(ERROR) << "Failed to parse image ICC profile"; |
379 setColorSpaceAndComputeTransform(std::move(colorSpace)); | 384 setColorSpaceAndComputeTransform(std::move(colorSpace)); |
380 } | 385 } |
381 | 386 |
382 void ImageDecoder::setColorSpaceAndComputeTransform( | 387 void ImageDecoder::setColorSpaceAndComputeTransform( |
383 sk_sp<SkColorSpace> colorSpace) { | 388 sk_sp<SkColorSpace> colorSpace) { |
384 DCHECK(!m_ignoreColorSpace); | 389 DCHECK(!m_ignoreColorSpace); |
| 390 DCHECK(!m_hasHistogrammedColorSpace); |
385 | 391 |
386 m_embeddedColorSpace = colorSpace; | 392 m_embeddedColorSpace = colorSpace; |
387 | 393 |
388 m_sourceToOutputDeviceColorTransform = nullptr; | 394 m_sourceToOutputDeviceColorTransform = nullptr; |
389 | 395 |
390 // With color correct rendering, we do not transform to the output color space | 396 // With color correct rendering, we do not transform to the output color space |
391 // at decode time. Instead, we tag the raw image pixels and pass the tagged | 397 // at decode time. Instead, we tag the raw image pixels and pass the tagged |
392 // SkImage to Skia. | 398 // SkImage to Skia. |
393 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | 399 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
394 return; | 400 return; |
(...skipping 14 matching lines...) Expand all Loading... |
409 | 415 |
410 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) { | 416 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) { |
411 return; | 417 return; |
412 } | 418 } |
413 | 419 |
414 m_sourceToOutputDeviceColorTransform = | 420 m_sourceToOutputDeviceColorTransform = |
415 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace); | 421 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace); |
416 } | 422 } |
417 | 423 |
418 } // namespace blink | 424 } // namespace blink |
OLD | NEW |