diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkCodecImageGenerator.cpp | 24 | ||||
-rw-r--r-- | src/codec/SkCodecImageGenerator.h | 4 | ||||
-rw-r--r-- | src/core/SkBitmapController.cpp | 29 | ||||
-rw-r--r-- | src/core/SkBitmapProvider.cpp | 35 | ||||
-rw-r--r-- | src/core/SkBitmapProvider.h | 4 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 58 | ||||
-rw-r--r-- | src/core/SkDevice.h | 4 | ||||
-rw-r--r-- | src/core/SkImageCacherator.cpp | 7 | ||||
-rw-r--r-- | src/core/SkImageCacherator.h | 3 | ||||
-rw-r--r-- | src/core/SkImageGenerator.cpp | 20 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.cpp | 35 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.h | 2 |
12 files changed, 1 insertions, 224 deletions
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp index 0758878146..447332b2c7 100644 --- a/src/codec/SkCodecImageGenerator.cpp +++ b/src/codec/SkCodecImageGenerator.cpp @@ -47,30 +47,6 @@ bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s } } -bool SkCodecImageGenerator::onComputeScaledDimensions(SkScalar scale, SupportedSizes* sizes) { - SkASSERT(scale > 0 && scale <= 1); - const auto size = fCodec->getScaledDimensions(SkScalarToFloat(scale)); - if (size == this->getInfo().dimensions()) { - return false; - } - - // FIXME: Make SkCodec's API return two potential sizes, like this one. For now, set them both - // to be the same. - sizes->fSizes[0] = sizes->fSizes[1] = size; - return true; -} - -bool SkCodecImageGenerator::onGenerateScaledPixels(const SkPixmap& pixmap) { - if (pixmap.colorType() == kIndex_8_SkColorType) { - // There is no way to tell the client about the color table with this API. - return false; - } - - return this->onGetPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes(), - nullptr, nullptr); -} - - bool SkCodecImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { return fCodec->queryYUV8(sizeInfo, colorSpace); diff --git a/src/codec/SkCodecImageGenerator.h b/src/codec/SkCodecImageGenerator.h index 51086eb0a8..d771f4925d 100644 --- a/src/codec/SkCodecImageGenerator.h +++ b/src/codec/SkCodecImageGenerator.h @@ -33,10 +33,6 @@ protected: bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; - bool onComputeScaledDimensions(SkScalar, SupportedSizes*) override; - - bool onGenerateScaledPixels(const SkPixmap&) override; - private: /* * Takes ownership of codec diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp index 6a44a36645..bcc096c879 100644 --- a/src/core/SkBitmapController.cpp +++ b/src/core/SkBitmapController.cpp @@ -50,7 +50,6 @@ private: sk_sp<const SkMipMap> fCurrMip; bool fCanShadeHQ; - bool processExternalRequest(const SkBitmapProvider&); bool processHQRequest(const SkBitmapProvider&); bool processMediumRequest(const SkBitmapProvider&); }; @@ -71,28 +70,6 @@ static inline bool cache_size_okay(const SkBitmapProvider& provider, const SkMat } /* - * Image generators can provide access to externally managed pixels - * (external scale/decode caches). - */ -bool SkDefaultBitmapControllerState::processExternalRequest(const SkBitmapProvider& provider) { - // TODO: actual srcRect - - const SkRect src = SkRect::MakeIWH(provider.width(), provider.height()); - SkRect adjustedSrc; - - if (!provider.accessScaledImage(src, fInvMatrix, fQuality, - &fResultBitmap, &adjustedSrc, &fQuality)) { - return false; - } - - fInvMatrix.postConcat(SkMatrix::MakeRectToRect(src, adjustedSrc, SkMatrix::kFill_ScaleToFit)); - fResultBitmap.lockPixels(); - SkASSERT(fResultBitmap.getPixels()); - - return true; -} - -/* * High quality is implemented by performing up-right scale-only filtering and then * using bilerp for any remaining transformations. */ @@ -240,11 +217,7 @@ SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(const SkBitmapPro fQuality = qual; fCanShadeHQ = canShadeHQ; - bool processed = this->processExternalRequest(provider); - - // Externally handled requests are not guaranteed to reduce quality below kMedium -- so we - // always give our internal processors a shot. - processed |= this->processHQRequest(provider) || this->processMediumRequest(provider); + bool processed = this->processHQRequest(provider) || this->processMediumRequest(provider); if (processed) { SkASSERT(fResultBitmap.getPixels()); diff --git a/src/core/SkBitmapProvider.cpp b/src/core/SkBitmapProvider.cpp index 9575ae2cf8..928214c498 100644 --- a/src/core/SkBitmapProvider.cpp +++ b/src/core/SkBitmapProvider.cpp @@ -47,38 +47,3 @@ void SkBitmapProvider::notifyAddedToCache() const { bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint); } - -bool SkBitmapProvider::accessScaledImage(const SkRect& srcRect, - const SkMatrix& invMatrix, - SkFilterQuality fq, - SkBitmap* scaledBitmap, - SkRect* adjustedSrcRect, - SkFilterQuality* adjustedFilterQuality) const { - if (!fImage) { - return false; - } - - SkImageCacherator* cacherator = as_IB(fImage)->peekCacherator(); - if (!cacherator) { - return false; - } - - // TODO: stash the matrix someplace to avoid invert()? - SkMatrix m; - if (!invMatrix.invert(&m)) { - return false; - } - - SkImageGenerator::ScaledImageRec rec; - if (!cacherator->directAccessScaledImage(srcRect, m, fq, &rec) || - !scaledBitmap->installPixels(rec.fPixmap.info(), const_cast<void*>(rec.fPixmap.addr()), - rec.fPixmap.rowBytes(), rec.fPixmap.ctable(), - rec.fReleaseProc, rec.fReleaseCtx)) { - return false; - } - - *adjustedSrcRect = rec.fSrcRect; - *adjustedFilterQuality = rec.fQuality; - - return true; -} diff --git a/src/core/SkBitmapProvider.h b/src/core/SkBitmapProvider.h index 54f28772cf..f4904d4aa4 100644 --- a/src/core/SkBitmapProvider.h +++ b/src/core/SkBitmapProvider.h @@ -39,10 +39,6 @@ public: // ... cause a decode and cache, or gpu-readback bool asBitmap(SkBitmap*) const; - bool accessScaledImage(const SkRect& srcRect, const SkMatrix& invMatrix, SkFilterQuality fq, - SkBitmap* scaledBitmap, SkRect* adjustedSrcRect, - SkFilterQuality* adjustedFilterQuality) const; - private: // Stack-allocated only. void* operator new(size_t) = delete; diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 803cddd543..ad9df5b144 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -173,61 +173,8 @@ void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc } } -bool SkBaseDevice::drawExternallyScaledImage(const SkDraw& draw, - const SkImage* image, - const SkRect* src, - const SkRect& dst, - const SkPaint& paint, - SkCanvas::SrcRectConstraint constraint) { - SkImageCacherator* cacherator = as_IB(image)->peekCacherator(); - if (!cacherator) { - return false; - } - - SkTLazy<SkRect> tmpSrc(src); - if (!tmpSrc.isValid()) { - tmpSrc.init(SkRect::Make(image->bounds())); - } - - SkMatrix m = *draw.fMatrix; - m.preConcat(SkMatrix::MakeRectToRect(*tmpSrc.get(), dst, SkMatrix::kFill_ScaleToFit)); - - // constrain src to our bounds - if (!image->bounds().contains(*tmpSrc.get()) && - !tmpSrc.get()->intersect(SkRect::Make(image->bounds()))) { - return false; - } - - SkImageGenerator::ScaledImageRec rec; - if (!cacherator->directAccessScaledImage(*tmpSrc.get(), m, paint.getFilterQuality(), &rec)) { - return false; - } - - SkBitmap bm; - if (!bm.installPixels(rec.fPixmap.info(), const_cast<void*>(rec.fPixmap.addr()), - rec.fPixmap.rowBytes(), rec.fPixmap.ctable(), - rec.fReleaseProc, rec.fReleaseCtx)) { - return false; - } - - SkTCopyOnFirstWrite<SkPaint> adjustedPaint(paint); - if (rec.fQuality != paint.getFilterQuality()) { - adjustedPaint.writable()->setFilterQuality(rec.fQuality); - } - - this->drawBitmapRect(draw, bm, &rec.fSrcRect, dst, *adjustedPaint, constraint); - - return true; -} void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y, const SkPaint& paint) { - // Default impl : turns everything into raster bitmap - if (this->drawExternallyScaledImage(draw, image, nullptr, - SkRect::Make(image->bounds()).makeOffset(x, y), - paint, SkCanvas::kFast_SrcRectConstraint)) { - return; - } - SkBitmap bm; if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) { this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); @@ -237,11 +184,6 @@ void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, const SkRect& dst, const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) { - // Default impl : turns everything into raster bitmap - if (this->drawExternallyScaledImage(draw, image, src, dst, paint, constraint)) { - return; - } - SkBitmap bm; if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) { this->drawBitmapRect(draw, bm, src, dst, paint, constraint); diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index 3d1b558eab..2a481971cf 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -380,10 +380,6 @@ private: *const_cast<SkImageInfo*>(&fInfo) = fInfo.makeWH(w, h); } - bool drawExternallyScaledImage(const SkDraw& draw, const SkImage* image, const SkRect* src, - const SkRect& dst, const SkPaint& paint, - SkCanvas::SrcRectConstraint constraint); - SkIPoint fOrigin; const SkImageInfo fInfo; const SkSurfaceProps fSurfaceProps; diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 978564801e..4534851421 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -176,13 +176,6 @@ bool SkImageCacherator::directGeneratePixels(const SkImageInfo& info, void* pixe return generator->getPixels(info, pixels, rb); } -bool SkImageCacherator::directAccessScaledImage(const SkRect& srcRect, - const SkMatrix& totalMatrix, - SkFilterQuality fq, - SkImageGenerator::ScaledImageRec* rec) { - return ScopedGenerator(fSharedGenerator)->accessScaledImage(srcRect, totalMatrix, fq, rec); -} - ////////////////////////////////////////////////////////////////////////////////////////////////// bool SkImageCacherator::lockAsBitmapOnlyIfAlreadyCached(SkBitmap* bitmap, CachedFormat format) { diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h index c5c3e9777a..528dc0ee52 100644 --- a/src/core/SkImageCacherator.h +++ b/src/core/SkImageCacherator.h @@ -85,9 +85,6 @@ public: bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, int srcX, int srcY); - bool directAccessScaledImage(const SkRect& srcRect, const SkMatrix& totalMatrix, - SkFilterQuality, SkImageGenerator::ScaledImageRec*); - private: // Ref-counted tuple(SkImageGenerator, SkMutex) which allows sharing of one generator // among several cacherators. diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index c941605da8..b815fbfb77 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -86,26 +86,6 @@ GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkImageInfo& return this->onGenerateTexture(ctx, info, origin); } -bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* sizes) { - if (scale > 0 && scale <= 1) { - return this->onComputeScaledDimensions(scale, sizes); - } - return false; -} - -bool SkImageGenerator::generateScaledPixels(const SkPixmap& scaledPixels) { - if (scaledPixels.width() <= 0 || scaledPixels.height() <= 0) { - return false; - } - return this->onGenerateScaledPixels(scaledPixels); -} - -bool SkImageGenerator::accessScaledImage(const SkRect& src, const SkMatrix& matrix, - SkFilterQuality fq, ScaledImageRec* rec) { - SkASSERT(fInfo.bounds().contains(src)); - return this->onAccessScaledImage(src, matrix, fq, rec); -} - ///////////////////////////////////////////////////////////////////////////////////////////// SkData* SkImageGenerator::onRefEncodedData(GrContext* ctx) { diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index 5f69db647b..618312e1cd 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -73,41 +73,6 @@ bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, return true; } -bool SkPictureImageGenerator::onComputeScaledDimensions(SkScalar scale, - SupportedSizes* sizes) { - SkASSERT(scale > 0 && scale <= 1); - const int w = this->getInfo().width(); - const int h = this->getInfo().height(); - const int sw = SkScalarRoundToInt(scale * w); - const int sh = SkScalarRoundToInt(scale * h); - if (sw > 0 && sh > 0) { - sizes->fSizes[0].set(sw, sh); - sizes->fSizes[1].set(sw, sh); - return true; - } - return false; -} - -bool SkPictureImageGenerator::onGenerateScaledPixels(const SkPixmap& scaledPixels) { - int w = scaledPixels.width(); - int h = scaledPixels.height(); - - const SkScalar scaleX = SkIntToScalar(w) / this->getInfo().width(); - const SkScalar scaleY = SkIntToScalar(h) / this->getInfo().height(); - SkMatrix matrix = SkMatrix::MakeScale(scaleX, scaleY); - - SkBitmap bitmap; - if (!bitmap.installPixels(scaledPixels)) { - return false; - } - - bitmap.eraseColor(SK_ColorTRANSPARENT); - SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry)); - matrix.preConcat(fMatrix); - canvas.drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull()); - return true; -} - /////////////////////////////////////////////////////////////////////////////////////////////////// SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const SkPicture* picture, diff --git a/src/core/SkPictureImageGenerator.h b/src/core/SkPictureImageGenerator.h index aca9c2c169..4728d21a44 100644 --- a/src/core/SkPictureImageGenerator.h +++ b/src/core/SkPictureImageGenerator.h @@ -18,8 +18,6 @@ public: protected: bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) override; - bool onComputeScaledDimensions(SkScalar scale, SupportedSizes*) override; - bool onGenerateScaledPixels(const SkPixmap&) override; #if SK_SUPPORT_GPU GrTexture* onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&) override; |