本文整理汇总了C++中SkDrawBitmapRectCommand::setDstRect方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDrawBitmapRectCommand::setDstRect方法的具体用法?C++ SkDrawBitmapRectCommand::setDstRect怎么用?C++ SkDrawBitmapRectCommand::setDstRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDrawBitmapRectCommand
的用法示例。
在下文中一共展示了SkDrawBitmapRectCommand::setDstRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Fold the clipRect into the drawBitmapRectToRect's src and dest rects
static void apply_8(SkDebugCanvas* canvas, int curCommand) {
SkClipRectCommand* clip =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
SkDrawBitmapRectCommand* dbmr =
(SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
SkScalar newSrcLeft, newSrcTop;
if (NULL != dbmr->srcRect()) {
newSrcLeft = dbmr->srcRect()->fLeft + clip->rect().fLeft - dbmr->dstRect().fLeft;
newSrcTop = dbmr->srcRect()->fTop + clip->rect().fTop - dbmr->dstRect().fTop;
} else {
newSrcLeft = clip->rect().fLeft - dbmr->dstRect().fLeft;
newSrcTop = clip->rect().fTop - dbmr->dstRect().fTop;
}
SkRect newSrc = SkRect::MakeXYWH(newSrcLeft, newSrcTop,
clip->rect().width(), clip->rect().height());
dbmr->setSrcRect(newSrc);
dbmr->setDstRect(clip->rect());
// remove everything except the drawbitmaprect
canvas->deleteDrawCommandAt(curCommand+3);
canvas->deleteDrawCommandAt(curCommand+1);
canvas->deleteDrawCommandAt(curCommand);
}
示例2: SkColorGetA
// Reduce to a single drawBitmapRectToRect call by folding the clipRect's into
// the src and dst Rects and the saveLayer paints into the drawBitmapRectToRect's
// paint.
static void apply_7(SkDebugCanvas* canvas, int curCommand) {
SkSaveLayerCommand* saveLayer0 =
(SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2);
SkSaveLayerCommand* saveLayer1 =
(SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+5);
SkClipRectCommand* clip2 =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+7);
SkDrawBitmapRectCommand* dbmr =
(SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+8);
SkScalar newSrcLeft = dbmr->srcRect()->fLeft + clip2->rect().fLeft - dbmr->dstRect().fLeft;
SkScalar newSrcTop = dbmr->srcRect()->fTop + clip2->rect().fTop - dbmr->dstRect().fTop;
SkRect newSrc = SkRect::MakeXYWH(newSrcLeft, newSrcTop,
clip2->rect().width(), clip2->rect().height());
dbmr->setSrcRect(newSrc);
dbmr->setDstRect(clip2->rect());
SkColor color = 0xFF000000;
int a0, a1;
const SkPaint* saveLayerPaint0 = saveLayer0->paint();
if (NULL != saveLayerPaint0) {
color = saveLayerPaint0->getColor();
a0 = SkColorGetA(color);
} else {
a0 = 0xFF;
}
const SkPaint* saveLayerPaint1 = saveLayer1->paint();
if (NULL != saveLayerPaint1) {
color = saveLayerPaint1->getColor();
a1 = SkColorGetA(color);
} else {
a1 = 0xFF;
}
int newA = SkMulDiv255Round(a0, a1);
SkASSERT(newA <= 0xFF);
SkPaint* dbmrPaint = dbmr->paint();
if (NULL != dbmrPaint) {
SkColor newColor = SkColorSetA(dbmrPaint->getColor(), newA);
dbmrPaint->setColor(newColor);
} else {
SkColor newColor = SkColorSetA(color, newA);
SkPaint newPaint;
newPaint.setColor(newColor);
dbmr->setPaint(newPaint);
}
// remove everything except the drawbitmaprect
canvas->deleteDrawCommandAt(curCommand+13); // restore
canvas->deleteDrawCommandAt(curCommand+12); // restore
canvas->deleteDrawCommandAt(curCommand+11); // restore
canvas->deleteDrawCommandAt(curCommand+10); // restore
canvas->deleteDrawCommandAt(curCommand+9); // restore
canvas->deleteDrawCommandAt(curCommand+7); // clipRect
canvas->deleteDrawCommandAt(curCommand+6); // save
canvas->deleteDrawCommandAt(curCommand+5); // saveLayer
canvas->deleteDrawCommandAt(curCommand+4); // clipRect
canvas->deleteDrawCommandAt(curCommand+3); // save
canvas->deleteDrawCommandAt(curCommand+2); // saveLayer
canvas->deleteDrawCommandAt(curCommand+1); // clipRect
canvas->deleteDrawCommandAt(curCommand); // save
}