diff options
-rw-r--r-- | gm/image_pict.cpp | 3 | ||||
-rw-r--r-- | include/core/SkImageGenerator.h | 11 | ||||
-rw-r--r-- | src/core/SkColorSpaceXformImageGenerator.cpp | 2 | ||||
-rw-r--r-- | src/core/SkColorSpaceXformImageGenerator.h | 3 | ||||
-rw-r--r-- | src/core/SkImageGenerator.cpp | 8 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.cpp | 2 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.h | 3 | ||||
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.h | 3 | ||||
-rw-r--r-- | src/gpu/GrBackendTextureImageGenerator.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrBackendTextureImageGenerator.h | 3 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 6 |
12 files changed, 30 insertions, 18 deletions
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index 25c3b1c085..0e39d3b997 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -165,7 +165,8 @@ public: protected: sk_sp<GrTextureProxy> onGenerateTexture(GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior) override { + SkTransferFunctionBehavior, + bool willBeMipped) override { SkASSERT(ctx); SkASSERT(ctx == fCtx.get()); diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index edd2f8d564..0dae7d7489 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -140,10 +140,16 @@ public: * It must be non-NULL. The generator should only succeed if: * - its internal context is the same * - it can somehow convert its texture into one that is valid for the provided context. + * + * If the willNeedMipMaps flag is true, the generator should try to create a TextureProxy that + * at least has the mip levels allocated and the base layer filled in. If this is not possible, + * the generator is allowed to return a non mipped proxy, but this will have some additional + * overhead in later allocating mips and copying of the base layer. */ sk_sp<GrTextureProxy> generateTexture(GrContext*, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior behavior); + SkTransferFunctionBehavior behavior, + bool willNeedMipMaps); #endif /** @@ -185,7 +191,8 @@ protected: virtual TexGenType onCanGenerateTexture() const { return TexGenType::kNone; } virtual sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior); // returns nullptr + SkTransferFunctionBehavior, + bool willNeedMipMaps); // returns nullptr #endif private: diff --git a/src/core/SkColorSpaceXformImageGenerator.cpp b/src/core/SkColorSpaceXformImageGenerator.cpp index ea277fe410..94566d5d2a 100644 --- a/src/core/SkColorSpaceXformImageGenerator.cpp +++ b/src/core/SkColorSpaceXformImageGenerator.cpp @@ -64,7 +64,7 @@ bool SkColorSpaceXformImageGenerator::onGetPixels(const SkImageInfo& info, void* sk_sp<GrTextureProxy> SkColorSpaceXformImageGenerator::onGenerateTexture( GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior) { + SkTransferFunctionBehavior, bool willNeedMipMaps) { // FIXME: // This always operates as if SkTranferFunctionBehavior is kIgnore. Should we add // options so that caller can also request kRespect? diff --git a/src/core/SkColorSpaceXformImageGenerator.h b/src/core/SkColorSpaceXformImageGenerator.h index ab72eba9ff..3fd6b94a23 100644 --- a/src/core/SkColorSpaceXformImageGenerator.h +++ b/src/core/SkColorSpaceXformImageGenerator.h @@ -23,7 +23,8 @@ protected: #if SK_SUPPORT_GPU sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior) override; + SkTransferFunctionBehavior, + bool willNeedMipMaps) override; TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; } diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index a3e825302b..865a718e44 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -66,17 +66,19 @@ bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes sk_sp<GrTextureProxy> SkImageGenerator::generateTexture(GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior behavior) { + SkTransferFunctionBehavior behavior, + bool willNeedMipMaps) { SkIRect srcRect = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height()); if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(srcRect)) { return nullptr; } - return this->onGenerateTexture(ctx, info, origin, behavior); + return this->onGenerateTexture(ctx, info, origin, behavior, willNeedMipMaps); } sk_sp<GrTextureProxy> SkImageGenerator::onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior) { + SkTransferFunctionBehavior, + bool willNeedMipMaps) { return nullptr; } #endif diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index 75861329d6..f6c36ca93c 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -102,7 +102,7 @@ SkImageGenerator::MakeFromPicture(const SkISize& size, sk_sp<SkPicture> picture, #if SK_SUPPORT_GPU sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture( GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior behavior) { + SkTransferFunctionBehavior behavior, bool willNeedMipMaps) { SkASSERT(ctx); bool useXformCanvas = SkTransferFunctionBehavior::kIgnore == behavior && info.colorSpace(); diff --git a/src/core/SkPictureImageGenerator.h b/src/core/SkPictureImageGenerator.h index f2ebc809c9..4c5f8e3a75 100644 --- a/src/core/SkPictureImageGenerator.h +++ b/src/core/SkPictureImageGenerator.h @@ -23,7 +23,8 @@ protected: #if SK_SUPPORT_GPU TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior) override; + SkTransferFunctionBehavior, + bool willNeedMipMaps) override; #endif private: diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index ba8e9d7486..164e3d6d45 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -98,7 +98,7 @@ void GrAHardwareBufferImageGenerator::deleteImageTexture(void* context) { sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture( GrContext* context, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior) { + SkTransferFunctionBehavior, bool willNeedMipMaps) { auto proxy = this->makeProxy(context); if (!proxy) { return nullptr; diff --git a/src/gpu/GrAHardwareBufferImageGenerator.h b/src/gpu/GrAHardwareBufferImageGenerator.h index f270d6ac9b..e1814f8b47 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.h +++ b/src/gpu/GrAHardwareBufferImageGenerator.h @@ -36,7 +36,8 @@ protected: #if SK_SUPPORT_GPU TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior) override; + SkTransferFunctionBehavior, + bool willNeedMipMaps) override; #endif private: diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index cedc60cc5b..93596cf6bd 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -118,7 +118,7 @@ void GrBackendTextureImageGenerator::ReleaseRefHelper_TextureReleaseProc(void* c sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture( GrContext* context, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior) { + SkTransferFunctionBehavior, bool willNeedMipMaps) { SkASSERT(context); if (context->contextPriv().getBackend() != fBackendTexture.backend()) { diff --git a/src/gpu/GrBackendTextureImageGenerator.h b/src/gpu/GrBackendTextureImageGenerator.h index f99055ab86..bebb736750 100644 --- a/src/gpu/GrBackendTextureImageGenerator.h +++ b/src/gpu/GrBackendTextureImageGenerator.h @@ -30,7 +30,8 @@ protected: #if SK_SUPPORT_GPU TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior) override; + SkTransferFunctionBehavior, + bool willNeedMipMaps) override; #endif private: diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 5e3c037402..8e055f395e 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -788,10 +788,8 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) { return nullptr; } - // TODO: Pass a flag into generateTexture which says we want to be mipped. If the generator - // can handle creating a mipped surface, then it can either generate the base layer or all - // the layers directly. Otherwise it just returns a non mipped surface as it currently does. - if ((proxy = generator->generateTexture(ctx, genPixelsInfo, fOrigin, behavior))) { + if ((proxy = generator->generateTexture(ctx, genPixelsInfo, fOrigin, behavior, + willBeMipped))) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, kLockTexturePathCount); set_key_on_proxy(ctx->resourceProvider(), proxy.get(), nullptr, key); |