Update generated effects to use views.

Bug: skia:9556
Change-Id: Iad4f7f2db2624e699184691d8aae2aaded81eb28
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270198
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-02-11 15:49:27 -05:00 committed by Skia Commit-Bot
parent 0234170cc6
commit 43956128ba
21 changed files with 307 additions and 275 deletions

View File

@ -289,8 +289,7 @@ public:
const char* name() const override { return "ColorTableEffect"; } const char* name() const override { return "ColorTableEffect"; }
std::unique_ptr<GrFragmentProcessor> clone() const override { std::unique_ptr<GrFragmentProcessor> clone() const override {
return std::unique_ptr<GrFragmentProcessor>( return std::unique_ptr<GrFragmentProcessor>(new ColorTableEffect(fTextureSampler.view()));
new ColorTableEffect(sk_ref_sp(fTextureSampler.view().proxy())));
} }
private: private:
@ -300,10 +299,11 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override { return true; } bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
ColorTableEffect(sk_sp<GrSurfaceProxy> proxy) ColorTableEffect(GrSurfaceProxyView view)
: INHERITED(kColorTableEffect_ClassID, : INHERITED(
kNone_OptimizationFlags) // Not bothering with table-specific optimizations. kColorTableEffect_ClassID,
, fTextureSampler(std::move(proxy)) { kNone_OptimizationFlags) // Not bothering with table-specific optimizations.
, fTextureSampler(std::move(view)) {
this->setTextureSamplerCnt(1); this->setTextureSamplerCnt(1);
} }
@ -378,11 +378,11 @@ std::unique_ptr<GrFragmentProcessor> ColorTableEffect::Make(GrRecordingContext*
SkASSERT(bitmap.isImmutable()); SkASSERT(bitmap.isImmutable());
auto view = GrMakeCachedBitmapProxyView(context, bitmap); auto view = GrMakeCachedBitmapProxyView(context, bitmap);
if (!view.proxy()) { if (!view) {
return nullptr; return nullptr;
} }
return std::unique_ptr<GrFragmentProcessor>(new ColorTableEffect(view.detachProxy())); return std::unique_ptr<GrFragmentProcessor>(new ColorTableEffect(std::move(view)));
} }
void ColorTableEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, void ColorTableEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,

View File

@ -45,9 +45,9 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override; sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> createMaskTexture(GrRecordingContext*, GrSurfaceProxyView createMaskTexture(GrRecordingContext*,
const SkMatrix&, const SkMatrix&,
const SkIRect& bounds) const; const SkIRect& bounds) const;
#endif #endif
private: private:
@ -100,13 +100,13 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context, GrSurfaceProxyView SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
const SkMatrix& inMatrix, const SkMatrix& inMatrix,
const SkIRect& bounds) const { const SkIRect& bounds) const {
auto rtContext = GrRenderTargetContext::MakeWithFallback( auto rtContext = GrRenderTargetContext::MakeWithFallback(
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size()); context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size());
if (!rtContext) { if (!rtContext) {
return nullptr; return {};
} }
SkRegion::Iterator iter(fRegion); SkRegion::Iterator iter(fRegion);
@ -125,7 +125,7 @@ sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingC
iter.next(); iter.next();
} }
return rtContext->asTextureProxyRef(); return rtContext->readSurfaceView();
} }
#endif #endif
@ -161,8 +161,8 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
SkMatrix matrix(ctx.ctm()); SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY)); matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY));
sk_sp<GrTextureProxy> maskProxy(this->createMaskTexture(context, matrix, bounds)); GrSurfaceProxyView maskView = this->createMaskTexture(context, matrix, bounds);
if (!maskProxy) { if (!maskView) {
return nullptr; return nullptr;
} }
@ -175,10 +175,8 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
return nullptr; return nullptr;
} }
auto thresholdFP = GrAlphaThresholdFragmentProcessor::Make(std::move(maskProxy), auto thresholdFP = GrAlphaThresholdFragmentProcessor::Make(
fInnerThreshold, std::move(maskView), fInnerThreshold, fOuterThreshold, bounds);
fOuterThreshold,
bounds);
if (!thresholdFP) { if (!thresholdFP) {
return nullptr; return nullptr;
} }

View File

@ -138,7 +138,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilterImpl::onFilterImage(const Context& c
(1.f - invYZoom) * input->subset().y()); (1.f - invYZoom) * input->subset().y());
// TODO: Update generated fp file Make functions to take views instead of proxies // TODO: Update generated fp file Make functions to take views instead of proxies
auto fp = GrMagnifierEffect::Make(inputView.detachProxy(), auto fp = GrMagnifierEffect::Make(std::move(inputView),
bounds, bounds,
srcRect, srcRect,
invXZoom, invXZoom,

View File

@ -18,12 +18,12 @@ in uniform half outerThreshold;
} }
@make { @make {
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> mask, static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView mask,
float innerThreshold, float innerThreshold,
float outerThreshold, float outerThreshold,
const SkIRect& bounds) { const SkIRect& bounds) {
return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor( return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(
mask, innerThreshold, outerThreshold, bounds)); std::move(mask), innerThreshold, outerThreshold, bounds));
} }
} }
@ -72,6 +72,11 @@ void main() {
uint32_t x = testData->fRandom->nextULessThan(kMaxWidth - width); uint32_t x = testData->fRandom->nextULessThan(kMaxWidth - width);
uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height); uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height);
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height); SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
return GrAlphaThresholdFragmentProcessor::Make(std::move(maskProxy), innerThresh, outerThresh,
GrSurfaceOrigin origin = maskProxy->origin();
GrSwizzle swizzle = maskProxy->textureSwizzle();
GrSurfaceProxyView view(std::move(maskProxy), origin, swizzle);
return GrAlphaThresholdFragmentProcessor::Make(std::move(view), innerThresh, outerThresh,
bounds); bounds);
} }

View File

@ -188,13 +188,13 @@ uniform half4 circleData;
profile[profileWidth - 1] = 0; profile[profileWidth - 1] = 0;
} }
static sk_sp<GrTextureProxy> create_profile_texture(GrRecordingContext* context, static GrSurfaceProxyView create_profile_texture(GrRecordingContext* context,
const SkRect& circle, const SkRect& circle,
float sigma, float sigma,
float* solidRadius, float* textureRadius) { float* solidRadius, float* textureRadius) {
float circleR = circle.width() / 2.0f; float circleR = circle.width() / 2.0f;
if (circleR < SK_ScalarNearlyZero) { if (circleR < SK_ScalarNearlyZero) {
return nullptr; return {};
} }
// Profile textures are cached by the ratio of sigma to circle radius and by the size of the // Profile textures are cached by the ratio of sigma to circle radius and by the size of the
// profile texture (binned by powers of 2). // profile texture (binned by powers of 2).
@ -231,45 +231,46 @@ uniform half4 circleData;
builder.finish(); builder.finish();
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin); key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)) {
if (!blurProfile) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(blurProfile->backendFormat(),
static constexpr int kProfileTextureWidth = 512; GrColorType::kAlpha_8);
return {std::move(blurProfile), kTopLeft_GrSurfaceOrigin, swizzle};
SkBitmap bm;
if (!bm.tryAllocPixels(SkImageInfo::MakeA8(kProfileTextureWidth, 1))) {
return nullptr;
}
if (useHalfPlaneApprox) {
create_half_plane_profile(bm.getAddr8(0, 0), kProfileTextureWidth);
} else {
// Rescale params to the size of the texture we're creating.
SkScalar scale = kProfileTextureWidth / *textureRadius;
create_circle_profile(bm.getAddr8(0, 0), sigma * scale, circleR * scale,
kProfileTextureWidth);
}
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
blurProfile = blurView.asTextureProxyRef();
if (!blurProfile) {
return nullptr;
}
proxyProvider->assignUniqueKeyToProxy(key, blurProfile.get());
} }
return blurProfile; static constexpr int kProfileTextureWidth = 512;
SkBitmap bm;
if (!bm.tryAllocPixels(SkImageInfo::MakeA8(kProfileTextureWidth, 1))) {
return {};
}
if (useHalfPlaneApprox) {
create_half_plane_profile(bm.getAddr8(0, 0), kProfileTextureWidth);
} else {
// Rescale params to the size of the texture we're creating.
SkScalar scale = kProfileTextureWidth / *textureRadius;
create_circle_profile(bm.getAddr8(0, 0), sigma * scale, circleR * scale,
kProfileTextureWidth);
}
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
if (!blurView) {
return {};
}
proxyProvider->assignUniqueKeyToProxy(key, blurView.asTextureProxy());
return blurView;
} }
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make( std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(
GrRecordingContext* context, const SkRect& circle, float sigma) { GrRecordingContext* context, const SkRect& circle, float sigma) {
float solidRadius; float solidRadius;
float textureRadius; float textureRadius;
sk_sp<GrTextureProxy> profile(create_profile_texture(context, circle, sigma, GrSurfaceProxyView profile = create_profile_texture(context, circle, sigma,
&solidRadius, &textureRadius)); &solidRadius, &textureRadius);
if (!profile) { if (!profile) {
return nullptr; return nullptr;
} }

View File

@ -82,7 +82,11 @@ void main() {
SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)); SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
auto effect = GrMagnifierEffect::Make(std::move(proxy), GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
auto effect = GrMagnifierEffect::Make(std::move(view),
bounds, bounds,
srcRect, srcRect,
srcRect.width() / bounds.width(), srcRect.width() / bounds.width(),

View File

@ -28,10 +28,10 @@ uniform half blurRadius;
} }
@class { @class {
static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrRecordingContext* context, static GrSurfaceProxyView find_or_create_rrect_blur_mask(GrRecordingContext* context,
const SkRRect& rrectToDraw, const SkRRect& rrectToDraw,
const SkISize& dimensions, const SkISize& dimensions,
float xformedSigma) { float xformedSigma) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key; GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 9, "RoundRect Blur Mask"); GrUniqueKey::Builder builder(&key, kDomain, 9, "RoundRect Blur Mask");
@ -49,49 +49,54 @@ uniform half blurRadius;
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> mask = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin)); key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin)) {
if (!mask) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(mask->backendFormat(),
auto rtc = GrRenderTargetContext::MakeWithFallback( GrColorType::kAlpha_8);
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions); return {std::move(mask), kBottomLeft_GrSurfaceOrigin, swizzle};
if (!rtc) {
return nullptr;
}
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView.asTextureProxy()) {
return nullptr;
}
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
std::move(srcView),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
nullptr,
SkIRect::MakeSize(dimensions),
SkIRect::MakeSize(dimensions),
xformedSigma,
xformedSigma,
SkTileMode::kClamp,
SkBackingFit::kExact);
if (!rtc2) {
return nullptr;
}
mask = rtc2->asTextureProxyRef();
if (!mask) {
return nullptr;
}
SkASSERT(mask->origin() == kBottomLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, mask.get());
} }
auto rtc = GrRenderTargetContext::MakeWithFallback(
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions);
if (!rtc) {
return {};
}
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView) {
return {};
}
SkASSERT(srcView.asTextureProxy());
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
std::move(srcView),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
nullptr,
SkIRect::MakeSize(dimensions),
SkIRect::MakeSize(dimensions),
xformedSigma,
xformedSigma,
SkTileMode::kClamp,
SkBackingFit::kExact);
if (!rtc2) {
return {};
}
GrSurfaceProxyView mask = rtc2->readSurfaceView();
if (!mask) {
return {};
}
SkASSERT(mask.asTextureProxy());
SkASSERT(mask.origin() == kBottomLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, mask.asTextureProxy());
return mask; return mask;
} }
} }
@ -142,8 +147,8 @@ uniform half blurRadius;
return nullptr; return nullptr;
} }
sk_sp<GrTextureProxy> mask(find_or_create_rrect_blur_mask(context, rrectToDraw, GrSurfaceProxyView mask = find_or_create_rrect_blur_mask(context, rrectToDraw, dimensions,
dimensions, xformedSigma)); xformedSigma);
if (!mask) { if (!mask) {
return nullptr; return nullptr;
} }

View File

@ -46,8 +46,7 @@ layout(key) in bool isFast;
samplerParams samplerParams
} }
@class { @class {
static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context, static GrSurfaceProxyView CreateIntegralTexture(GrRecordingContext* context, float sixSigma) {
float sixSigma) {
// The texture we're producing represents the integral of a normal distribution over a six-sigma // The texture we're producing represents the integral of a normal distribution over a six-sigma
// range centered at zero. We want enough resolution so that the linear interpolation done in // range centered at zero. We want enough resolution so that the linear interpolation done in
// texture lookup doesn't introduce noticeable artifacts. We conservatively choose to have 2 // texture lookup doesn't introduce noticeable artifacts. We conservatively choose to have 2
@ -63,34 +62,36 @@ static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context,
builder.finish(); builder.finish();
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> proxy = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)); key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)) {
if (!proxy) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
SkBitmap bitmap; GrColorType::kAlpha_8);
if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) { return {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
return nullptr;
}
*bitmap.getAddr8(0, 0) = 255;
const float invWidth = 1.f / width;
for (int i = 1; i < width - 1; ++i) {
float x = (i + 0.5f) * invWidth;
x = (-6 * x + 3) * SK_ScalarRoot2Over2;
float integral = 0.5f * (std::erf(x) + 1.f);
*bitmap.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
auto[view, grCT] = maker.view(GrMipMapped::kNo);
if (!view.proxy()) {
return nullptr;
}
proxy = view.asTextureProxyRef();
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, proxy.get());
} }
return proxy;
SkBitmap bitmap;
if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) {
return {};
}
*bitmap.getAddr8(0, 0) = 255;
const float invWidth = 1.f / width;
for (int i = 1; i < width - 1; ++i) {
float x = (i + 0.5f) * invWidth;
x = (-6 * x + 3) * SK_ScalarRoot2Over2;
float integral = 0.5f * (std::erf(x) + 1.f);
*bitmap.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
auto[view, grCT] = maker.view(GrMipMapped::kNo);
if (!view) {
return {};
}
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
return view;
} }
} }
@ -110,7 +111,7 @@ static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context,
} }
const float sixSigma = 6 * sigma; const float sixSigma = 6 * sigma;
auto integral = CreateIntegralTexture(context, sixSigma); GrSurfaceProxyView integral = CreateIntegralTexture(context, sixSigma);
if (!integral) { if (!integral) {
return nullptr; return nullptr;
} }

View File

@ -122,7 +122,12 @@ std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCrea
uint32_t x = testData->fRandom->nextULessThan(kMaxWidth - width); uint32_t x = testData->fRandom->nextULessThan(kMaxWidth - width);
uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height); uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height);
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height); SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
return GrAlphaThresholdFragmentProcessor::Make(std::move(maskProxy), innerThresh, outerThresh,
GrSurfaceOrigin origin = maskProxy->origin();
GrSwizzle swizzle = maskProxy->textureSwizzle();
GrSurfaceProxyView view(std::move(maskProxy), origin, swizzle);
return GrAlphaThresholdFragmentProcessor::Make(std::move(view), innerThresh, outerThresh,
bounds); bounds);
} }
#endif #endif

View File

@ -19,12 +19,12 @@ class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
public: public:
inline OptimizationFlags optFlags(float outerThreshold); inline OptimizationFlags optFlags(float outerThreshold);
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> mask, static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView mask,
float innerThreshold, float innerThreshold,
float outerThreshold, float outerThreshold,
const SkIRect& bounds) { const SkIRect& bounds) {
return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor( return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(
mask, innerThreshold, outerThreshold, bounds)); std::move(mask), innerThreshold, outerThreshold, bounds));
} }
GrAlphaThresholdFragmentProcessor(const GrAlphaThresholdFragmentProcessor& src); GrAlphaThresholdFragmentProcessor(const GrAlphaThresholdFragmentProcessor& src);
std::unique_ptr<GrFragmentProcessor> clone() const override; std::unique_ptr<GrFragmentProcessor> clone() const override;
@ -35,12 +35,12 @@ public:
float outerThreshold; float outerThreshold;
private: private:
GrAlphaThresholdFragmentProcessor(sk_sp<GrSurfaceProxy> mask, float innerThreshold, GrAlphaThresholdFragmentProcessor(GrSurfaceProxyView mask, float innerThreshold,
float outerThreshold, const SkIRect& bounds) float outerThreshold, const SkIRect& bounds)
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags) : INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags)
, maskCoordTransform( , maskCoordTransform(
SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())), SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
mask.get()) mask.proxy())
, mask(std::move(mask)) , mask(std::move(mask))
, innerThreshold(innerThreshold) , innerThreshold(innerThreshold)
, outerThreshold(outerThreshold) { , outerThreshold(outerThreshold) {

View File

@ -166,12 +166,12 @@ static void create_half_plane_profile(uint8_t* profile, int profileWidth) {
profile[profileWidth - 1] = 0; profile[profileWidth - 1] = 0;
} }
static sk_sp<GrTextureProxy> create_profile_texture(GrRecordingContext* context, static GrSurfaceProxyView create_profile_texture(GrRecordingContext* context, const SkRect& circle,
const SkRect& circle, float sigma, float sigma, float* solidRadius,
float* solidRadius, float* textureRadius) { float* textureRadius) {
float circleR = circle.width() / 2.0f; float circleR = circle.width() / 2.0f;
if (circleR < SK_ScalarNearlyZero) { if (circleR < SK_ScalarNearlyZero) {
return nullptr; return {};
} }
// Profile textures are cached by the ratio of sigma to circle radius and by the size of the // Profile textures are cached by the ratio of sigma to circle radius and by the size of the
// profile texture (binned by powers of 2). // profile texture (binned by powers of 2).
@ -208,45 +208,46 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrRecordingContext* context,
builder.finish(); builder.finish();
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin); key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)) {
if (!blurProfile) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(blurProfile->backendFormat(),
static constexpr int kProfileTextureWidth = 512; GrColorType::kAlpha_8);
return {std::move(blurProfile), kTopLeft_GrSurfaceOrigin, swizzle};
SkBitmap bm;
if (!bm.tryAllocPixels(SkImageInfo::MakeA8(kProfileTextureWidth, 1))) {
return nullptr;
}
if (useHalfPlaneApprox) {
create_half_plane_profile(bm.getAddr8(0, 0), kProfileTextureWidth);
} else {
// Rescale params to the size of the texture we're creating.
SkScalar scale = kProfileTextureWidth / *textureRadius;
create_circle_profile(bm.getAddr8(0, 0), sigma * scale, circleR * scale,
kProfileTextureWidth);
}
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
blurProfile = blurView.asTextureProxyRef();
if (!blurProfile) {
return nullptr;
}
proxyProvider->assignUniqueKeyToProxy(key, blurProfile.get());
} }
return blurProfile; static constexpr int kProfileTextureWidth = 512;
SkBitmap bm;
if (!bm.tryAllocPixels(SkImageInfo::MakeA8(kProfileTextureWidth, 1))) {
return {};
}
if (useHalfPlaneApprox) {
create_half_plane_profile(bm.getAddr8(0, 0), kProfileTextureWidth);
} else {
// Rescale params to the size of the texture we're creating.
SkScalar scale = kProfileTextureWidth / *textureRadius;
create_circle_profile(bm.getAddr8(0, 0), sigma * scale, circleR * scale,
kProfileTextureWidth);
}
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
if (!blurView) {
return {};
}
proxyProvider->assignUniqueKeyToProxy(key, blurView.asTextureProxy());
return blurView;
} }
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make( std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(
GrRecordingContext* context, const SkRect& circle, float sigma) { GrRecordingContext* context, const SkRect& circle, float sigma) {
float solidRadius; float solidRadius;
float textureRadius; float textureRadius;
sk_sp<GrTextureProxy> profile( GrSurfaceProxyView profile =
create_profile_texture(context, circle, sigma, &solidRadius, &textureRadius)); create_profile_texture(context, circle, sigma, &solidRadius, &textureRadius);
if (!profile) { if (!profile) {
return nullptr; return nullptr;
} }

View File

@ -29,7 +29,7 @@ public:
private: private:
GrCircleBlurFragmentProcessor(SkRect circleRect, float textureRadius, float solidRadius, GrCircleBlurFragmentProcessor(SkRect circleRect, float textureRadius, float solidRadius,
sk_sp<GrSurfaceProxy> blurProfileSampler) GrSurfaceProxyView blurProfileSampler)
: INHERITED(kGrCircleBlurFragmentProcessor_ClassID, : INHERITED(kGrCircleBlurFragmentProcessor_ClassID,
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag) (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
, circleRect(circleRect) , circleRect(circleRect)

View File

@ -189,7 +189,11 @@ std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTe
SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)); SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
auto effect = GrMagnifierEffect::Make(std::move(proxy), GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
auto effect = GrMagnifierEffect::Make(std::move(view),
bounds, bounds,
srcRect, srcRect,
srcRect.width() / bounds.width(), srcRect.width() / bounds.width(),

View File

@ -17,11 +17,11 @@
#include "src/gpu/GrFragmentProcessor.h" #include "src/gpu/GrFragmentProcessor.h"
class GrMagnifierEffect : public GrFragmentProcessor { class GrMagnifierEffect : public GrFragmentProcessor {
public: public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> src, SkIRect bounds, static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView src, SkIRect bounds,
SkRect srcRect, float xInvZoom, float yInvZoom, SkRect srcRect, float xInvZoom, float yInvZoom,
float xInvInset, float yInvInset) { float xInvInset, float yInvInset) {
return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect( return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(
src, bounds, srcRect, xInvZoom, yInvZoom, xInvInset, yInvInset)); std::move(src), bounds, srcRect, xInvZoom, yInvZoom, xInvInset, yInvInset));
} }
GrMagnifierEffect(const GrMagnifierEffect& src); GrMagnifierEffect(const GrMagnifierEffect& src);
std::unique_ptr<GrFragmentProcessor> clone() const override; std::unique_ptr<GrFragmentProcessor> clone() const override;
@ -36,10 +36,10 @@ public:
float yInvInset; float yInvInset;
private: private:
GrMagnifierEffect(sk_sp<GrSurfaceProxy> src, SkIRect bounds, SkRect srcRect, float xInvZoom, GrMagnifierEffect(GrSurfaceProxyView src, SkIRect bounds, SkRect srcRect, float xInvZoom,
float yInvZoom, float xInvInset, float yInvInset) float yInvZoom, float xInvInset, float yInvInset)
: INHERITED(kGrMagnifierEffect_ClassID, kNone_OptimizationFlags) : INHERITED(kGrMagnifierEffect_ClassID, kNone_OptimizationFlags)
, srcCoordTransform(SkMatrix::I(), src.get()) , srcCoordTransform(SkMatrix::I(), src.proxy())
, src(std::move(src)) , src(std::move(src))
, bounds(bounds) , bounds(bounds)
, srcRect(srcRect) , srcRect(srcRect)

View File

@ -39,8 +39,8 @@ std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::Make(GrRecordingContext*
return nullptr; return nullptr;
} }
sk_sp<GrTextureProxy> mask( GrSurfaceProxyView mask =
find_or_create_rrect_blur_mask(context, rrectToDraw, dimensions, xformedSigma)); find_or_create_rrect_blur_mask(context, rrectToDraw, dimensions, xformedSigma);
if (!mask) { if (!mask) {
return nullptr; return nullptr;
} }

View File

@ -30,10 +30,10 @@
#include "src/gpu/GrFragmentProcessor.h" #include "src/gpu/GrFragmentProcessor.h"
class GrRRectBlurEffect : public GrFragmentProcessor { class GrRRectBlurEffect : public GrFragmentProcessor {
public: public:
static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrRecordingContext* context, static GrSurfaceProxyView find_or_create_rrect_blur_mask(GrRecordingContext* context,
const SkRRect& rrectToDraw, const SkRRect& rrectToDraw,
const SkISize& dimensions, const SkISize& dimensions,
float xformedSigma) { float xformedSigma) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key; GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 9, "RoundRect Blur Mask"); GrUniqueKey::Builder builder(&key, kDomain, 9, "RoundRect Blur Mask");
@ -51,49 +51,54 @@ public:
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> mask = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin)); key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin)) {
if (!mask) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(mask->backendFormat(),
auto rtc = GrRenderTargetContext::MakeWithFallback( GrColorType::kAlpha_8);
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions); return {std::move(mask), kBottomLeft_GrSurfaceOrigin, swizzle};
if (!rtc) {
return nullptr;
}
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView.asTextureProxy()) {
return nullptr;
}
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
std::move(srcView),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
nullptr,
SkIRect::MakeSize(dimensions),
SkIRect::MakeSize(dimensions),
xformedSigma,
xformedSigma,
SkTileMode::kClamp,
SkBackingFit::kExact);
if (!rtc2) {
return nullptr;
}
mask = rtc2->asTextureProxyRef();
if (!mask) {
return nullptr;
}
SkASSERT(mask->origin() == kBottomLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, mask.get());
} }
auto rtc = GrRenderTargetContext::MakeWithFallback(context, GrColorType::kAlpha_8, nullptr,
SkBackingFit::kExact, dimensions);
if (!rtc) {
return {};
}
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView) {
return {};
}
SkASSERT(srcView.asTextureProxy());
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
std::move(srcView),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
nullptr,
SkIRect::MakeSize(dimensions),
SkIRect::MakeSize(dimensions),
xformedSigma,
xformedSigma,
SkTileMode::kClamp,
SkBackingFit::kExact);
if (!rtc2) {
return {};
}
GrSurfaceProxyView mask = rtc2->readSurfaceView();
if (!mask) {
return {};
}
SkASSERT(mask.asTextureProxy());
SkASSERT(mask.origin() == kBottomLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, mask.asTextureProxy());
return mask; return mask;
} }
@ -112,7 +117,7 @@ public:
private: private:
GrRRectBlurEffect(float sigma, SkRect rect, float cornerRadius, GrRRectBlurEffect(float sigma, SkRect rect, float cornerRadius,
sk_sp<GrSurfaceProxy> ninePatchSampler) GrSurfaceProxyView ninePatchSampler)
: INHERITED(kGrRRectBlurEffect_ClassID, : INHERITED(kGrRRectBlurEffect_ClassID,
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag) (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
, sigma(sigma) , sigma(sigma)

View File

@ -29,8 +29,7 @@
#include "src/gpu/GrFragmentProcessor.h" #include "src/gpu/GrFragmentProcessor.h"
class GrRectBlurEffect : public GrFragmentProcessor { class GrRectBlurEffect : public GrFragmentProcessor {
public: public:
static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context, static GrSurfaceProxyView CreateIntegralTexture(GrRecordingContext* context, float sixSigma) {
float sixSigma) {
// The texture we're producing represents the integral of a normal distribution over a // The texture we're producing represents the integral of a normal distribution over a
// six-sigma range centered at zero. We want enough resolution so that the linear // six-sigma range centered at zero. We want enough resolution so that the linear
// interpolation done in texture lookup doesn't introduce noticeable artifacts. We // interpolation done in texture lookup doesn't introduce noticeable artifacts. We
@ -46,34 +45,36 @@ public:
builder.finish(); builder.finish();
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey( if (sk_sp<GrTextureProxy> proxy = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)); key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)) {
if (!proxy) { GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
SkBitmap bitmap; GrColorType::kAlpha_8);
if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) { return {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
return nullptr;
}
*bitmap.getAddr8(0, 0) = 255;
const float invWidth = 1.f / width;
for (int i = 1; i < width - 1; ++i) {
float x = (i + 0.5f) * invWidth;
x = (-6 * x + 3) * SK_ScalarRoot2Over2;
float integral = 0.5f * (std::erf(x) + 1.f);
*bitmap.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
auto[view, grCT] = maker.view(GrMipMapped::kNo);
if (!view.proxy()) {
return nullptr;
}
proxy = view.asTextureProxyRef();
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, proxy.get());
} }
return proxy;
SkBitmap bitmap;
if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) {
return {};
}
*bitmap.getAddr8(0, 0) = 255;
const float invWidth = 1.f / width;
for (int i = 1; i < width - 1; ++i) {
float x = (i + 0.5f) * invWidth;
x = (-6 * x + 3) * SK_ScalarRoot2Over2;
float integral = 0.5f * (std::erf(x) + 1.f);
*bitmap.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
auto[view, grCT] = maker.view(GrMipMapped::kNo);
if (!view) {
return {};
}
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
return view;
} }
static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext* context, static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext* context,
@ -91,7 +92,7 @@ public:
} }
const float sixSigma = 6 * sigma; const float sixSigma = 6 * sigma;
auto integral = CreateIntegralTexture(context, sixSigma); GrSurfaceProxyView integral = CreateIntegralTexture(context, sixSigma);
if (!integral) { if (!integral) {
return nullptr; return nullptr;
} }
@ -125,7 +126,7 @@ public:
bool isFast; bool isFast;
private: private:
GrRectBlurEffect(SkRect rect, sk_sp<GrSurfaceProxy> integral, float invSixSigma, bool isFast, GrRectBlurEffect(SkRect rect, GrSurfaceProxyView integral, float invSixSigma, bool isFast,
GrSamplerState samplerParams) GrSamplerState samplerParams)
: INHERITED(kGrRectBlurEffect_ClassID, : INHERITED(kGrRectBlurEffect_ClassID,
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag) (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)

View File

@ -65,7 +65,7 @@ static std::unique_ptr<GrFragmentProcessor> make_textured_colorizer(const SkPMCo
return nullptr; return nullptr;
} }
return GrTextureGradientColorizer::Make(view.detachProxy()); return GrTextureGradientColorizer::Make(std::move(view));
} }
// Analyze the shader's color stops and positions and chooses an appropriate colorizer to represent // Analyze the shader's color stops and positions and chooses an appropriate colorizer to represent

View File

@ -17,8 +17,9 @@
#include "src/gpu/GrFragmentProcessor.h" #include "src/gpu/GrFragmentProcessor.h"
class GrTextureGradientColorizer : public GrFragmentProcessor { class GrTextureGradientColorizer : public GrFragmentProcessor {
public: public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> gradient) { static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView gradient) {
return std::unique_ptr<GrFragmentProcessor>(new GrTextureGradientColorizer(gradient)); return std::unique_ptr<GrFragmentProcessor>(
new GrTextureGradientColorizer(std::move(gradient)));
} }
GrTextureGradientColorizer(const GrTextureGradientColorizer& src); GrTextureGradientColorizer(const GrTextureGradientColorizer& src);
std::unique_ptr<GrFragmentProcessor> clone() const override; std::unique_ptr<GrFragmentProcessor> clone() const override;
@ -26,7 +27,7 @@ public:
TextureSampler gradient; TextureSampler gradient;
private: private:
GrTextureGradientColorizer(sk_sp<GrSurfaceProxy> gradient) GrTextureGradientColorizer(GrSurfaceProxyView gradient)
: INHERITED(kGrTextureGradientColorizer_ClassID, kNone_OptimizationFlags) : INHERITED(kGrTextureGradientColorizer_ClassID, kNone_OptimizationFlags)
, gradient(std::move(gradient), GrSamplerState::Filter::kBilerp) { , gradient(std::move(gradient), GrSamplerState::Filter::kBilerp) {
this->setTextureSamplerCnt(1); this->setTextureSamplerCnt(1);

View File

@ -66,7 +66,7 @@ Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type&
} else if (type == *context.fFloat4x4_Type || type == *context.fHalf4x4_Type) { } else if (type == *context.fFloat4x4_Type || type == *context.fHalf4x4_Type) {
return Layout::CType::kSkM44; return Layout::CType::kSkM44;
} else if (type.kind() == Type::kSampler_Kind) { } else if (type.kind() == Type::kSampler_Kind) {
return Layout::CType::kGrSurfaceProxy; return Layout::CType::kGrSurfaceProxyView;
} else if (type == *context.fFragmentProcessor_Type) { } else if (type == *context.fFragmentProcessor_Type) {
return Layout::CType::kGrFragmentProcessor; return Layout::CType::kGrFragmentProcessor;
} }
@ -191,7 +191,8 @@ void HCodeGenerator::writeMake() {
fFullName.c_str()); fFullName.c_str());
separator = ""; separator = "";
for (const auto& param : fSectionAndParameterHelper.getParameters()) { for (const auto& param : fSectionAndParameterHelper.getParameters()) {
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) { if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type ||
param->fType.nonnullable().kind() == Type::kSampler_Kind) {
this->writef("%sstd::move(%s)", separator, String(param->fName).c_str()); this->writef("%sstd::move(%s)", separator, String(param->fName).c_str());
} else { } else {
this->writef("%s%s", separator, String(param->fName).c_str()); this->writef("%s%s", separator, String(param->fName).c_str());
@ -241,7 +242,7 @@ void HCodeGenerator::writeConstructor() {
const Section& s = *transforms[i]; const Section& s = *transforms[i];
String field = CoordTransformName(s.fArgument.c_str(), i); String field = CoordTransformName(s.fArgument.c_str(), i);
if (s.fArgument.size()) { if (s.fArgument.size()) {
this->writef("\n , %s(%s, %s.get())", field.c_str(), s.fText.c_str(), this->writef("\n , %s(%s, %s.proxy())", field.c_str(), s.fText.c_str(),
FieldName(s.fArgument.c_str()).c_str()); FieldName(s.fArgument.c_str()).c_str());
} }
else { else {

View File

@ -95,7 +95,7 @@ struct Layout {
kSkIPoint, kSkIPoint,
kSkMatrix, kSkMatrix,
kSkM44, kSkM44,
kGrSurfaceProxy, kGrSurfaceProxyView,
kGrFragmentProcessor, kGrFragmentProcessor,
}; };
@ -177,8 +177,8 @@ struct Layout {
return "SkMatrix"; return "SkMatrix";
case CType::kSkM44: case CType::kSkM44:
return "SkM44"; return "SkM44";
case CType::kGrSurfaceProxy: case CType::kGrSurfaceProxyView:
return "sk_sp<GrSurfaceProxy>"; return "GrSurfaceProxyView";
case CType::kGrFragmentProcessor: case CType::kGrFragmentProcessor:
return "std::unique_ptr<GrFragmentProcessor>"; return "std::unique_ptr<GrFragmentProcessor>";
default: default: