本文整理汇总了C++中SkMatrix::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::getType方法的具体用法?C++ SkMatrix::getType怎么用?C++ SkMatrix::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTransform
SkMatrix SkPDFDevice::setTransform(const SkMatrix& m) {
SkMatrix old = fGraphicStack[fGraphicStackIndex].fTransform;
if (old == m)
return old;
if (old.getType() != SkMatrix::kIdentity_Mask) {
SkASSERT(fGraphicStackIndex > 0);
SkASSERT(fGraphicStack[fGraphicStackIndex - 1].fTransform.getType() ==
SkMatrix::kIdentity_Mask);
SkASSERT(fGraphicStack[fGraphicStackIndex].fClip ==
fGraphicStack[fGraphicStackIndex - 1].fClip);
popGS();
}
if (m.getType() == SkMatrix::kIdentity_Mask)
return old;
if (fGraphicStackIndex == 0 || fGraphicStack[fGraphicStackIndex].fClip !=
fGraphicStack[fGraphicStackIndex - 1].fClip)
pushGS();
SkScalar transform[6];
SkAssertResult(m.pdfTransform(transform));
for (size_t i = 0; i < SK_ARRAY_COUNT(transform); i++) {
SkPDFScalar::Append(transform[i], &fContent);
fContent.writeText(" ");
}
fContent.writeText("cm\n");
fGraphicStack[fGraphicStackIndex].fTransform = m;
return old;
}
示例2: test_matrix_recttorect
static void test_matrix_recttorect(skiatest::Reporter* reporter) {
SkRect src, dst;
SkMatrix matrix;
src.set(0, 0, SK_Scalar1*10, SK_Scalar1*10);
dst = src;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kIdentity_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst.offset(SK_Scalar1, SK_Scalar1);
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kTranslate_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst.fRight += SK_Scalar1;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter,
(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask) == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst = src;
dst.fRight = src.fRight * 2;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kScale_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
}
示例3: SkASSERT
void SkDeferredCanvas::Rec::setConcat(const SkMatrix& m) {
SkASSERT(m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask));
if (m.getType() <= SkMatrix::kTranslate_Mask) {
fType = kTrans_Type;
fData.fTranslate.set(m.getTranslateX(), m.getTranslateY());
} else {
fType = kScaleTrans_Type;
fData.fScaleTrans.fScale.set(m.getScaleX(), m.getScaleY());
fData.fScaleTrans.fTrans.set(m.getTranslateX(), m.getTranslateY());
}
}
示例4: just_trans_clamp
/**
* For the purposes of drawing bitmaps, if a matrix is "almost" translate
* go ahead and treat it as if it were, so that subsequent code can go fast.
*/
static bool just_trans_clamp(const SkMatrix& matrix, const SkBitmap& bitmap) {
SkASSERT(matrix_only_scale_translate(matrix));
if (matrix.getType() & SkMatrix::kScale_Mask) {
SkRect src, dst;
bitmap.getBounds(&src);
// Can't call mapRect(), since that will fix up inverted rectangles,
// e.g. when scale is negative, and we don't want to return true for
// those.
matrix.mapPoints(SkTCast<SkPoint*>(&dst),
SkTCast<const SkPoint*>(&src),
2);
// Now round all 4 edges to device space, and then compare the device
// width/height to the original. Note: we must map all 4 and subtract
// rather than map the "width" and compare, since we care about the
// phase (in pixel space) that any translate in the matrix might impart.
SkIRect idst;
dst.round(&idst);
return idst.width() == bitmap.width() && idst.height() == bitmap.height();
}
// if we got here, we're either kTranslate_Mask or identity
return true;
}
示例5: just_trans_integral
/**
* Determine if the matrix can be treated as integral-only-translate,
* for the purpose of filtering.
*/
static bool just_trans_integral(const SkMatrix& m) {
static constexpr SkScalar tol = SK_Scalar1 / 256;
return m.getType() <= SkMatrix::kTranslate_Mask
&& SkScalarNearlyEqual(m.getTranslateX(), SkScalarRoundToScalar(m.getTranslateX()), tol)
&& SkScalarNearlyEqual(m.getTranslateY(), SkScalarRoundToScalar(m.getTranslateY()), tol);
}
示例6: memset
void Matrix4::load(const SkMatrix& v) {
memset(data, 0, sizeof(data));
data[kScaleX] = v[SkMatrix::kMScaleX];
data[kSkewX] = v[SkMatrix::kMSkewX];
data[kTranslateX] = v[SkMatrix::kMTransX];
data[kSkewY] = v[SkMatrix::kMSkewY];
data[kScaleY] = v[SkMatrix::kMScaleY];
data[kTranslateY] = v[SkMatrix::kMTransY];
data[kPerspective0] = v[SkMatrix::kMPersp0];
data[kPerspective1] = v[SkMatrix::kMPersp1];
data[kPerspective2] = v[SkMatrix::kMPersp2];
data[kScaleZ] = 1.0f;
// NOTE: The flags are compatible between SkMatrix and this class.
// However, SkMatrix::getType() does not return the flag
// kRectStaysRect. The return value is masked with 0xF
// so we need the extra rectStaysRect() check
mType = v.getType();
if (v.rectStaysRect()) {
mType |= kTypeRectToRect;
}
}
示例7: shouldDrawAntiAliased
bool shouldDrawAntiAliased(const GraphicsContext* context, const SkRect& destRect)
{
if (!context->shouldAntialias())
return false;
const SkMatrix totalMatrix = context->getTotalMatrix();
// Don't disable anti-aliasing if we're rotated or skewed.
if (!totalMatrix.rectStaysRect())
return true;
// Disable anti-aliasing for scales or n*90 degree rotations.
// Allow to opt out of the optimization though for "hairline" geometry
// images - using the shouldAntialiasHairlineImages() GraphicsContext flag.
if (!context->shouldAntialiasHairlineImages())
return false;
// Check if the dimensions of the destination are "small" (less than one
// device pixel). To prevent sudden drop-outs. Since we know that
// kRectStaysRect_Mask is set, the matrix either has scale and no skew or
// vice versa. We can query the kAffine_Mask flag to determine which case
// it is.
// FIXME: This queries the CTM while drawing, which is generally
// discouraged. Always drawing with AA can negatively impact performance
// though - that's why it's not always on.
SkScalar widthExpansion, heightExpansion;
if (totalMatrix.getType() & SkMatrix::kAffine_Mask)
widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = totalMatrix[SkMatrix::kMSkewX];
else
widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = totalMatrix[SkMatrix::kMScaleY];
return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fabs(heightExpansion) < 1;
}
示例8: sizeof
template <typename T> void write_sparse_matrix(T* writer, const SkMatrix& matrix) {
SkMatrix::TypeMask tm = matrix.getType();
SkScalar tmp[9];
if (tm & SkMatrix::kPerspective_Mask) {
matrix.get9(tmp);
writer->write(tmp, 9 * sizeof(SkScalar));
} else if (tm & SkMatrix::kAffine_Mask) {
tmp[0] = matrix[SkMatrix::kMScaleX];
tmp[1] = matrix[SkMatrix::kMSkewX];
tmp[2] = matrix[SkMatrix::kMTransX];
tmp[3] = matrix[SkMatrix::kMScaleY];
tmp[4] = matrix[SkMatrix::kMSkewY];
tmp[5] = matrix[SkMatrix::kMTransY];
writer->write(tmp, 6 * sizeof(SkScalar));
} else if (tm & SkMatrix::kScale_Mask) {
tmp[0] = matrix[SkMatrix::kMScaleX];
tmp[1] = matrix[SkMatrix::kMTransX];
tmp[2] = matrix[SkMatrix::kMScaleY];
tmp[3] = matrix[SkMatrix::kMTransY];
writer->write(tmp, 4 * sizeof(SkScalar));
} else if (tm & SkMatrix::kTranslate_Mask) {
tmp[0] = matrix[SkMatrix::kMTransX];
tmp[1] = matrix[SkMatrix::kMTransY];
writer->write(tmp, 2 * sizeof(SkScalar));
}
// else write nothing for Identity
}
示例9: CanApplyDstMatrixAsCTM
static inline bool CanApplyDstMatrixAsCTM(const SkMatrix& m, const SkPaint& paint) {
if (!paint.getMaskFilter()) {
return true;
}
// Some mask filters parameters (sigma) depend on the CTM/scale.
return m.getType() <= SkMatrix::kTranslate_Mask;
}
示例10: recordScale
void SkPictureRecord::recordScale(const SkMatrix& m) {
SkASSERT(SkMatrix::kScale_Mask == m.getType());
// op + sx + sy
size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(SCALE, &size);
this->addScalar(m.getScaleX());
this->addScalar(m.getScaleY());
this->validate(initialOffset, size);
}
示例11: recordTranslate
void SkPictureRecord::recordTranslate(const SkMatrix& m) {
SkASSERT(SkMatrix::kTranslate_Mask == m.getType());
// op + dx + dy
size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(TRANSLATE, &size);
this->addScalar(m.getTranslateX());
this->addScalar(m.getTranslateY());
this->validate(initialOffset, size);
}
示例12: ComputeMatrixClass
SkShader::MatrixClass SkShader::ComputeMatrixClass(const SkMatrix& mat) {
MatrixClass mc = kLinear_MatrixClass;
if (mat.getType() & SkMatrix::kPerspective_Mask) {
if (mat.fixedStepInX(0, NULL, NULL)) {
mc = kFixedStepInX_MatrixClass;
} else {
mc = kPerspective_MatrixClass;
}
}
return mc;
}
示例13: do_concat
static void do_concat(SkWStream* stream, const SkMatrix& matrix, bool isSetMatrix) {
unsigned mtype = matrix.getType();
SkASSERT(0 == (mtype & ~kTypeMask_ConcatMask));
unsigned extra = mtype;
if (isSetMatrix) {
extra |= kSetMatrix_ConcatMask;
}
if (mtype || isSetMatrix) {
stream->write32(pack_verb(SkPipeVerb::kConcat, extra));
write_sparse_matrix(stream, matrix);
}
}
示例14: SkLocalMatrixImageFilter
sk_sp<SkImageFilter> SkLocalMatrixImageFilter::Make(const SkMatrix& localM,
sk_sp<SkImageFilter> input) {
if (!input) {
return nullptr;
}
if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) {
return nullptr;
}
if (localM.isIdentity()) {
return input;
}
return sk_sp<SkImageFilter>(new SkLocalMatrixImageFilter(localM, input));
}
示例15: didConcat
void SkPictureRecord::didConcat(const SkMatrix& matrix) {
switch (matrix.getType()) {
case SkMatrix::kTranslate_Mask:
this->recordTranslate(matrix);
break;
case SkMatrix::kScale_Mask:
this->recordScale(matrix);
break;
default:
this->recordConcat(matrix);
break;
}
this->INHERITED::didConcat(matrix);
}