本文整理汇总了C++中SkMatrix::preConcat方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::preConcat方法的具体用法?C++ SkMatrix::preConcat怎么用?C++ SkMatrix::preConcat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::preConcat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute_source_rect
// Compute the source rect and return false if it is empty.
static bool compute_source_rect(const SkLayerInfo::BlockInfo& info, const SkMatrix& initialMat,
const SkIRect& dstIR, SkIRect* srcIR) {
SkIRect clipBounds = dstIR;
SkMatrix totMat = initialMat;
totMat.preConcat(info.fPreMat);
totMat.preConcat(info.fLocalMat);
if (info.fPaint && info.fPaint->getImageFilter()) {
info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat, &clipBounds);
}
if (!info.fSrcBounds.isEmpty()) {
SkRect r;
totMat.mapRect(&r, info.fSrcBounds);
r.roundOut(srcIR);
if (!srcIR->intersect(clipBounds)) {
return false;
}
} else {
*srcIR = clipBounds;
}
return true;
}
示例2: MulOutputByInputAlpha
sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPArgs& args) const {
SkASSERT(args.fContext);
SkMatrix localMatrix = this->getLocalMatrix();
if (args.fLocalMatrix) {
localMatrix.preConcat(*args.fLocalMatrix);
}
SkMatrix matrix = *args.fViewMatrix;
matrix.preConcat(localMatrix);
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
// TODO: Either treat the output of this shader as sRGB or allow client to specify a
// color space of the noise. Either way, this case (and the GLSL) need to convert to
// the destination.
sk_sp<GrFragmentProcessor> inner(
GrConstColorProcessor::Make(GrColor4f::FromGrColor(0x80404040),
GrConstColorProcessor::kModulateRGBA_InputMode));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
return GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
GrConstColorProcessor::kIgnore_InputMode);
}
// Either we don't stitch tiles, either we have a valid tile size
SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
SkPerlinNoiseShader::PaintingData* paintingData =
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
sk_sp<GrTextureProxy> permutationsProxy(GrMakeCachedBitmapProxy(
args.fContext->resourceProvider(),
paintingData->getPermutationsBitmap()));
sk_sp<GrTextureProxy> noiseProxy(GrMakeCachedBitmapProxy(args.fContext->resourceProvider(),
paintingData->getNoiseBitmap()));
SkMatrix m = *args.fViewMatrix;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if (permutationsProxy && noiseProxy) {
sk_sp<GrFragmentProcessor> inner(
GrPerlinNoiseEffect::Make(args.fContext->resourceProvider(),
fType,
fNumOctaves,
fStitchTiles,
paintingData,
std::move(permutationsProxy),
std::move(noiseProxy),
m));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
}
示例3: asFragmentProcessor
const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
SkFilterQuality) const {
SkASSERT(context);
SkMatrix localMatrix = this->getLocalMatrix();
if (externalLocalMatrix) {
localMatrix.preConcat(*externalLocalMatrix);
}
SkMatrix matrix = viewM;
matrix.preConcat(localMatrix);
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
SkAutoTUnref<const GrFragmentProcessor> inner(
GrConstColorProcessor::Create(0x80404040,
GrConstColorProcessor::kModulateRGBA_InputMode));
return GrFragmentProcessor::MulOutputByInputAlpha(inner);
}
// Emit zero.
return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
// Either we don't stitch tiles, either we have a valid tile size
SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
SkPerlinNoiseShader::PaintingData* paintingData =
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
SkAutoTUnref<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(),
GrTextureParams::ClampNoFilter()));
SkAutoTUnref<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(),
GrTextureParams::ClampNoFilter()));
SkMatrix m = viewM;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
SkAutoTUnref<GrFragmentProcessor> inner(
GrPerlinNoiseEffect::Create(fType,
fNumOctaves,
fStitchTiles,
paintingData,
permutationsTexture, noiseTexture,
m));
return GrFragmentProcessor::MulOutputByInputAlpha(inner);
}
delete paintingData;
return nullptr;
}
示例4: INHERITED
SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext(
const SkPerlinNoiseShader& shader, const ContextRec& rec)
: INHERITED(shader, rec)
{
SkMatrix newMatrix = *rec.fMatrix;
newMatrix.preConcat(shader.getLocalMatrix());
if (rec.fLocalMatrix) {
newMatrix.preConcat(*rec.fLocalMatrix);
}
// This (1,1) translation is due to WebKit's 1 based coordinates for the noise
// (as opposed to 0 based, usually). The same adjustment is in the setData() function.
fMatrix.setTranslate(-newMatrix.getTranslateX() + SK_Scalar1, -newMatrix.getTranslateY() + SK_Scalar1);
fPaintingData = SkNEW_ARGS(PaintingData, (shader.fTileSize, shader.fSeed, shader.fBaseFrequencyX, shader.fBaseFrequencyY, newMatrix));
}
示例5: drawPathWithMaskFilter
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrDrawContext* drawContext,
const GrClip& clip,
const SkPath& origPath,
const SkPaint& paint,
const SkMatrix& origViewMatrix,
const SkMatrix* prePathMatrix,
const SkIRect& clipBounds,
bool pathIsMutable) {
SkASSERT(!pathIsMutable || origPath.isVolatile());
GrStyle style(paint);
// If we have a prematrix, apply it to the path, optimizing for the case
// where the original path can in fact be modified in place (even though
// its parameter type is const).
const SkPath* path = &origPath;
SkTLazy<SkPath> tmpPath;
SkMatrix viewMatrix = origViewMatrix;
if (prePathMatrix) {
// Styling, blurs, and shading are supposed to be applied *after* the prePathMatrix.
if (!paint.getMaskFilter() && !paint.getShader() && !style.applies()) {
viewMatrix.preConcat(*prePathMatrix);
} else {
SkPath* result = pathIsMutable ? const_cast<SkPath*>(path) : tmpPath.init();
pathIsMutable = true;
path->transform(*prePathMatrix, result);
path = result;
result->setIsVolatile(true);
}
}
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
示例6: localToAncestor
void Layer::localToAncestor(const Layer* ancestor, SkMatrix* matrix) const {
if (this == ancestor) {
matrix->setIdentity();
return;
}
getLocalTransform(matrix);
// Fixed position layers simply use the root layer's transform.
if (shouldInheritFromRootTransform()) {
ASSERT(!ancestor);
matrix->postConcat(getRootLayer()->getMatrix());
return;
}
// Apply the local and child transforms for every layer between this layer
// and ancestor.
ASSERT(isAncestor(ancestor));
for (const Layer* layer = this->fParent; layer != ancestor; layer = layer->fParent) {
SkMatrix tmp;
layer->getLocalTransform(&tmp);
tmp.preConcat(layer->getChildrenMatrix());
matrix->postConcat(tmp);
}
// If ancestor is not the root layer, apply its child transformation too.
if (ancestor)
matrix->postConcat(ancestor->getChildrenMatrix());
}
示例7: parseTransform
// https://www.w3.org/TR/SVG/coords.html#TransformAttribute
bool SkSVGAttributeParser::parseTransform(SkSVGTransformType* t) {
SkMatrix matrix = SkMatrix::I();
bool parsed = false;
while (true) {
SkMatrix m;
if (!( this->parseMatrixToken(&m)
|| this->parseTranslateToken(&m)
|| this->parseScaleToken(&m)
|| this->parseRotateToken(&m)
|| this->parseSkewXToken(&m)
|| this->parseSkewYToken(&m))) {
break;
}
matrix.preConcat(m);
parsed = true;
}
this->parseWSToken();
if (!parsed || !this->parseEOSToken()) {
return false;
}
*t = SkSVGTransformType(matrix);
return true;
}
示例8: DrawToTargetWithPathMask
void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
GrDrawTarget* target,
const SkIRect& rect) {
GrDrawState* drawState = target->drawState();
GrDrawState::AutoViewMatrixRestore avmr;
if (!avmr.setIdentity(drawState)) {
return;
}
GrDrawState::AutoRestoreEffects are(drawState);
SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft,
SK_Scalar1 * rect.fTop,
SK_Scalar1 * rect.fRight,
SK_Scalar1 * rect.fBottom);
// We want to use device coords to compute the texture coordinates. We set our matrix to be
// equal to the view matrix followed by a translation so that the top-left of the device bounds
// maps to 0,0, and then a scaling matrix to normalized coords. We apply this matrix to the
// vertex positions rather than local coords.
SkMatrix maskMatrix;
maskMatrix.setIDiv(texture->width(), texture->height());
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
maskMatrix.preConcat(drawState->getViewMatrix());
drawState->addCoverageEffect(
GrSimpleTextureEffect::Create(texture,
maskMatrix,
GrTextureParams::kNone_FilterMode,
kPosition_GrCoordSet))->unref();
target->drawSimpleRect(dstRect);
}
示例9: DrawToTargetWithShapeMask
void GrSWMaskHelper::DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkIPoint& textureOriginInDeviceSpace,
const SkIRect& deviceSpaceRectToDraw) {
SkMatrix invert;
if (!viewMatrix.invert(&invert)) {
return;
}
GrResourceProvider* resourceProvider = renderTargetContext->resourceProvider();
SkRect dstRect = SkRect::Make(deviceSpaceRectToDraw);
// We use device coords to compute the texture coordinates. We take the device coords and apply
// a translation so that the top-left of the device bounds maps to 0,0, and then a scaling
// matrix to normalized coords.
SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
std::unique_ptr<GrLegacyMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill(
paint.getColor(), SkMatrix::I(), dstRect, nullptr, &invert);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
resourceProvider, std::move(proxy), nullptr, maskMatrix,
GrSamplerParams::kNone_FilterMode));
GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone);
pipelineBuilder.setUserStencil(&userStencilSettings);
renderTargetContext->addLegacyMeshDrawOp(std::move(pipelineBuilder), clip, std::move(op));
}
示例10: NativePreConcat
void Matrix::NativePreConcat(
/* [in] */ Int64 objHandle,
/* [in] */ Int64 otherHandle)
{
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle);
obj->preConcat(*other);
}
示例11: asFragmentProcessor
const GrFragmentProcessor* SkImageShader::asFragmentProcessor(GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
GrProcessorDataManager* mgr) const {
SkMatrix matrix;
matrix.setIDiv(fImage->width(), fImage->height());
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
return nullptr;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
return nullptr;
}
lmInverse.postConcat(inv);
}
matrix.preConcat(lmInverse);
SkShader::TileMode tm[] = { fTileModeX, fTileModeY };
// Must set wrap and filter on the sampler before requesting a texture. In two places below
// we check the matrix scale factors to determine how to interpret the filter quality setting.
// This completely ignores the complexity of the drawVertices case where explicit local coords
// are provided by the caller.
bool doBicubic;
GrTextureParams::FilterMode textureFilterMode =
GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), &doBicubic);
GrTextureParams params(tm, textureFilterMode);
SkImageUsageType usageType;
if (kClamp_TileMode == fTileModeX && kClamp_TileMode == fTileModeY) {
usageType = kUntiled_SkImageUsageType;
} else if (GrTextureParams::kNone_FilterMode == textureFilterMode) {
usageType = kTiled_Unfiltered_SkImageUsageType;
} else {
usageType = kTiled_Filtered_SkImageUsageType;
}
SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, usageType));
if (!texture) {
return nullptr;
}
SkAutoTUnref<GrFragmentProcessor> inner;
if (doBicubic) {
inner.reset(GrBicubicEffect::Create(mgr, texture, matrix, tm));
} else {
inner.reset(GrSimpleTextureEffect::Create(mgr, texture, matrix, params));
}
if (GrPixelConfigIsAlphaOnly(texture->config())) {
return SkRef(inner.get());
}
return GrFragmentProcessor::MulOuputByInputAlpha(inner);
}
示例12: computeNormTotalInverse
bool SkNormalMapSourceImpl::computeNormTotalInverse(const SkShaderBase::ContextRec& rec,
SkMatrix* normTotalInverse) const {
SkMatrix total = SkMatrix::Concat(*rec.fMatrix, fMapShader->getLocalMatrix());
if (rec.fLocalMatrix) {
total.preConcat(*rec.fLocalMatrix);
}
return total.invert(normTotalInverse);
}
示例13: drawBitmap
void SkSVGDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) {
SkMatrix adjustedMatrix = *draw.fMatrix;
adjustedMatrix.preConcat(matrix);
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
drawBitmapCommon(adjustedDraw, bitmap, paint);
}
示例14: asFragmentProcessor
bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
const SkMatrix& viewM,
const SkMatrix* localMatrix, GrColor* paintColor,
GrProcessorDataManager* procDataManager,
GrFragmentProcessor** fp) const {
SkMatrix matrix;
matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
return false;
}
lmInverse.postConcat(inv);
}
matrix.preConcat(lmInverse);
SkShader::TileMode tm[] = {
(TileMode)fTileModeX,
(TileMode)fTileModeY,
};
// Must set wrap and filter on the sampler before requesting a texture. In two places below
// we check the matrix scale factors to determine how to interpret the filter quality setting.
// This completely ignores the complexity of the drawVertices case where explicit local coords
// are provided by the caller.
bool doBicubic;
GrTextureParams::FilterMode textureFilterMode =
GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, this->getLocalMatrix(),
&doBicubic);
GrTextureParams params(tm, textureFilterMode);
SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, ¶ms));
if (!texture) {
SkErrorInternals::SetError( kInternalError_SkError,
"Couldn't convert bitmap to texture.");
return false;
}
*paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ?
SkColor2GrColor(paint.getColor()) :
SkColor2GrColorJustAlpha(paint.getColor());
if (doBicubic) {
*fp = GrBicubicEffect::Create(procDataManager, texture, matrix, tm);
} else {
*fp = GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params);
}
return true;
}
示例15: writeDeltaMat
void SkMatrixClipStateMgr::writeDeltaMat(int currentMatID, int desiredMatID) {
const SkMatrix& current = this->lookupMat(currentMatID);
const SkMatrix& desired = this->lookupMat(desiredMatID);
SkMatrix delta;
bool result = current.invert(&delta);
if (result) {
delta.preConcat(desired);
}
fPicRecord->recordConcat(delta);
}