Revert "Make textures used with alpha-only color-types produce 0s for RGB"

This reverts commit 16d86135b7.

No-Tree-Checks: true
Change-Id: Ia5ba78259a3a406c4c0f8ddca9aaf495d29b34f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348176
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2020-12-29 09:32:52 -05:00 committed by Skia Commit-Bot
parent d1b593f446
commit c85bce8ea6
19 changed files with 65 additions and 87 deletions

View File

@ -250,7 +250,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrRecordingContext* ctx, GrSurfa
// Now visualize the alpha mask by drawing a rect over the area where it is defined. The regions
// inside window rectangles or outside the scissor should still have the initial checkerboard
// intact. (This verifies we didn't spend any time modifying those pixels in the mask.)
AlphaOnlyClip alphaClip(maskRTC->readSurfaceView().makeSwizzle(GrSwizzle("aaaa")), x, y);
AlphaOnlyClip alphaClip(maskRTC->readSurfaceView(), x, y);
rtc->drawRect(&alphaClip, std::move(paint), GrAA::kYes, SkMatrix::I(),
SkRect::Make(SkIRect::MakeXYWH(x, y, maskRTC->width(), maskRTC->height())));
}

View File

@ -102,9 +102,9 @@ protected:
static const SkRect kColorRect = SkRect::MakeLTRB(2.f, 2.f, 6.f, 6.f);
SkYUVAIndex yuvaIndices[4] = {
{ SkYUVAIndex::kY_Index, SkColorChannel::kA },
{ SkYUVAIndex::kU_Index, SkColorChannel::kA },
{ SkYUVAIndex::kV_Index, SkColorChannel::kA },
{ SkYUVAIndex::kY_Index, SkColorChannel::kR },
{ SkYUVAIndex::kU_Index, SkColorChannel::kR },
{ SkYUVAIndex::kV_Index, SkColorChannel::kR },
{ -1, SkColorChannel::kA }
};
// Outset to visualize wrap modes.

View File

@ -50,8 +50,6 @@ static bool draw_mask(GrSurfaceDrawContext* surfaceDrawContext,
return false;
}
mask.concatSwizzle(GrSwizzle("aaaa"));
SkMatrix matrix = SkMatrix::Translate(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);

View File

@ -1594,7 +1594,7 @@ GrFPResult GrClipStack::GetSWMaskFP(GrRecordingContext* context, Mask::Stack* ma
const Element** elements, int count,
std::unique_ptr<GrFragmentProcessor> clipFP) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
GrSurfaceProxyView maskView;
GrSurfaceProxyView maskProxy;
SkIRect maskBounds; // may not be 'bounds' if we reuse a large clip mask
// Check the existing masks from this save record for compatibility
@ -1603,31 +1603,31 @@ GrFPResult GrClipStack::GetSWMaskFP(GrRecordingContext* context, Mask::Stack* ma
break;
}
if (m.appliesToDraw(current, bounds)) {
maskView = proxyProvider->findCachedProxyWithColorTypeFallback(
m.key(), kMaskOrigin, GrColorType::kAlpha_8, 1).makeSwizzle(GrSwizzle("aaaa"));
if (maskView) {
maskProxy = proxyProvider->findCachedProxyWithColorTypeFallback(
m.key(), kMaskOrigin, GrColorType::kAlpha_8, 1);
if (maskProxy) {
maskBounds = m.bounds();
break;
}
}
}
if (!maskView) {
if (!maskProxy) {
// No existing mask was found, so need to render a new one
maskView = render_sw_mask(context, bounds, elements, count).makeSwizzle(GrSwizzle("aaaa"));
if (!maskView) {
maskProxy = render_sw_mask(context, bounds, elements, count);
if (!maskProxy) {
// If we still don't have one, there's nothing we can do
return GrFPFailure(std::move(clipFP));
}
// Register the mask for later invalidation
Mask& mask = masks->emplace_back(current, bounds);
proxyProvider->assignUniqueKeyToProxy(mask.key(), maskView.asTextureProxy());
proxyProvider->assignUniqueKeyToProxy(mask.key(), maskProxy.asTextureProxy());
maskBounds = bounds;
}
// Wrap the mask in an FP that samples it for coverage
SkASSERT(maskView && maskView.origin() == kMaskOrigin);
SkASSERT(maskProxy && maskProxy.origin() == kMaskOrigin);
GrSamplerState samplerState(GrSamplerState::WrapMode::kClampToBorder,
GrSamplerState::Filter::kNearest);
@ -1639,8 +1639,8 @@ GrFPResult GrClipStack::GetSWMaskFP(GrRecordingContext* context, Mask::Stack* ma
// We scissor to bounds. The mask's texel centers are aligned to device space
// pixel centers. Hence this domain of texture coordinates.
auto domain = subset.makeInset(0.5, 0.5);
auto fp = GrTextureEffect::MakeSubset(std::move(maskView), kPremul_SkAlphaType, m, samplerState,
subset, domain, *context->priv().caps());
auto fp = GrTextureEffect::MakeSubset(std::move(maskProxy), kPremul_SkAlphaType, m,
samplerState, subset, domain, *context->priv().caps());
fp = GrDeviceSpaceEffect::Make(std::move(fp));
// Must combine the coverage sampled from the texture effect with the previous coverage

View File

@ -562,9 +562,6 @@ bool GrDrawOpAtlas::createPages(
for (uint32_t i = 0; i < this->maxPages(); ++i) {
GrSwizzle swizzle = proxyProvider->caps()->getReadSwizzle(fFormat, fColorType);
if (GrColorTypeIsAlphaOnly(fColorType)) {
swizzle = GrSwizzle::Concat(swizzle, GrSwizzle("aaaa"));
}
sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy(
fFormat, dims, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBackingFit::kExact,
SkBudgeted::kYes, GrProtected::kNo, GrInternalSurfaceFlags::kNone,
@ -595,6 +592,7 @@ bool GrDrawOpAtlas::createPages(
return true;
}
bool GrDrawOpAtlas::activateNewPage(GrResourceProvider* resourceProvider) {
SkASSERT(fNumActivePages < this->maxPages());

View File

@ -156,8 +156,6 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
return;
}
view.concatSwizzle(GrSwizzle("aaaa"));
SkRect dstRect = SkRect::Make(deviceSpaceRectToDraw);
// We use device coords to compute the texture coordinates. We take the device coords and apply

View File

@ -72,16 +72,6 @@ public:
GrSurfaceOrigin origin() const { return fOrigin; }
GrSwizzle swizzle() const { return fSwizzle; }
void concatSwizzle(GrSwizzle swizzle) { fSwizzle = GrSwizzle::Concat(fSwizzle, swizzle); }
GrSurfaceProxyView makeSwizzle(GrSwizzle swizzle) const & {
return {fProxy, fOrigin, GrSwizzle::Concat(fSwizzle, swizzle)};
}
GrSurfaceProxyView makeSwizzle(GrSwizzle swizzle) && {
return {std::move(fProxy), fOrigin, GrSwizzle::Concat(fSwizzle, swizzle)};
}
void reset() {
*this = {};
}

View File

@ -53,8 +53,10 @@ public:
void apply(SkRasterPipeline*) const;
static constexpr GrSwizzle RGBA() { return GrSwizzle("rgba"); }
static constexpr GrSwizzle BGRA() { return GrSwizzle("bgra"); }
static constexpr GrSwizzle AAAA() { return GrSwizzle("aaaa"); }
static constexpr GrSwizzle RRRR() { return GrSwizzle("rrrr"); }
static constexpr GrSwizzle RRRA() { return GrSwizzle("rrra"); }
static constexpr GrSwizzle BGRA() { return GrSwizzle("bgra"); }
static constexpr GrSwizzle RGB1() { return GrSwizzle("rgb1"); }
private:

View File

@ -839,9 +839,6 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
if (!view) {
return;
}
if (producer->isAlphaOnly()) {
view.concatSwizzle(GrSwizzle("aaaa"));
}
auto csxf = GrColorSpaceXform::Make(producer->colorSpace(), producer->alphaType(),
dstColorSpace, kPremul_SkAlphaType);

View File

@ -351,9 +351,6 @@ static void draw_texture(GrSurfaceDrawContext* rtc,
SkCanvas::SrcRectConstraint constraint,
GrSurfaceProxyView view,
const GrColorInfo& srcColorInfo) {
if (GrColorTypeIsAlphaOnly(srcColorInfo.colorType())) {
view.concatSwizzle(GrSwizzle("aaaa"));
}
const GrColorInfo& dstInfo(rtc->colorInfo());
auto textureXform =
GrColorSpaceXform::Make(srcColorInfo.colorSpace(), srcColorInfo.alphaType(),
@ -451,9 +448,7 @@ static void draw_texture_producer(GrRecordingContext* context,
aaFlags,
constraint,
std::move(view),
{producer->colorType(),
producer->alphaType(),
sk_ref_sp(producer->colorSpace())});
producer->colorInfo());
return;
}
@ -514,11 +509,7 @@ static void draw_texture_producer(GrRecordingContext* context,
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), producer->colorSpace(), producer->alphaType(),
rtc->colorInfo().colorSpace(), kPremul_SkAlphaType);
if (producer->isAlphaOnly()) {
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
} else {
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn);
}
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kModulate);
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(context, rtc->colorInfo(), paint, matrixProvider,
@ -898,10 +889,6 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
if (!view) {
view = image->refView(this->recordingContext(), GrMipmapped::kNo);
}
if (image->isAlphaOnly()) {
GrSwizzle swizzle = GrSwizzle::Concat(view.swizzle(), GrSwizzle("aaaa"));
view = {view.detachProxy(), view.origin(), swizzle};
}
}
if (!view) {

View File

@ -395,8 +395,8 @@ void GrD3DCaps::initFormatTable(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Devi
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle("rrrr");
ctInfo.fWriteSwizzle = GrSwizzle("aaaa");
}
// Format: DXGI_FORMAT_R8_UNORM, Surface: kGray_8
{
@ -488,8 +488,8 @@ void GrD3DCaps::initFormatTable(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Devi
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle("rrrr");
ctInfo.fWriteSwizzle = GrSwizzle("aaaa");
}
}
}
@ -587,8 +587,8 @@ void GrD3DCaps::initFormatTable(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Devi
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle("rrrr");
ctInfo.fWriteSwizzle = GrSwizzle("aaaa");
}
}
}

View File

@ -49,9 +49,9 @@ static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorTyp
case GrColorType::kAlpha_8: // fall through
case GrColorType::kAlpha_F16:
if (forOutput) {
return GrSwizzle("a000");
return GrSwizzle::AAAA();
} else {
return GrSwizzle("000r");
return GrSwizzle::RRRR();
}
case GrColorType::kGray_8:
if (!forOutput) {

View File

@ -95,6 +95,9 @@ uniform half blurRadius;
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView) {
return false;
}
SkASSERT(srcView.asTextureProxy());
auto rtc2 = SkGpuBlurUtils::GaussianBlur(dContext,
std::move(srcView),
@ -403,7 +406,7 @@ half4 main() {
half2 proxyDims = half2(2.0 * edgeSize);
half2 texCoord = translatedFragPosHalf / proxyDims;
return sample(inputFP) * sample(ninePatchFP, texCoord).a;
return sample(inputFP) * sample(ninePatchFP, texCoord);
}
@setData(pdman) {

View File

@ -69,6 +69,9 @@ static bool fillin_view_on_gpu(GrDirectContext* dContext,
GrStyle::SimpleFill());
GrSurfaceProxyView srcView = rtc->readSurfaceView();
if (!srcView) {
return false;
}
SkASSERT(srcView.asTextureProxy());
auto rtc2 = SkGpuBlurUtils::GaussianBlur(dContext,
std::move(srcView),
@ -379,7 +382,7 @@ half2 texCoord = translatedFragPosHalf / proxyDims;)SkSL",
SkString _sample1 = this->invokeChild(1, args, _coords1.c_str());
fragBuilder->codeAppendf(
R"SkSL(
return %s * %s.w;
return %s * %s;
)SkSL",
_sample0.c_str(), _sample1.c_str());
}

View File

@ -1559,8 +1559,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_8;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
this->setColorTypeFormat(GrColorType::kAlpha_8, GrGLFormat::kR8);
// External IO ColorTypes:
@ -1686,6 +1686,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ctInfo.fColorType = GrColorType::kAlpha_8;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag |
ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle::AAAA();
int idx = static_cast<int>(GrColorType::kAlpha_8);
if (fColorTypeToFormatTable[idx] == GrGLFormat::kUnknown) {
this->setColorTypeFormat(GrColorType::kAlpha_8, GrGLFormat::kALPHA8);
@ -2266,8 +2267,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_F16;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
this->setColorTypeFormat(GrColorType::kAlpha_F16, GrGLFormat::kR16F);
// External IO ColorTypes:
@ -2349,8 +2350,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_F16;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("aaa0");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
int idx = static_cast<int>(GrColorType::kAlpha_F16);
if (fColorTypeToFormatTable[idx] == GrGLFormat::kUnknown) {
@ -2895,8 +2896,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_16;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
this->setColorTypeFormat(GrColorType::kAlpha_16, GrGLFormat::kR16);
// External IO ColorTypes:

View File

@ -570,8 +570,8 @@ void GrMtlCaps::initFormatTable() {
auto& ctInfo = info->fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_8;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
// Format: R8Unorm, Surface: kGray_8
{
@ -594,6 +594,7 @@ void GrMtlCaps::initFormatTable() {
auto& ctInfo = info->fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_8;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle::AAAA();
}
}
@ -748,8 +749,8 @@ void GrMtlCaps::initFormatTable() {
auto& ctInfo = info->fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_F16;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
}
@ -790,8 +791,8 @@ void GrMtlCaps::initFormatTable() {
auto& ctInfo = info->fColorTypeInfos[ctIdx++];
ctInfo.fColorType = GrColorType::kAlpha_16;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
}

View File

@ -851,8 +851,8 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
// Format: VK_FORMAT_R8_UNORM, Surface: kGray_8
{
@ -940,8 +940,8 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
}
}
@ -1089,8 +1089,8 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = GrSwizzle("000r");
ctInfo.fWriteSwizzle = GrSwizzle("a000");
ctInfo.fReadSwizzle = GrSwizzle::RRRR();
ctInfo.fWriteSwizzle = GrSwizzle::AAAA();
}
}
}

View File

@ -486,14 +486,14 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), fImage->colorSpace(), producer->alphaType(),
args.fDstColorInfo->colorSpace(), kPremul_SkAlphaType);
if (fImage->isAlphaOnly()) {
return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kModulate);
bool isAlphaOnly = SkColorTypeIsAlphaOnly(fImage->colorType());
if (isAlphaOnly) {
return fp;
} else if (args.fInputColorIsOpaque) {
// This special case isn't needed for correctness. It just avoids a multiplication by
// a vertex attribute alpha that is known to be 1 if we take the kSrcIn path.
return GrFragmentProcessor::OverrideInput(std::move(fp), SK_PMColor4fWHITE, false);
}
return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn);
return GrFragmentProcessor::MulChildByInputAlpha(std::move(fp));
}
#endif

View File

@ -887,7 +887,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
// can't see fInputColor (which is "_input" in the FP's outer function). skbug.com/10506
SkString sampleX = this->invokeChild(0, "half4(1)", args, "half2(floorVal.x, 0.5)");
SkString sampleY = this->invokeChild(0, "half4(1)", args, "half2(floorVal.z, 0.5)");
noiseCode.appendf("half2 latticeIdx = half2(%s.a, %s.a);", sampleX.c_str(), sampleY.c_str());
noiseCode.appendf("half2 latticeIdx = half2(%s.r, %s.r);", sampleX.c_str(), sampleY.c_str());
#if defined(SK_BUILD_FOR_ANDROID)
// Android rounding for Tegra devices, like, for example: Xoom (Tegra 2), Nexus 7 (Tegra 3).