virtual void onDraw(SkCanvas* canvas) { if (true) { SkRect r = { 0, 0, 1 << 30, 1 << 30 }; bool open = canvas->clipRect(r); SkDebugf("---- giant clip is %d\n", open); } this->drawBG(canvas); if (false) { SkPaint paint; paint.setAntiAlias(true); SkBitmap bm; bm.setConfig(SkBitmap::kA8_Config, 100, 100); bm.allocPixels(); bm.eraseColor(0); SkCanvas c(bm); c.drawCircle(50, 50, 50, paint); paint.setColor(SK_ColorBLUE); canvas->drawBitmap(bm, 0, 0, &paint); canvas->scale(SK_Scalar1/2, SK_Scalar1/2); paint.setColor(SK_ColorRED); canvas->drawBitmap(bm, 0, 0, &paint); return; } #ifdef SK_DEBUG if (true) { SkRegion a, b, c; test_union_bug_1505668(&a, &b, &c); if (false) { // draw the result of the test SkPaint paint; canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); paint.setColor(SK_ColorRED); paint_rgn(canvas, a, paint); paint.setColor(0x800000FF); paint_rgn(canvas, b, paint); paint.setColor(SK_ColorBLACK); paint.setStyle(SkPaint::kStroke_Style); // paint_rgn(canvas, c, paint); return; } } #endif static const struct { SkColor fColor; const char* fName; SkRegion::Op fOp; } gOps[] = { { SK_ColorBLACK, "Difference", SkRegion::kDifference_Op }, { SK_ColorRED, "Intersect", SkRegion::kIntersect_Op }, { 0xFF008800, "Union", SkRegion::kUnion_Op }, { SK_ColorBLUE, "XOR", SkRegion::kXOR_Op } }; SkPaint textPaint; textPaint.setAntiAlias(true); textPaint.setTextSize(SK_Scalar1*24); this->drawOrig(canvas, false); canvas->save(); canvas->translate(SkIntToScalar(200), 0); this->drawRgnOped(canvas, SkRegion::kUnion_Op, SK_ColorBLACK); canvas->restore(); canvas->translate(0, SkIntToScalar(200)); for (int op = 0; op < SK_ARRAY_COUNT(gOps); op++) { canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), SkIntToScalar(75), SkIntToScalar(50), textPaint); this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor); if (true) { canvas->save(); canvas->translate(0, SkIntToScalar(200)); this->drawPathOped(canvas, gOps[op].fOp, gOps[op].fColor); canvas->restore(); } canvas->translate(SkIntToScalar(200), 0); } }
virtual void onDrawContent(SkCanvas* canvas) { if (false) { // avoid bit rot, suppress warning test_strokerect(canvas); return; } if (false) { // avoid bit rot, suppress warning test_text(canvas); return; } #ifdef SK_DEBUG if (true) { SkRegion a, b, c; test_union_bug_1505668(&a, &b, &c); if (false) { // draw the result of the test SkPaint paint; canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); paint.setColor(SK_ColorRED); paint_rgn(canvas, a, paint); paint.setColor(0x800000FF); paint_rgn(canvas, b, paint); paint.setColor(SK_ColorBLACK); paint.setStyle(SkPaint::kStroke_Style); // paint_rgn(canvas, c, paint); return; } } #endif const SkPoint origins[] = { { 30*SK_Scalar1, 50*SK_Scalar1 }, { 150*SK_Scalar1, 50*SK_Scalar1 }, }; this->drawPredicates(canvas, origins); static const struct { SkColor fColor; const char* fName; SkRegion::Op fOp; } gOps[] = { { SK_ColorBLACK, "Difference", SkRegion::kDifference_Op }, { SK_ColorRED, "Intersect", SkRegion::kIntersect_Op }, { 0xFF008800, "Union", SkRegion::kUnion_Op }, { SK_ColorBLUE, "XOR", SkRegion::kXOR_Op } }; SkPaint textPaint; textPaint.setAntiAlias(true); textPaint.setTextSize(SK_Scalar1*24); this->drawOrig(canvas, false); canvas->save(); canvas->translate(SkIntToScalar(200), 0); this->drawRgnOped(canvas, SkRegion::kUnion_Op, SK_ColorBLACK); canvas->restore(); canvas->translate(0, SkIntToScalar(200)); for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) { canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), SkIntToScalar(75), SkIntToScalar(50), textPaint); this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor); canvas->save(); canvas->translate(0, SkIntToScalar(200)); this->drawPathOped(canvas, gOps[op].fOp, gOps[op].fColor); canvas->restore(); canvas->translate(SkIntToScalar(200), 0); } }