本文整理汇总了C++中SkMatrix::getScaleY方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::getScaleY方法的具体用法?C++ SkMatrix::getScaleY怎么用?C++ SkMatrix::getScaleY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::getScaleY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Check to see that the size of the bitmap that would be produced by
// scaling by the given inverted matrix is less than the maximum allowed.
static inline bool cache_size_okay(const SkBitmapProvider& provider, const SkMatrix& invMat) {
size_t maximumAllocation = SkResourceCache::GetEffectiveSingleAllocationByteLimit();
if (0 == maximumAllocation) {
return true;
}
// float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY);
// return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize);
// Skip the division step:
const size_t size = provider.info().getSafeSize(provider.info().minRowBytes());
return size < (maximumAllocation * invMat.getScaleX() * invMat.getScaleY());
}
示例2: effective_matrix_scale_sqrd
static SkScalar effective_matrix_scale_sqrd(const SkMatrix& mat) {
SkPoint v1, v2;
v1.fX = mat.getScaleX();
v1.fY = mat.getSkewY();
v2.fX = mat.getSkewX();
v2.fY = mat.getScaleY();
return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd());
}
示例3:
// Check to see that the size of the bitmap that would be produced by
// scaling by the given inverted matrix is less than the maximum allowed.
static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) {
size_t maximumAllocation
= SkScaledImageCache::GetSingleAllocationByteLimit();
if (0 == maximumAllocation) {
return true;
}
// float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY);
// return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize);
// Skip the division step:
return bm.info().getSafeSize(bm.info().minRowBytes())
< (maximumAllocation * invMat.getScaleX() * invMat.getScaleY());
}
示例4: 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());
}
}
示例5: SkScalerContext
SkScalerContext_Ascender::SkScalerContext_Ascender(const SkDescriptor* desc)
: SkScalerContext(desc)
{
int size = aca_Get_FontHandleRec_Size();
fHandle = (aca_FontHandle)sk_malloc_throw(size);
// get the pointer to the font
fFontStream = new SkMMAPStream("/UcsGB2312-Hei-H.FDL");
fHintStream = new SkMMAPStream("/genv6-23.bin");
void* hints = sk_malloc_throw(fHintStream->getLength());
memcpy(hints, fHintStream->getMemoryBase(), fHintStream->getLength());
aca_Create_Font_Handle(fHandle,
(void*)fFontStream->getMemoryBase(), fFontStream->getLength(),
"fred",
hints, fHintStream->getLength());
// compute our factors from the record
SkMatrix m;
fRec.getSingleMatrix(&m);
// now compute our scale factors
SkScalar sx = m.getScaleX();
SkScalar sy = m.getScaleY();
int ppemX = SkScalarRound(sx);
int ppemY = SkScalarRound(sy);
size = aca_Find_Font_Memory_Required(fHandle, ppemX, ppemY);
size *= 8; // Jeff suggests this :)
fWorkspace = sk_malloc_throw(size);
aca_Set_Font_Memory(fHandle, (uint8_t*)fWorkspace, size);
aca_GlyphAttribsRec rec;
memset(&rec, 0, sizeof(rec));
rec.xSize = ppemX;
rec.ySize = ppemY;
rec.doAdjust = true;
rec.doExceptions = true;
rec.doGlyphHints = true;
rec.doInterpolate = true;
rec.grayMode = 2;
aca_Set_Font_Attributes(fHandle, &rec, &size);
fGlyphWorkspace = sk_malloc_throw(size);
aca_Set_Glyph_Memory(fHandle, fGlyphWorkspace);
}
示例6: mapDstScaleTranslate
void SkLatticeIter::mapDstScaleTranslate(const SkMatrix& matrix) {
SkASSERT(matrix.isScaleTranslate());
SkScalar tx = matrix.getTranslateX();
SkScalar sx = matrix.getScaleX();
for (int i = 0; i < fDstX.count(); i++) {
fDstX[i] = fDstX[i] * sx + tx;
}
SkScalar ty = matrix.getTranslateY();
SkScalar sy = matrix.getScaleY();
for (int i = 0; i < fDstY.count(); i++) {
fDstY[i] = fDstY[i] * sy + ty;
}
}
示例7: generateFontMetrics
void SkGScalerContext::generateFontMetrics(SkPaint::FontMetrics* metrics) {
fProxy->getFontMetrics(metrics);
if (metrics) {
SkScalar scale = fMatrix.getScaleY();
metrics->fTop = SkScalarMul(metrics->fTop, scale);
metrics->fAscent = SkScalarMul(metrics->fAscent, scale);
metrics->fDescent = SkScalarMul(metrics->fDescent, scale);
metrics->fBottom = SkScalarMul(metrics->fBottom, scale);
metrics->fLeading = SkScalarMul(metrics->fLeading, scale);
metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale);
metrics->fXMin = SkScalarMul(metrics->fXMin, scale);
metrics->fXMax = SkScalarMul(metrics->fXMax, scale);
metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale);
}
}
示例8: SkASSERT
GrCCPathCache::MaskTransform::MaskTransform(const SkMatrix& m, SkIVector* shift)
: fMatrix2x2{m.getScaleX(), m.getSkewX(), m.getSkewY(), m.getScaleY()} {
SkASSERT(!m.hasPerspective());
Sk2f translate = Sk2f(m.getTranslateX(), m.getTranslateY());
Sk2f transFloor;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// On Android framework we pre-round view matrix translates to integers for better caching.
transFloor = translate;
#else
transFloor = translate.floor();
(translate - transFloor).store(fSubpixelTranslate);
#endif
shift->set((int)transFloor[0], (int)transFloor[1]);
SkASSERT((float)shift->fX == transFloor[0]); // Make sure transFloor had integer values.
SkASSERT((float)shift->fY == transFloor[1]);
}
示例9: calculate_translation
static void calculate_translation(bool applyVM,
const SkMatrix& newViewMatrix, SkScalar newX, SkScalar newY,
const SkMatrix& currentViewMatrix, SkScalar currentX,
SkScalar currentY, SkScalar* transX, SkScalar* transY) {
if (applyVM) {
*transX = newViewMatrix.getTranslateX() +
newViewMatrix.getScaleX() * (newX - currentX) +
newViewMatrix.getSkewX() * (newY - currentY) -
currentViewMatrix.getTranslateX();
*transY = newViewMatrix.getTranslateY() +
newViewMatrix.getSkewY() * (newX - currentX) +
newViewMatrix.getScaleY() * (newY - currentY) -
currentViewMatrix.getTranslateY();
} else {
*transX = newX - currentX;
*transY = newY - currentY;
}
}
示例10: nextafterf
SkLinearBitmapPipeline::SkLinearBitmapPipeline(
const SkMatrix& inverse,
SkFilterQuality filterQuality,
SkShader::TileMode xTile, SkShader::TileMode yTile,
SkColor paintColor,
const SkPixmap& srcPixmap)
{
SkISize dimensions = srcPixmap.info().dimensions();
const SkImageInfo& srcImageInfo = srcPixmap.info();
SkMatrix adjustedInverse = inverse;
if (filterQuality == kNone_SkFilterQuality) {
if (inverse.getScaleX() >= 0.0f) {
adjustedInverse.setTranslateX(
nextafterf(inverse.getTranslateX(), std::floor(inverse.getTranslateX())));
}
if (inverse.getScaleY() >= 0.0f) {
adjustedInverse.setTranslateY(
nextafterf(inverse.getTranslateY(), std::floor(inverse.getTranslateY())));
}
}
SkScalar dx = adjustedInverse.getScaleX();
// If it is an index 8 color type, the sampler converts to unpremul for better fidelity.
SkAlphaType alphaType = srcImageInfo.alphaType();
if (srcPixmap.colorType() == kIndex_8_SkColorType) {
alphaType = kUnpremul_SkAlphaType;
}
float postAlpha = SkColorGetA(paintColor) * (1.0f / 255.0f);
// As the stages are built, the chooser function may skip a stage. For example, with the
// identity matrix, the matrix stage is skipped, and the tilerStage is the first stage.
auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlenderStage);
auto samplerStage = choose_pixel_sampler(
blenderStage, filterQuality, xTile, yTile,
srcPixmap, paintColor, &fSampleStage, &fAccessor);
auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile,
filterQuality, dx, &fTileStage);
fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage);
fLastStage = blenderStage;
}
示例11: dump
void SkFlatMatrix::dump() const {
const SkMatrix* matrix = (const SkMatrix*) fMatrixData;
char pBuffer[DUMP_BUFFER_SIZE];
char* bufferPtr = pBuffer;
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"matrix: ");
SkScalar scaleX = matrix->getScaleX();
SkMatrix defaultMatrix;
defaultMatrix.reset();
if (scaleX != defaultMatrix.getScaleX())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"scaleX:%g ", SkScalarToFloat(scaleX));
SkScalar scaleY = matrix->getScaleY();
if (scaleY != defaultMatrix.getScaleY())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"scaleY:%g ", SkScalarToFloat(scaleY));
SkScalar skewX = matrix->getSkewX();
if (skewX != defaultMatrix.getSkewX())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"skewX:%g ", SkScalarToFloat(skewX));
SkScalar skewY = matrix->getSkewY();
if (skewY != defaultMatrix.getSkewY())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"skewY:%g ", SkScalarToFloat(skewY));
SkScalar translateX = matrix->getTranslateX();
if (translateX != defaultMatrix.getTranslateX())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"translateX:%g ", SkScalarToFloat(translateX));
SkScalar translateY = matrix->getTranslateY();
if (translateY != defaultMatrix.getTranslateY())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"translateY:%g ", SkScalarToFloat(translateY));
SkScalar perspX = matrix->getPerspX();
if (perspX != defaultMatrix.getPerspX())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"perspX:%g ", SkFractToFloat(perspX));
SkScalar perspY = matrix->getPerspY();
if (perspY != defaultMatrix.getPerspY())
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"perspY:%g ", SkFractToFloat(perspY));
SkDebugf("%s\n", pBuffer);
}
示例12: push_concat
bool SkDeferredCanvas::push_concat(const SkMatrix& mat) {
if (mat.getType() > (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
return false;
}
// At the moment, we don't know which ops can scale and which can also flip, so
// we reject negative scales for now
if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
return false;
}
int index = fRecs.count() - 1;
SkMatrix m;
if (index >= 0 && fRecs[index].isConcat(&m)) {
m.preConcat(mat);
fRecs[index].setConcat(m);
} else {
fRecs.append()->setConcat(mat);
}
return true;
}
示例13: didConcat
void SkDumpCanvas::didConcat(const SkMatrix& matrix) {
SkString str;
switch (matrix.getType()) {
case SkMatrix::kTranslate_Mask:
this->dump(kMatrix_Verb, nullptr, "translate(%g %g)",
SkScalarToFloat(matrix.getTranslateX()),
SkScalarToFloat(matrix.getTranslateY()));
break;
case SkMatrix::kScale_Mask:
this->dump(kMatrix_Verb, nullptr, "scale(%g %g)",
SkScalarToFloat(matrix.getScaleX()),
SkScalarToFloat(matrix.getScaleY()));
break;
default:
matrix.toString(&str);
this->dump(kMatrix_Verb, nullptr, "concat(%s)", str.c_str());
break;
}
this->INHERITED::didConcat(matrix);
}
示例14: didConcat
void LoggingCanvas::didConcat(const SkMatrix& matrix)
{
AutoLogger logger(this);
RefPtr<JSONObject> params;
switch (matrix.getType()) {
case SkMatrix::kTranslate_Mask:
params = logger.logItemWithParams("translate");
params->setNumber("dx", matrix.getTranslateX());
params->setNumber("dy", matrix.getTranslateY());
break;
case SkMatrix::kScale_Mask:
params = logger.logItemWithParams("scale");
params->setNumber("scaleX", matrix.getScaleX());
params->setNumber("scaleY", matrix.getScaleY());
break;
default:
params = logger.logItemWithParams("concat");
params->setArray("matrix", arrayForSkMatrix(matrix));
}
this->SkCanvas::didConcat(matrix);
}
示例15: drawPattern
void NativeImageSkia::drawPattern(
GraphicsContext* context,
const FloatRect& floatSrcRect,
const FloatSize& scale,
const FloatPoint& phase,
CompositeOperator compositeOp,
const FloatRect& destRect,
blink::WebBlendMode blendMode,
const IntSize& repeatSpacing) const
{
FloatRect normSrcRect = floatSrcRect;
normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height()));
if (destRect.isEmpty() || normSrcRect.isEmpty())
return; // nothing to draw
SkMatrix totalMatrix = context->getTotalMatrix();
SkScalar ctmScaleX = totalMatrix.getScaleX();
SkScalar ctmScaleY = totalMatrix.getScaleY();
totalMatrix.preScale(scale.width(), scale.height());
// Figure out what size the bitmap will be in the destination. The
// destination rect is the bounds of the pattern, we need to use the
// matrix to see how big it will be.
SkRect destRectTarget;
totalMatrix.mapRect(&destRectTarget, normSrcRect);
float destBitmapWidth = SkScalarToFloat(destRectTarget.width());
float destBitmapHeight = SkScalarToFloat(destRectTarget.height());
// Compute the resampling mode.
ResamplingMode resampling;
if (context->isAccelerated() || context->printing())
resampling = LinearResampling;
else
resampling = computeResamplingMode(totalMatrix, normSrcRect.width(), normSrcRect.height(), destBitmapWidth, destBitmapHeight);
resampling = limitResamplingMode(context, resampling);
SkMatrix shaderTransform;
RefPtr<SkShader> shader;
bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap());
// Bicubic filter is only applied to defer-decoded images, see
// NativeImageSkia::draw for details.
bool useBicubicFilter = resampling == AwesomeResampling && isLazyDecoded;
if (resampling == AwesomeResampling && !useBicubicFilter) {
// Do nice resampling.
float scaleX = destBitmapWidth / normSrcRect.width();
float scaleY = destBitmapHeight / normSrcRect.height();
SkRect scaledSrcRect;
// The image fragment generated here is not exactly what is
// requested. The scale factor used is approximated and image
// fragment is slightly larger to align to integer
// boundaries.
SkBitmap resampled = extractScaledImageFragment(normSrcRect, scaleX, scaleY, &scaledSrcRect);
if (repeatSpacing.isZero()) {
shader = adoptRef(SkShader::CreateBitmapShader(resampled, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
} else {
shader = adoptRef(SkShader::CreateBitmapShader(
createBitmapWithSpace(resampled, repeatSpacing.width() * ctmScaleX, repeatSpacing.height() * ctmScaleY),
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
}
// Since we just resized the bitmap, we need to remove the scale
// applied to the pixels in the bitmap shader. This means we need
// CTM * shaderTransform to have identity scale. Since we
// can't modify CTM (or the rectangle will be drawn in the wrong
// place), we must set shaderTransform's scale to the inverse of
// CTM scale.
shaderTransform.setScale(ctmScaleX ? 1 / ctmScaleX : 1, ctmScaleY ? 1 / ctmScaleY : 1);
} else {
// No need to resample before drawing.
SkBitmap srcSubset;
bitmap().extractSubset(&srcSubset, enclosingIntRect(normSrcRect));
if (repeatSpacing.isZero()) {
shader = adoptRef(SkShader::CreateBitmapShader(srcSubset, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
} else {
shader = adoptRef(SkShader::CreateBitmapShader(
createBitmapWithSpace(srcSubset, repeatSpacing.width() * ctmScaleX, repeatSpacing.height() * ctmScaleY),
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
}
// Because no resizing occurred, the shader transform should be
// set to the pattern's transform, which just includes scale.
shaderTransform.setScale(scale.width(), scale.height());
}
// We also need to translate it such that the origin of the pattern is the
// origin of the destination rect, which is what WebKit expects. Skia uses
// the coordinate system origin as the base for the pattern. If WebKit wants
// a shifted image, it will shift it from there using the shaderTransform.
float adjustedX = phase.x() + normSrcRect.x() * scale.width();
float adjustedY = phase.y() + normSrcRect.y() * scale.height();
shaderTransform.postTranslate(SkFloatToScalar(adjustedX), SkFloatToScalar(adjustedY));
shader->setLocalMatrix(shaderTransform);
SkPaint paint;
paint.setShader(shader.get());
paint.setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).get());
//.........这里部分代码省略.........