Add View->FP helper to SkImage_Base, use instead of GrTextureAdjuster.
Remove now-unused functionality from GrTextureProducer/Adjuster. Bug: skia:11877 Change-Id: I34225397e730db36c6dc3e8c4815e41a147acb1d Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-PreAbandonGpuContext Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402638 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
3934647d22
commit
e74638b83f
@ -77,23 +77,3 @@ GrSurfaceProxyView GrTextureAdjuster::onView(GrMipmapped mipMapped) {
|
||||
SkASSERT(copy.asTextureProxy());
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState samplerState) {
|
||||
return this->createFragmentProcessorForView(
|
||||
this->view(samplerState.mipmapped()), textureMatrix, subset, domain, samplerState);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createBicubicFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState::WrapMode wrapX,
|
||||
GrSamplerState::WrapMode wrapY,
|
||||
SkImage::CubicResampler kernel) {
|
||||
return this->createBicubicFragmentProcessorForView(
|
||||
this->view(GrMipmapped::kNo), textureMatrix, subset, domain, wrapX, wrapY, kernel);
|
||||
}
|
||||
|
@ -23,19 +23,6 @@ public:
|
||||
GrTextureAdjuster(GrRecordingContext*, GrSurfaceProxyView, const GrColorInfo&,
|
||||
uint32_t uniqueID);
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState) override;
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> createBicubicFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState::WrapMode wrapX,
|
||||
GrSamplerState::WrapMode wrapY,
|
||||
SkImage::CubicResampler) override;
|
||||
|
||||
private:
|
||||
GrSurfaceProxyView onView(GrMipmapped) override;
|
||||
|
||||
|
@ -20,71 +20,6 @@
|
||||
#include "src/gpu/effects/GrBicubicEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureProducer::createFragmentProcessorForView(
|
||||
GrSurfaceProxyView view,
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState samplerState) {
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
SkRect tempSubset;
|
||||
|
||||
if (!subset && !view.proxy()->isFullyLazy() && !view.proxy()->isFunctionallyExact()) {
|
||||
tempSubset = view.proxy()->getBoundsRect();
|
||||
subset = &tempSubset;
|
||||
}
|
||||
|
||||
const auto& caps = *fContext->priv().caps();
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrTextureEffect::MakeSubset(std::move(view), this->alphaType(), textureMatrix,
|
||||
samplerState, *subset, *domain, caps);
|
||||
} else {
|
||||
return GrTextureEffect::MakeSubset(std::move(view), this->alphaType(), textureMatrix,
|
||||
samplerState, *subset, caps);
|
||||
}
|
||||
} else {
|
||||
return GrTextureEffect::Make(std::move(view), this->alphaType(), textureMatrix,
|
||||
samplerState, caps);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureProducer::createBicubicFragmentProcessorForView(
|
||||
GrSurfaceProxyView view,
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState::WrapMode wrapX,
|
||||
GrSamplerState::WrapMode wrapY,
|
||||
SkImage::CubicResampler kernel) {
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
SkRect tempSubset;
|
||||
|
||||
if (!subset && !view.proxy()->isFullyLazy() && !view.proxy()->isFunctionallyExact()) {
|
||||
tempSubset = view.proxy()->getBoundsRect();
|
||||
subset = &tempSubset;
|
||||
}
|
||||
|
||||
const auto& caps = *fContext->priv().caps();
|
||||
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrBicubicEffect::MakeSubset(std::move(view), this->alphaType(), textureMatrix,
|
||||
wrapX, wrapY, *subset, *domain, kernel, kDir, caps);
|
||||
} else {
|
||||
return GrBicubicEffect::MakeSubset(std::move(view), this->alphaType(), textureMatrix,
|
||||
wrapX, wrapY, *subset, kernel, kDir, caps);
|
||||
}
|
||||
} else {
|
||||
return GrBicubicEffect::Make(std::move(view), this->alphaType(), textureMatrix, wrapX,
|
||||
wrapY, kernel, kDir, caps);
|
||||
}
|
||||
}
|
||||
|
||||
GrSurfaceProxyView GrTextureProducer::view(GrMipmapped mipMapped) {
|
||||
const GrCaps* caps = this->context()->priv().caps();
|
||||
// Sanitize the MIP map request.
|
||||
|
@ -34,53 +34,6 @@ class GrTextureProducer : public SkNoncopyable {
|
||||
public:
|
||||
virtual ~GrTextureProducer() = default;
|
||||
|
||||
/**
|
||||
* Helper for creating a fragment processor to sample the texture with a given filtering mode.
|
||||
* Attempts to avoid unnecessary copies (e.g. for planar sources or subsets) by generating more
|
||||
* complex shader code.
|
||||
*
|
||||
* @param textureMatrix Matrix used to access the texture. It is applied to
|
||||
* the local coords. The post-transformed coords should
|
||||
* be in texel units (rather than normalized) with
|
||||
* respect to this Producer's bounds (width()/height()).
|
||||
* @param subset If not null, a subset of the texture to restrict
|
||||
* sampling to. The wrap modes apply to this subset.
|
||||
* @param domain If not null, a known limit on the texture coordinates
|
||||
* that will be accessed. Applies after textureMatrix.
|
||||
* @param sampler Sampler state. Wrap modes applies to subset if not
|
||||
* null, otherwise to the entire source.
|
||||
**/
|
||||
virtual std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState sampler) = 0;
|
||||
|
||||
/**
|
||||
* Similar createFragmentProcessor but produces a fragment processor that does bicubic
|
||||
* interpolation of the source. Attempts to avoid unnecessary copies (e.g. for planar sources or
|
||||
* subsets) by generating more complex shader code.
|
||||
*
|
||||
* @param textureMatrix Matrix used to access the texture. It is applied to
|
||||
* the local coords. The post-transformed coords should
|
||||
* be in texel units (rather than normalized) with
|
||||
* respect to this Producer's bounds (width()/height()).
|
||||
* @param subset If not null, a subset of the texture to restrict
|
||||
* sampling to. The wrap modes apply to this subset.
|
||||
* @param domain If not null, a known limit on the texture coordinates
|
||||
* that will be accessed. Applies after textureMatrix.
|
||||
* @param wrapX Wrap mode on x axis. Applied to subset if not null,
|
||||
* otherwise to the entire source.
|
||||
* @param wrapY Wrap mode on y axis. Applied to subset if not null,
|
||||
* otherwise to the entire source.
|
||||
*/
|
||||
virtual std::unique_ptr<GrFragmentProcessor> createBicubicFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState::WrapMode wrapX,
|
||||
GrSamplerState::WrapMode wrapY,
|
||||
SkImage::CubicResampler kernel) = 0;
|
||||
|
||||
/**
|
||||
* Returns a texture view, possibly with MIP maps. The request for MIP maps may not be honored
|
||||
@ -89,38 +42,15 @@ public:
|
||||
*/
|
||||
GrSurfaceProxyView view(GrMipmapped);
|
||||
|
||||
const GrColorInfo& colorInfo() const { return fImageInfo.colorInfo(); }
|
||||
int width() const { return fImageInfo.width(); }
|
||||
int height() const { return fImageInfo.height(); }
|
||||
SkISize dimensions() const { return fImageInfo.dimensions(); }
|
||||
GrColorType colorType() const { return fImageInfo.colorType(); }
|
||||
SkAlphaType alphaType() const { return fImageInfo.alphaType(); }
|
||||
SkColorSpace* colorSpace() const { return fImageInfo.colorSpace(); }
|
||||
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fImageInfo.colorType()); }
|
||||
/* Is it a planar image consisting of multiple textures that may have different resolutions? */
|
||||
virtual bool isPlanar() const { return false; }
|
||||
|
||||
protected:
|
||||
GrTextureProducer(GrRecordingContext* context, const GrImageInfo& imageInfo)
|
||||
: fContext(context), fImageInfo(imageInfo) {}
|
||||
|
||||
// Helper for making a texture effect from a single proxy view.
|
||||
std::unique_ptr<GrFragmentProcessor> createFragmentProcessorForView(
|
||||
GrSurfaceProxyView view,
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState sampler);
|
||||
|
||||
// Helper for making a bicubic effect from a single proxy view.
|
||||
std::unique_ptr<GrFragmentProcessor> createBicubicFragmentProcessorForView(
|
||||
GrSurfaceProxyView view,
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain,
|
||||
GrSamplerState::WrapMode wrapX,
|
||||
GrSamplerState::WrapMode wrapY,
|
||||
SkImage::CubicResampler kernel);
|
||||
|
||||
GrRecordingContext* context() const { return fContext; }
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "src/gpu/GrImageContextPriv.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBicubicEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/image/SkImage_Gpu.h"
|
||||
#endif
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
@ -337,6 +339,79 @@ std::unique_ptr<GrFragmentProcessor> SkImage_Base::asFragmentProcessor(
|
||||
}
|
||||
return this->onAsFragmentProcessor(rContext, sampling, tileModes, m, subset, domain);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> SkImage_Base::MakeFragmentProcessorFromView(
|
||||
GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView view,
|
||||
SkAlphaType at,
|
||||
SkSamplingOptions sampling,
|
||||
const SkTileMode tileModes[2],
|
||||
const SkMatrix& m,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain) {
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
const GrCaps& caps = *rContext->priv().caps();
|
||||
auto wmx = SkTileModeToWrapMode(tileModes[0]);
|
||||
auto wmy = SkTileModeToWrapMode(tileModes[1]);
|
||||
if (sampling.useCubic) {
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrBicubicEffect::MakeSubset(std::move(view),
|
||||
at,
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
*subset,
|
||||
*domain,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*rContext->priv().caps());
|
||||
}
|
||||
return GrBicubicEffect::MakeSubset(std::move(view),
|
||||
at,
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
*subset,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*rContext->priv().caps());
|
||||
}
|
||||
return GrBicubicEffect::Make(std::move(view),
|
||||
at,
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*rContext->priv().caps());
|
||||
}
|
||||
if (view.proxy()->asTextureProxy()->mipmapped() == GrMipmapped::kNo) {
|
||||
sampling = SkSamplingOptions(sampling.filter);
|
||||
}
|
||||
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrTextureEffect::MakeSubset(std::move(view),
|
||||
at,
|
||||
m,
|
||||
sampler,
|
||||
*subset,
|
||||
*domain,
|
||||
caps);
|
||||
}
|
||||
return GrTextureEffect::MakeSubset(std::move(view),
|
||||
at,
|
||||
m,
|
||||
sampler,
|
||||
*subset,
|
||||
caps);
|
||||
} else {
|
||||
return GrTextureEffect::Make(std::move(view), at, m, sampler, caps);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GrBackendTexture SkImage_Base::onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
|
@ -173,6 +173,15 @@ protected:
|
||||
GrSurfaceProxyView src,
|
||||
GrMipmapped,
|
||||
GrImageTexGenPolicy);
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> MakeFragmentProcessorFromView(GrRecordingContext*,
|
||||
GrSurfaceProxyView,
|
||||
SkAlphaType,
|
||||
SkSamplingOptions,
|
||||
const SkTileMode[2],
|
||||
const SkMatrix&,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -854,19 +854,15 @@ std::unique_ptr<GrFragmentProcessor> SkImage_Gpu::onAsFragmentProcessor(
|
||||
if (!fContext->priv().matches(rContext)) {
|
||||
return {};
|
||||
}
|
||||
GrSurfaceProxyView view = this->makeView(rContext);
|
||||
GrColorType ct = SkColorTypeAndFormatToGrColorType(rContext->priv().caps(),
|
||||
this->colorType(),
|
||||
view.proxy()->backendFormat());
|
||||
GrColorInfo colorInfo(ct, this->alphaType(), this->refColorSpace());
|
||||
GrTextureAdjuster adjuster(rContext, std::move(view), colorInfo, this->uniqueID());
|
||||
auto wmx = SkTileModeToWrapMode(tileModes[0]);
|
||||
auto wmy = SkTileModeToWrapMode(tileModes[1]);
|
||||
if (sampling.useCubic) {
|
||||
return adjuster.createBicubicFragmentProcessor(m, subset, domain, wmx, wmy, sampling.cubic);
|
||||
}
|
||||
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
|
||||
return adjuster.createFragmentProcessor(m, subset, domain, sampler);
|
||||
auto mm = sampling.mipmap == SkMipmapMode::kNone ? GrMipmapped::kNo : GrMipmapped::kYes;
|
||||
return MakeFragmentProcessorFromView(rContext,
|
||||
std::get<0>(this->asView(rContext, mm)),
|
||||
this->alphaType(),
|
||||
sampling,
|
||||
tileModes,
|
||||
m,
|
||||
subset,
|
||||
domain);
|
||||
}
|
||||
|
||||
GrSurfaceProxyView SkImage_Gpu::makeView(GrRecordingContext* rContext) const {
|
||||
|
@ -264,23 +264,15 @@ std::unique_ptr<GrFragmentProcessor> SkImage_Lazy::onAsFragmentProcessor(
|
||||
const SkRect* domain) const {
|
||||
// TODO: If the CPU data is extracted as planes return a FP that reconstructs the image from
|
||||
// the planes.
|
||||
auto wmx = SkTileModeToWrapMode(tileModes[0]);
|
||||
auto wmy = SkTileModeToWrapMode(tileModes[1]);
|
||||
auto mm = sampling.mipmap == SkMipmapMode::kNone ? GrMipmapped::kNo : GrMipmapped::kYes;
|
||||
auto [view, ct] = this->asView(rContext, mm);
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
GrColorInfo info = this->imageInfo().colorInfo();
|
||||
info = info.makeColorType(ct);
|
||||
// We pass the invalid unique ID here because our above call to asView() should have already
|
||||
// made and cached a mipmapped texture if mipmapping was called for.
|
||||
GrTextureAdjuster adjuster(rContext, std::move(view), std::move(info), SK_InvalidUniqueID);
|
||||
if (sampling.useCubic) {
|
||||
return adjuster.createBicubicFragmentProcessor(m, subset, domain, wmx, wmy, sampling.cubic);
|
||||
}
|
||||
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
|
||||
return adjuster.createFragmentProcessor(m, subset, domain, sampler);
|
||||
return MakeFragmentProcessorFromView(rContext,
|
||||
std::get<0>(this->asView(rContext, mm)),
|
||||
this->alphaType(),
|
||||
sampling,
|
||||
tileModes,
|
||||
m,
|
||||
subset,
|
||||
domain);
|
||||
}
|
||||
|
||||
GrSurfaceProxyView SkImage_Lazy::textureProxyViewFromPlanes(GrRecordingContext* ctx,
|
||||
|
@ -440,73 +440,20 @@ std::tuple<GrSurfaceProxyView, GrColorType> SkImage_Raster::onAsView(
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> SkImage_Raster::onAsFragmentProcessor(
|
||||
GrRecordingContext* context,
|
||||
GrRecordingContext* rContext,
|
||||
SkSamplingOptions sampling,
|
||||
const SkTileMode tileModes[2],
|
||||
const SkMatrix& m,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain) const {
|
||||
auto mm = sampling.mipmap == SkMipmapMode::kNone ? GrMipmapped::kNo : GrMipmapped::kYes;
|
||||
auto [view, ct] = this->asView(context, mm);
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
const GrCaps& caps = *context->priv().caps();
|
||||
auto wmx = SkTileModeToWrapMode(tileModes[0]);
|
||||
auto wmy = SkTileModeToWrapMode(tileModes[1]);
|
||||
if (sampling.useCubic) {
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrBicubicEffect::MakeSubset(std::move(view),
|
||||
this->alphaType(),
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
*subset,
|
||||
*domain,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*context->priv().caps());
|
||||
}
|
||||
return GrBicubicEffect::MakeSubset(std::move(view),
|
||||
this->alphaType(),
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
*subset,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*context->priv().caps());
|
||||
}
|
||||
return GrBicubicEffect::Make(std::move(view),
|
||||
this->alphaType(),
|
||||
m,
|
||||
wmx,
|
||||
wmy,
|
||||
sampling.cubic,
|
||||
GrBicubicEffect::Direction::kXY,
|
||||
*context->priv().caps());
|
||||
}
|
||||
|
||||
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
|
||||
if (subset) {
|
||||
if (domain) {
|
||||
return GrTextureEffect::MakeSubset(std::move(view),
|
||||
this->alphaType(),
|
||||
m,
|
||||
sampler,
|
||||
*subset,
|
||||
*domain,
|
||||
caps);
|
||||
}
|
||||
return GrTextureEffect::MakeSubset(std::move(view),
|
||||
this->alphaType(),
|
||||
m,
|
||||
sampler,
|
||||
*subset,
|
||||
caps);
|
||||
} else {
|
||||
return GrTextureEffect::Make(std::move(view), this->alphaType(), m, sampler, caps);
|
||||
}
|
||||
return MakeFragmentProcessorFromView(rContext,
|
||||
std::get<0>(this->asView(rContext, mm)),
|
||||
this->alphaType(),
|
||||
sampling,
|
||||
tileModes,
|
||||
m,
|
||||
subset,
|
||||
domain);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user