Revert "Move localmatrix routines to shaderbase, no need to be public."

This reverts commit f4a8d6fc94.

Reason for revert: need to guard this for google3

Original change's description:
> Move localmatrix routines to shaderbase, no need to be public.
> 
> Requires https://chromium-review.googlesource.com/c/chromium/src/+/1554040
> 
> Bug: skia:8941
> Change-Id: I68593bf794d559845b638e1ecbcc658cc5cfe1b4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206165
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=halcanary@google.com,fmalita@chromium.org,reed@google.com

Change-Id: I2dc2f2ff2291c0b4579f32f1a6a8f283a156f6c0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8941
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206263
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-04-05 15:15:15 +00:00 committed by Skia Commit-Bot
parent 69da7ad49b
commit f88a0e1c91
8 changed files with 29 additions and 19 deletions

View File

@ -70,6 +70,14 @@ public:
static constexpr int kTileModeCount = kLast_TileMode + 1;
#endif
/**
* Returns the local matrix.
*
* FIXME: This can be incorrect for a Shader with its own local matrix
* that is also wrapped via CreateLocalMatrixShader.
*/
const SkMatrix& getLocalMatrix() const;
/**
* Returns true if the shader is guaranteed to produce only opaque
* colors, subject to the SkPaint using the shader to apply an opaque
@ -253,6 +261,13 @@ public:
const SkMatrix* localMatrix, const SkRect* tile);
#endif
/** DEPRECATED. skbug.com/8941
* If this shader can be represented by another shader + a localMatrix, return that shader and
* the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
*/
// TODO: clean up clients, move to SkShaderBase.
virtual sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const;
private:
SkShader() = default;
friend class SkShaderBase;

View File

@ -167,7 +167,7 @@ SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShaderBase::
bool SkNormalMapSourceImpl::computeNormTotalInverse(const SkShaderBase::ContextRec& rec,
SkMatrix* normTotalInverse) const {
SkMatrix total = SkMatrix::Concat(*rec.fMatrix, as_SB(fMapShader)->getLocalMatrix());
SkMatrix total = SkMatrix::Concat(*rec.fMatrix, fMapShader->getLocalMatrix());
if (rec.fLocalMatrix) {
total.preConcat(*rec.fLocalMatrix);
}

View File

@ -269,7 +269,7 @@ static SkPDFIndirectReference make_fallback_shader(SkPDFDocument* doc,
{SkTileMode::kClamp, SkTileMode::kClamp},
paintColor};
key.fShaderTransform = as_SB(shader)->getLocalMatrix();
key.fShaderTransform = shader->getLocalMatrix();
// surfaceBBox is in device space. While that's exactly what we
// want for sizing our bitmap, we need to map it into

View File

@ -12,7 +12,6 @@
#include "SkPaint.h"
#include "SkPath.h"
#include "SkShader.h"
#include "SkShaderBase.h"
#include "SkStream.h"
#include "SkUtils.h"
@ -114,10 +113,10 @@ inline void WriteUTF16beHex(SkDynamicMemoryWStream* wStream, SkUnichar utf32) {
inline SkMatrix GetShaderLocalMatrix(const SkShader* shader) {
SkMatrix localMatrix;
if (sk_sp<SkShader> s = as_SB(shader)->makeAsALocalMatrixShader(&localMatrix)) {
return SkMatrix::Concat(as_SB(s)->getLocalMatrix(), localMatrix);
if (sk_sp<SkShader> s = shader->makeAsALocalMatrixShader(&localMatrix)) {
return SkMatrix::Concat(s->getLocalMatrix(), localMatrix);
}
return as_SB(shader)->getLocalMatrix();
return shader->getLocalMatrix();
}
bool InverseTransformBBox(const SkMatrix& matrix, SkRect* bbox);
void PopulateTilingPatternDict(SkPDFDict* pattern,

View File

@ -114,6 +114,10 @@ bool SkShaderBase::ContextRec::isLegacyCompatible(SkColorSpace* shaderColorSpace
return !SkColorSpaceXformSteps::Required(shaderColorSpace, fDstColorSpace);
}
const SkMatrix& SkShader::getLocalMatrix() const {
return as_SB(this)->getLocalMatrix();
}
SkImage* SkShader::isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const {
return as_SB(this)->onIsAImage(localMatrix, xy);
}
@ -128,7 +132,7 @@ std::unique_ptr<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const GrF
}
#endif
sk_sp<SkShader> SkShaderBase::makeAsALocalMatrixShader(SkMatrix*) const {
sk_sp<SkShader> SkShader::makeAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
}

View File

@ -178,12 +178,6 @@ public:
}
static void RegisterFlattenables();
/** DEPRECATED. skbug.com/8941
* If this shader can be represented by another shader + a localMatrix, return that shader and
* the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
*/
virtual sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const;
protected:
SkShaderBase(const SkMatrix* localMatrix = nullptr);

View File

@ -24,7 +24,6 @@
#include "SkParsePath.h"
#include "SkPngCodec.h"
#include "SkShader.h"
#include "SkShaderBase.h"
#include "SkStream.h"
#include "SkTHash.h"
#include "SkTo.h"
@ -548,8 +547,8 @@ SkString SkSVGDevice::AutoElement::addLinearGradientDef(const SkShader::Gradient
gradient.addAttribute("x2", info.fPoint[1].x());
gradient.addAttribute("y2", info.fPoint[1].y());
if (!as_SB(shader)->getLocalMatrix().isIdentity()) {
this->addAttribute("gradientTransform", svg_transform(as_SB(shader)->getLocalMatrix()));
if (!shader->getLocalMatrix().isIdentity()) {
this->addAttribute("gradientTransform", svg_transform(shader->getLocalMatrix()));
}
SkASSERT(info.fColorCount >= 2);

View File

@ -40,7 +40,6 @@
#include "SkRasterClip.h"
#include "SkSFNTHeader.h"
#include "SkShader.h"
#include "SkShaderBase.h"
#include "SkSize.h"
#include "SkStream.h"
#include "SkStrikeCache.h"
@ -1017,7 +1016,7 @@ HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint,
return S_OK;
}
SkMatrix localMatrix = as_SB(shader)->getLocalMatrix();
SkMatrix localMatrix = shader->getLocalMatrix();
if (parentTransform) {
localMatrix.preConcat(*parentTransform);
}
@ -1057,7 +1056,7 @@ HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint,
SkImage* image = shader->isAImage(&outMatrix, xy);
if (image && image->asLegacyBitmap(&outTexture)) {
//TODO: outMatrix??
SkMatrix localMatrix = as_SB(shader)->getLocalMatrix();
SkMatrix localMatrix = shader->getLocalMatrix();
if (parentTransform) {
localMatrix.postConcat(*parentTransform);
}