本文整理汇总了C++中SkMatrix::postConcat方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::postConcat方法的具体用法?C++ SkMatrix::postConcat怎么用?C++ SkMatrix::postConcat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::postConcat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_anchor
void anchor_handle_renderer::draw_anchor (SkCanvas &canvas, const SkRect &rect, SkPaint &paint) const
{
switch (m_node_type)
{
case handle_type::DIAMOND:
{
canvas.save ();
canvas.translate (rect.centerX (), rect.centerY ());
canvas.rotate (45);
SkRect moved_rect = rect;
moved_rect.offset (-rect.centerX (), -rect.centerY ());
paint.setAntiAlias (true);
canvas.drawRect (moved_rect, paint);
canvas.restore ();
break;
}
case handle_type::SQUARE:
canvas.drawRect (rect, paint);
break;
case handle_type::CIRCLE:
canvas.drawOval (rect, paint);
break;
case handle_type::DOUBLE_HEADED_ARROW:
case handle_type::ROTATE_ARROW:
SkPath path = qt2skia::path (*m_paths.at (m_node_type));
SkMatrix trans;
trans.setIdentity ();
trans.postRotate (m_rotation_angle, 32, 32); // TODO: change all these to use info from path_storage (bounding box and center (possibly should be made 0))
trans.postConcat (qt2skia::matrix (geom::rect2rect (QRectF (0, 0, 64, 64), qt2skia::rect (rect))));
path.transform (trans);
paint.setAntiAlias (true);
canvas.drawPath (path, paint);
break;
}
}
示例2: drawBitmap
void SkPDFDevice::drawBitmap(const SkDraw&, const SkBitmap& bitmap,
const SkIRect* srcRect,
const SkMatrix& matrix, const SkPaint& paint) {
SkMatrix transform = matrix;
transform.postConcat(fGraphicStack[fGraphicStackIndex].fTransform);
internalDrawBitmap(transform, bitmap, srcRect, paint);
}
示例3: internalDrawBitmap
void SkPDFDevice::internalDrawBitmap(const SkMatrix& matrix,
const SkBitmap& bitmap,
const SkIRect* srcRect,
const SkPaint& paint) {
SkIRect subset = SkIRect::MakeWH(bitmap.width(), bitmap.height());
if (srcRect && !subset.intersect(*srcRect))
return;
SkPDFImage* image = SkPDFImage::CreateImage(bitmap, subset, paint);
if (!image)
return;
SkMatrix scaled;
// Adjust for origin flip.
scaled.setScale(1, -1);
scaled.postTranslate(0, 1);
// Scale the image up from 1x1 to WxH.
scaled.postScale(SkIntToScalar(subset.width()),
SkIntToScalar(subset.height()));
scaled.postConcat(matrix);
SkMatrix curTransform = setTransform(scaled);
updateGSFromPaint(paint, false);
fXObjectResources.push(image); // Transfer reference.
fContent.writeText("/X");
fContent.writeDecAsText(fXObjectResources.count() - 1);
fContent.writeText(" Do\n");
setTransform(curTransform);
}
示例4: scaleCanvas
DEF_TEST(RecordDraw_SetMatrixClobber, r) {
// Set up an SkRecord that just scales by 2x,3x.
SkRecord scaleRecord;
SkRecorder scaleCanvas(&scaleRecord, W, H);
SkMatrix scale;
scale.setScale(2, 3);
scaleCanvas.setMatrix(scale);
// Set up an SkRecord with an initial +20, +20 translate.
SkRecord translateRecord;
SkRecorder translateCanvas(&translateRecord, W, H);
SkMatrix translate;
translate.setTranslate(20, 20);
translateCanvas.setMatrix(translate);
SkRecordDraw(scaleRecord, &translateCanvas, nullptr, nullptr, 0, nullptr/*bbh*/, nullptr/*callback*/);
REPORTER_ASSERT(r, 4 == translateRecord.count());
assert_type<SkRecords::SetMatrix>(r, translateRecord, 0);
assert_type<SkRecords::Save> (r, translateRecord, 1);
assert_type<SkRecords::SetMatrix>(r, translateRecord, 2);
assert_type<SkRecords::Restore> (r, translateRecord, 3);
// When we look at translateRecord now, it should have its first +20,+20 translate,
// then a 2x,3x scale that's been concatted with that +20,+20 translate.
const SkRecords::SetMatrix* setMatrix;
setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0);
REPORTER_ASSERT(r, setMatrix->matrix == translate);
setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 2);
SkMatrix expected = scale;
expected.postConcat(translate);
REPORTER_ASSERT(r, setMatrix->matrix == expected);
}
示例5: onDraw
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(fAA);
paint.setBlendMode(fMode);
SkColor color = start_color(fColorType);
int w = this->getSize().x();
int h = this->getSize().y();
static const SkScalar kRectW = 25.1f;
static const SkScalar kRectH = 25.9f;
if (fColorType == kShaderOpaque_ColorType) {
// The only requirement for the shader is that it requires local coordinates
SkPoint pts[2] = { {0.0f, 0.0f}, {kRectW, kRectH} };
SkColor colors[] = { color, SK_ColorBLUE };
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
SkTileMode::kClamp));
}
SkMatrix rotate;
// This value was chosen so that we frequently hit the axis-aligned case.
rotate.setRotate(30.f, kRectW / 2, kRectH / 2);
SkMatrix m = rotate;
SkScalar tx = 0, ty = 0;
if (fPerspective) {
// Apply some fixed perspective to change how ops may draw the rects
SkMatrix perspective;
perspective.setIdentity();
perspective.setPerspX(1e-4f);
perspective.setPerspY(1e-3f);
perspective.setSkewX(0.1f);
canvas->concat(perspective);
}
for (int i = 0; i < loops; ++i) {
canvas->save();
canvas->translate(tx, ty);
canvas->concat(m);
paint.setColor(color);
color = advance_color(color, fColorType, i);
canvas->drawRect(SkRect::MakeWH(kRectW, kRectH), paint);
canvas->restore();
tx += kRectW + 2;
if (tx > w) {
tx = 0;
ty += kRectH + 2;
if (ty > h) {
ty = 0;
}
}
m.postConcat(rotate);
}
}
示例6: NativePostConcat
void Matrix::NativePostConcat(
/* [in] */ Int64 nObj,
/* [in] */ Int64 nOther)
{
SkMatrix* matrix = reinterpret_cast<SkMatrix*>(nObj);
SkMatrix* other = reinterpret_cast<SkMatrix*>(nOther);
matrix->postConcat(*other);
}
示例7: 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);
}
示例8: onFilterImage
bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
SkRect dstRect;
SkIRect srcBounds, dstBounds;
src.getBounds(&srcBounds);
srcBounds.offset(srcOffset);
SkRect srcRect = SkRect::Make(srcBounds);
SkMatrix matrix;
if (!ctx.ctm().invert(&matrix)) {
return false;
}
matrix.postConcat(fTransform);
matrix.postConcat(ctx.ctm());
matrix.mapRect(&dstRect, srcRect);
dstRect.roundOut(&dstBounds);
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device.get());
canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
canvas.concat(matrix);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setFilterLevel(fFilterLevel);
canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint);
*result = device.get()->accessBitmap(false);
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
return true;
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_skia,代码行数:44,代码来源:SkMatrixImageFilter.cpp
示例9: 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;
}
示例10: computeFastBounds
void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
SkRect bounds = src;
if (getInput(0)) {
getInput(0)->computeFastBounds(src, &bounds);
}
SkMatrix matrix;
matrix.setTranslate(-bounds.x(), -bounds.y());
matrix.postConcat(fTransform);
matrix.postTranslate(bounds.x(), bounds.y());
matrix.mapRect(dst, bounds);
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_skia,代码行数:11,代码来源:SkMatrixImageFilter.cpp
示例11: currentTransformMatrix
SkMatrix View::currentTransformMatrix(View* ancestor)
{
SkMatrix m;
m.reset();
View* v = this;
while (v && v != ancestor) {
m.postConcat(v->matrix());
v = v->m_parent;
}
return m;
}
示例12: drawPicture
void SKPAnimationBench::drawPicture() {
SkMatrix frameMatrix = SkMatrix::MakeTrans(-fCenter.fX, -fCenter.fY);
frameMatrix.postConcat(fAnimationMatrix);
SkMatrix reverseTranslate = SkMatrix::MakeTrans(fCenter.fX, fCenter.fY);
frameMatrix.postConcat(reverseTranslate);
SkMatrix currentMatrix = frameMatrix;
for (int i = 0; i < fSteps; i++) {
for (int j = 0; j < this->tileRects().count(); ++j) {
SkMatrix trans = SkMatrix::MakeTrans(-1.f * this->tileRects()[j].fLeft,
-1.f * this->tileRects()[j].fTop);
SkMatrix tileMatrix = currentMatrix;
tileMatrix.postConcat(trans);
this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &tileMatrix, NULL);
}
for (int j = 0; j < this->tileRects().count(); ++j) {
this->surfaces()[j]->getCanvas()->flush();
}
currentMatrix.postConcat(frameMatrix);
}
}
示例13: onFilterBounds
bool SkMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
SkMatrix transformInverse;
if (!fTransform.invert(&transformInverse)) {
return false;
}
SkMatrix matrix;
if (!ctm.invert(&matrix)) {
return false;
}
matrix.postConcat(transformInverse);
matrix.postConcat(ctm);
SkRect floatBounds;
matrix.mapRect(&floatBounds, SkRect::Make(src));
SkIRect bounds = floatBounds.roundOut();
if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
return true;
}
示例14: SkASSERT
void SkPictureStateTree::Iterator::setCurrentMatrix(const SkMatrix* matrix) {
SkASSERT(NULL != matrix);
if (matrix == fCurrentMatrix) {
return;
}
// The matrix is in recording space, but we also inherit
// a playback matrix from out target canvas.
SkMatrix m = *matrix;
m.postConcat(fPlaybackMatrix);
fCanvas->setMatrix(m);
fCurrentMatrix = matrix;
}
示例15: params
sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& args) const {
SkMatrix matrix;
matrix.setIDiv(fImage->width(), fImage->height());
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
return nullptr;
}
if (args.fLocalMatrix) {
SkMatrix inv;
if (!args.fLocalMatrix->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(args.fFilterQuality, *args.fViewMatrix, this->getLocalMatrix(),
&doBicubic);
GrTextureParams params(tm, textureFilterMode);
SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params,
args.fGammaTreatment));
if (!texture) {
return nullptr;
}
sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
inner = GrBicubicEffect::Make(texture, nullptr, matrix, tm);
} else {
inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params);
}
if (GrPixelConfigIsAlphaOnly(texture->config())) {
return inner;
}
return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)));
}