本文整理汇总了C++中SkDrawBitmapRectCommand::dstRect方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDrawBitmapRectCommand::dstRect方法的具体用法?C++ SkDrawBitmapRectCommand::dstRect怎么用?C++ SkDrawBitmapRectCommand::dstRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDrawBitmapRectCommand
的用法示例。
在下文中一共展示了SkDrawBitmapRectCommand::dstRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Check for:
// SAVE
// CLIP_RECT
// DRAW_BITMAP_RECT_TO_RECT
// RESTORE
// where the rect and drawBitmapRect dst exactly match
static bool check_4(SkDebugCanvas* canvas, int curCommand) {
if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
SkClipRectCommand* cr =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
SkDrawBitmapRectCommand* dbmr =
(SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
if (SkRegion::kIntersect_Op != cr->op()) {
return false;
}
return dbmr->dstRect() == cr->rect();
}
示例2:
// Check for:
// SAVE
// CLIP_RECT
// DRAW_BITMAP_RECT_TO_RECT
// RESTORE
// where the rect and drawBitmapRect dst exactly match
static bool check_4(SkDebugCanvas* canvas, int curCommand) {
if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
SkClipRectCommand* cr =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
SkDrawBitmapRectCommand* dbmr =
(SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
if (SkRegion::kIntersect_Op != cr->op()) {
return false;
}
return dbmr->dstRect() == cr->rect();
}
示例3: 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
}
示例4:
// Check for:
// SAVE
// CLIP_RECT
// SAVE_LAYER
// SAVE
// CLIP_RECT
// SAVE_LAYER
// SAVE
// CLIP_RECT
// DRAWBITMAPRECTTORECT
// RESTORE
// RESTORE
// RESTORE
// RESTORE
// RESTORE
// where:
// all the clipRect's are BW, nested, intersections
// the drawBitmapRectToRect is a 1-1 copy from src to dest
// the last (smallest) clip rect is a subset of the drawBitmapRectToRect's dest rect
// all the saveLayer's paints can be rolled into the drawBitmapRectToRect's paint
// This pattern is used by Google spreadsheet when drawing the toolbar buttons
static bool check_7(SkDebugCanvas* canvas, int curCommand) {
if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+13 ||
CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
SAVE_LAYER != canvas->getDrawCommandAt(curCommand+2)->getType() ||
SAVE != canvas->getDrawCommandAt(curCommand+3)->getType() ||
CLIP_RECT != canvas->getDrawCommandAt(curCommand+4)->getType() ||
SAVE_LAYER != canvas->getDrawCommandAt(curCommand+5)->getType() ||
SAVE != canvas->getDrawCommandAt(curCommand+6)->getType() ||
CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() ||
DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() ||
RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) {
return false;
}
SkClipRectCommand* clip0 =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
SkSaveLayerCommand* saveLayer0 =
(SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2);
SkClipRectCommand* clip1 =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+4);
SkSaveLayerCommand* saveLayer1 =
(SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+5);
SkClipRectCommand* clip2 =
(SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+7);
SkDrawBitmapRectCommand* dbmr =
(SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+8);
if (clip0->doAA() || clip1->doAA() || clip2->doAA()) {
return false;
}
if (SkRegion::kIntersect_Op != clip0->op() ||
SkRegion::kIntersect_Op != clip1->op() ||
SkRegion::kIntersect_Op != clip2->op()) {
return false;
}
if (!clip0->rect().contains(clip1->rect()) ||
!clip1->rect().contains(clip2->rect())) {
return false;
}
// The src->dest mapping needs to be 1-to-1
if (NULL == dbmr->srcRect()) {
if (dbmr->bitmap().width() != dbmr->dstRect().width() ||
dbmr->bitmap().height() != dbmr->dstRect().height()) {
return false;
}
} else {
if (dbmr->srcRect()->width() != dbmr->dstRect().width() ||
dbmr->srcRect()->height() != dbmr->dstRect().height()) {
return false;
}
}
if (!dbmr->dstRect().contains(clip2->rect())) {
return false;
}
const SkPaint* saveLayerPaint0 = saveLayer0->paint();
const SkPaint* saveLayerPaint1 = saveLayer1->paint();
if ((NULL != saveLayerPaint0 && !is_simple(*saveLayerPaint0)) ||
(NULL != saveLayerPaint1 && !is_simple(*saveLayerPaint1))) {
return false;
}
SkPaint* dbmrPaint = dbmr->paint();
if (NULL == dbmrPaint) {
return true;
}
if (NULL != saveLayerPaint0) {
//.........这里部分代码省略.........