| Index: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| index 92ea4de1b78448828eae0b1dfeb700459d9a6066..2b793ebc4324a7c36a8ab2b678a4cae450a71ad1 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| @@ -47,9 +47,6 @@ namespace blink {
|
| namespace {
|
|
|
| ColorBehavior defaultColorBehavior() {
|
| - // TODO(ccameron): ColorBehavior should be specified by the caller requesting
|
| - // SkImages.
|
| - // https://crbug.com/667420
|
| if (RuntimeEnabledFeatures::trueColorRenderingEnabled())
|
| return ColorBehavior::tag();
|
| return ColorBehavior::transformToGlobalTarget();
|
| @@ -75,7 +72,6 @@ BitmapImage::BitmapImage(ImageObserver* observer)
|
| : Image(observer),
|
| m_currentFrame(0),
|
| m_cachedFrameIndex(0),
|
| - m_cachedFrameColorBehavior(defaultColorBehavior()),
|
| m_repetitionCount(cAnimationNone),
|
| m_repetitionCountStatus(Unknown),
|
| m_repetitionsComplete(0),
|
| @@ -94,7 +90,6 @@ BitmapImage::BitmapImage(const SkBitmap& bitmap, ImageObserver* observer)
|
| m_currentFrame(0),
|
| m_cachedFrame(SkImage::MakeFromBitmap(bitmap)),
|
| m_cachedFrameIndex(0),
|
| - m_cachedFrameColorBehavior(defaultColorBehavior()),
|
| m_repetitionCount(cAnimationNone),
|
| m_repetitionCountStatus(Unknown),
|
| m_repetitionsComplete(0),
|
| @@ -147,19 +142,17 @@ size_t BitmapImage::totalFrameBytes() {
|
| return totalBytes;
|
| }
|
|
|
| -sk_sp<SkImage> BitmapImage::decodeAndCacheFrame(
|
| - size_t index,
|
| - const ColorBehavior& colorBehavior) {
|
| +sk_sp<SkImage> BitmapImage::decodeAndCacheFrame(size_t index) {
|
| size_t numFrames = frameCount();
|
| if (m_frames.size() < numFrames)
|
| m_frames.grow(numFrames);
|
|
|
| // We are caching frame snapshots. This is OK even for partially decoded
|
| // frames, as they are cleared by dataChanged() when new data arrives.
|
| - sk_sp<SkImage> image = m_source.createFrameAtIndex(index, colorBehavior);
|
| + sk_sp<SkImage> image =
|
| + m_source.createFrameAtIndex(index, defaultColorBehavior());
|
| m_cachedFrame = image;
|
| m_cachedFrameIndex = index;
|
| - m_cachedFrameColorBehavior = colorBehavior;
|
|
|
| m_frames[index].m_orientation = m_source.orientationAtIndex(index);
|
| m_frames[index].m_haveMetadata = true;
|
| @@ -269,8 +262,7 @@ void BitmapImage::draw(
|
| ImageClampingMode clampMode) {
|
| TRACE_EVENT0("skia", "BitmapImage::draw");
|
|
|
| - sk_sp<SkImage> image =
|
| - imageForCurrentFrame(ColorBehavior::transformToGlobalTarget());
|
| + sk_sp<SkImage> image = imageForCurrentFrame();
|
| if (!image)
|
| return; // It's too early and we don't have an image yet.
|
|
|
| @@ -346,16 +338,14 @@ bool BitmapImage::isSizeAvailable() {
|
| return m_sizeAvailable;
|
| }
|
|
|
| -sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index,
|
| - const ColorBehavior& colorBehavior) {
|
| +sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index) {
|
| if (index >= frameCount())
|
| return nullptr;
|
|
|
| - if (index == m_cachedFrameIndex && m_cachedFrame &&
|
| - m_cachedFrameColorBehavior == colorBehavior)
|
| + if (index == m_cachedFrameIndex && m_cachedFrame)
|
| return m_cachedFrame;
|
|
|
| - return decodeAndCacheFrame(index, colorBehavior);
|
| + return decodeAndCacheFrame(index);
|
| }
|
|
|
| bool BitmapImage::frameIsCompleteAtIndex(size_t index) const {
|
| @@ -373,17 +363,13 @@ float BitmapImage::frameDurationAtIndex(size_t index) const {
|
| return m_source.frameDurationAtIndex(index);
|
| }
|
|
|
| -sk_sp<SkImage> BitmapImage::imageForCurrentFrame(
|
| - const ColorBehavior& colorBehavior) {
|
| - return frameAtIndex(currentFrame(), colorBehavior);
|
| +sk_sp<SkImage> BitmapImage::imageForCurrentFrame() {
|
| + return frameAtIndex(currentFrame());
|
| }
|
|
|
| PassRefPtr<Image> BitmapImage::imageForDefaultFrame() {
|
| - // TODO(ccameron): Determine the appropriate ColorBehavior for this situation.
|
| - // https://crbug.com/667420
|
| - const ColorBehavior& colorBehavior = m_cachedFrameColorBehavior;
|
| if (frameCount() > 1) {
|
| - sk_sp<SkImage> firstFrame = frameAtIndex(0, colorBehavior);
|
| + sk_sp<SkImage> firstFrame = frameAtIndex(0);
|
| if (firstFrame)
|
| return StaticBitmapImage::create(std::move(firstFrame));
|
| }
|
| @@ -412,9 +398,8 @@ bool BitmapImage::currentFrameKnownToBeOpaque(MetadataMode metadataMode) {
|
| if (metadataMode == PreCacheMetadata) {
|
| // frameHasAlphaAtIndex() conservatively returns false for uncached frames.
|
| // To increase the chance of an accurate answer, pre-cache the current frame
|
| - // metadata. Because ColorBehavior does not affect this result, use
|
| - // whatever ColorBehavior was last used (if any).
|
| - frameAtIndex(currentFrame(), m_cachedFrameColorBehavior);
|
| + // metadata.
|
| + frameAtIndex(currentFrame());
|
| }
|
| return !frameHasAlphaAtIndex(currentFrame());
|
| }
|
| @@ -424,10 +409,7 @@ bool BitmapImage::currentFrameIsComplete() {
|
| }
|
|
|
| bool BitmapImage::currentFrameIsLazyDecoded() {
|
| - // Because ColorBehavior does not affect this result, use whatever
|
| - // ColorBehavior was last used (if any).
|
| - sk_sp<SkImage> image =
|
| - frameAtIndex(currentFrame(), m_cachedFrameColorBehavior);
|
| + sk_sp<SkImage> image = frameAtIndex(currentFrame());
|
| return image && image->isLazyGenerated();
|
| }
|
|
|
|
|