diff options
Diffstat (limited to 'chromium/third_party/skia/src/android')
5 files changed, 2 insertions, 277 deletions
diff --git a/chromium/third_party/skia/src/android/SkAnimatedImage.cpp b/chromium/third_party/skia/src/android/SkAnimatedImage.cpp index 3ae8a843ba4..966f150aa89 100644 --- a/chromium/third_party/skia/src/android/SkAnimatedImage.cpp +++ b/chromium/third_party/skia/src/android/SkAnimatedImage.cpp @@ -92,10 +92,10 @@ SkAnimatedImage::SkAnimatedImage(std::unique_ptr<SkAndroidCodec> codec, SkISize } if (!fSimple) { - fMatrix = SkMatrix::MakeTrans(-fCropRect.fLeft, -fCropRect.fTop); + fMatrix = SkMatrix::Translate(-fCropRect.fLeft, -fCropRect.fTop); float scaleX = (float) fScaledSize.width() / fDecodeInfo.width(); float scaleY = (float) fScaledSize.height() / fDecodeInfo.height(); - fMatrix.preConcat(SkMatrix::MakeScale(scaleX, scaleY)); + fMatrix.preConcat(SkMatrix::Scale(scaleX, scaleY)); } this->decodeNextFrame(); } diff --git a/chromium/third_party/skia/src/android/SkBitmapRegionCodec.cpp b/chromium/third_party/skia/src/android/SkBitmapRegionCodec.cpp deleted file mode 100644 index 081d0bbf3bc..00000000000 --- a/chromium/third_party/skia/src/android/SkBitmapRegionCodec.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "include/codec/SkAndroidCodec.h" -#include "src/android/SkBitmapRegionCodec.h" -#include "src/android/SkBitmapRegionDecoderPriv.h" -#include "src/codec/SkCodecPriv.h" - -SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec) - : INHERITED(codec->getInfo().width(), codec->getInfo().height()) - , fCodec(codec) -{} - -bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator, - const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType, - bool requireUnpremul, sk_sp<SkColorSpace> dstColorSpace) { - - // Fix the input sampleSize if necessary. - if (sampleSize < 1) { - sampleSize = 1; - } - - // The size of the output bitmap is determined by the size of the - // requested subset, not by the size of the intersection of the subset - // and the image dimensions. - // If inputX is negative, we will need to place decoded pixels into the - // output bitmap starting at a left offset. Call this outX. - // If outX is non-zero, subsetX must be zero. - // If inputY is negative, we will need to place decoded pixels into the - // output bitmap starting at a top offset. Call this outY. - // If outY is non-zero, subsetY must be zero. - int outX; - int outY; - SkIRect subset = desiredSubset; - SubsetType type = adjust_subset_rect(fCodec->getInfo().dimensions(), &subset, &outX, &outY); - if (SubsetType::kOutside_SubsetType == type) { - return false; - } - - // Ask the codec for a scaled subset - if (!fCodec->getSupportedSubset(&subset)) { - SkCodecPrintf("Error: Could not get subset.\n"); - return false; - } - SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset); - - // Create the image info for the decode - SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul); - SkImageInfo decodeInfo = - SkImageInfo::Make(scaledSize, dstColorType, dstAlphaType, dstColorSpace); - - // Initialize the destination bitmap - int scaledOutX = 0; - int scaledOutY = 0; - int scaledOutWidth = scaledSize.width(); - int scaledOutHeight = scaledSize.height(); - if (SubsetType::kPartiallyInside_SubsetType == type) { - scaledOutX = outX / sampleSize; - scaledOutY = outY / sampleSize; - // We need to be safe here because getSupportedSubset() may have modified the subset. - const int extraX = std::max(0, desiredSubset.width() - outX - subset.width()); - const int extraY = std::max(0, desiredSubset.height() - outY - subset.height()); - const int scaledExtraX = extraX / sampleSize; - const int scaledExtraY = extraY / sampleSize; - scaledOutWidth += scaledOutX + scaledExtraX; - scaledOutHeight += scaledOutY + scaledExtraY; - } - SkImageInfo outInfo = decodeInfo.makeWH(scaledOutWidth, scaledOutHeight); - if (kGray_8_SkColorType == dstColorType) { - // The legacy implementations of BitmapFactory and BitmapRegionDecoder - // used kAlpha8 for grayscale images (before kGray8 existed). While - // the codec recognizes kGray8, we need to decode into a kAlpha8 - // bitmap in order to avoid a behavior change. - outInfo = outInfo.makeColorType(kAlpha_8_SkColorType).makeAlphaType(kPremul_SkAlphaType); - } - bitmap->setInfo(outInfo); - if (!bitmap->tryAllocPixels(allocator)) { - SkCodecPrintf("Error: Could not allocate pixels.\n"); - return false; - } - - // Zero the bitmap if the region is not completely within the image. - // TODO (msarett): Can we make this faster by implementing it to only - // zero parts of the image that we won't overwrite with - // pixels? - SkCodec::ZeroInitialized zeroInit = allocator ? allocator->zeroInit() : - SkCodec::kNo_ZeroInitialized; - if (SubsetType::kPartiallyInside_SubsetType == type && - SkCodec::kNo_ZeroInitialized == zeroInit) { - void* pixels = bitmap->getPixels(); - size_t bytes = outInfo.computeByteSize(bitmap->rowBytes()); - memset(pixels, 0, bytes); - } - - // Decode into the destination bitmap - SkAndroidCodec::AndroidOptions options; - options.fSampleSize = sampleSize; - options.fSubset = ⊂ - options.fZeroInitialized = zeroInit; - void* dst = bitmap->getAddr(scaledOutX, scaledOutY); - - SkCodec::Result result = fCodec->getAndroidPixels(decodeInfo, dst, bitmap->rowBytes(), - &options); - switch (result) { - case SkCodec::kSuccess: - case SkCodec::kIncompleteInput: - case SkCodec::kErrorInInput: - return true; - default: - SkCodecPrintf("Error: Could not get pixels with message \"%s\".\n", - SkCodec::ResultToString(result)); - return false; - } -} diff --git a/chromium/third_party/skia/src/android/SkBitmapRegionCodec.h b/chromium/third_party/skia/src/android/SkBitmapRegionCodec.h deleted file mode 100644 index 21859514af9..00000000000 --- a/chromium/third_party/skia/src/android/SkBitmapRegionCodec.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkBitmapRegionCodec_DEFINED -#define SkBitmapRegionCodec_DEFINED - -#include "include/android/SkBitmapRegionDecoder.h" -#include "include/codec/SkAndroidCodec.h" -#include "include/core/SkBitmap.h" - -/* - * This class implements SkBitmapRegionDecoder using an SkAndroidCodec. - */ -class SkBitmapRegionCodec : public SkBitmapRegionDecoder { -public: - - /* - * Takes ownership of pointer to codec - */ - SkBitmapRegionCodec(SkAndroidCodec* codec); - - bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator, - const SkIRect& desiredSubset, int sampleSize, - SkColorType colorType, bool requireUnpremul, - sk_sp<SkColorSpace> prefColorSpace) override; - - SkEncodedImageFormat getEncodedFormat() override { return fCodec->getEncodedFormat(); } - - SkColorType computeOutputColorType(SkColorType requestedColorType) override { - return fCodec->computeOutputColorType(requestedColorType); - } - - sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType, - sk_sp<SkColorSpace> prefColorSpace = nullptr) override { - return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace); - } - -private: - - std::unique_ptr<SkAndroidCodec> fCodec; - - typedef SkBitmapRegionDecoder INHERITED; - -}; -#endif // SkBitmapRegionCodec_DEFINED diff --git a/chromium/third_party/skia/src/android/SkBitmapRegionDecoder.cpp b/chromium/third_party/skia/src/android/SkBitmapRegionDecoder.cpp deleted file mode 100644 index 328daa3bc97..00000000000 --- a/chromium/third_party/skia/src/android/SkBitmapRegionDecoder.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "include/android/SkBitmapRegionDecoder.h" -#include "include/codec/SkAndroidCodec.h" -#include "include/codec/SkCodec.h" -#include "src/android/SkBitmapRegionCodec.h" -#include "src/codec/SkCodecPriv.h" - -SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( - sk_sp<SkData> data, Strategy strategy) { - return SkBitmapRegionDecoder::Create(new SkMemoryStream(data), - strategy); -} - -SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( - SkStreamRewindable* stream, Strategy strategy) { - std::unique_ptr<SkStreamRewindable> streamDeleter(stream); - switch (strategy) { - case kAndroidCodec_Strategy: { - auto codec = SkAndroidCodec::MakeFromStream(std::move(streamDeleter)); - if (nullptr == codec) { - SkCodecPrintf("Error: Failed to create codec.\n"); - return nullptr; - } - - switch ((SkEncodedImageFormat)codec->getEncodedFormat()) { - case SkEncodedImageFormat::kJPEG: - case SkEncodedImageFormat::kPNG: - case SkEncodedImageFormat::kWEBP: - case SkEncodedImageFormat::kHEIF: - break; - default: - return nullptr; - } - - return new SkBitmapRegionCodec(codec.release()); - } - default: - SkASSERT(false); - return nullptr; - } -} diff --git a/chromium/third_party/skia/src/android/SkBitmapRegionDecoderPriv.h b/chromium/third_party/skia/src/android/SkBitmapRegionDecoderPriv.h deleted file mode 100644 index 905d460c5c6..00000000000 --- a/chromium/third_party/skia/src/android/SkBitmapRegionDecoderPriv.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkBitmapRegionDecoderPriv_DEFINED -#define SkBitmapRegionDecoderPriv_DEFINED - -#include "include/core/SkRect.h" - -enum SubsetType { - kFullyInside_SubsetType, - kPartiallyInside_SubsetType, - kOutside_SubsetType, -}; - -/* - * Corrects image subset offsets and dimensions in order to perform a valid decode. - * Also indicates if the image subset should be placed at an offset within the - * output bitmap. - * - * Values of output variables are undefined if the SubsetType is kInvalid. - * - * @param imageDims Original image dimensions. - * @param subset As input, the subset that the client requested. - * As output, the image subset that we will decode. - * @param outX The left offset of the image subset within the output bitmap. - * @param outY The top offset of the image subset within the output bitmap. - * - * @return An indication of how the subset is contained in the image. - * If the return value is kInvalid, values of output variables are undefined. - */ -inline SubsetType adjust_subset_rect(const SkISize& imageDims, SkIRect* subset, int* outX, - int* outY) { - // These must be at least zero, we can't start decoding the image at a negative coordinate. - int left = std::max(0, subset->fLeft); - int top = std::max(0, subset->fTop); - - // If input offsets are less than zero, we decode to an offset location in the output bitmap. - *outX = left - subset->fLeft; - *outY = top - subset->fTop; - - // Make sure we don't decode pixels past the edge of the image or past the edge of the subset. - int width = std::min(imageDims.width() - left, subset->width() - *outX); - int height = std::min(imageDims.height() - top, subset->height() - *outY); - if (width <= 0 || height <= 0) { - return SubsetType::kOutside_SubsetType; - } - - subset->setXYWH(left, top, width, height); - if ((*outX != 0) || (*outY != 0) || (width != subset->width()) || - (height != subset->height())) { - return SubsetType::kPartiallyInside_SubsetType; - } - - return SubsetType::kFullyInside_SubsetType; -} - -#endif // SkBitmapRegionDecoderPriv_DEFINED |