void onDraw(SkCanvas* canvas) override { if (NULL == fBitmap.pixelRef()) { fImage.reset(make_image(canvas, &fCenter)); image_to_bitmap(fImage, &fBitmap); } // amount of bm that should not be stretched (unless we have to) const SkScalar fixed = SkIntToScalar(fBitmap.width() - fCenter.width()); const SkTSize<SkScalar> size[] = { { fixed * 4 / 5, fixed * 4 / 5 }, // shrink in both axes { fixed * 4 / 5, fixed * 4 }, // shrink in X { fixed * 4, fixed * 4 / 5 }, // shrink in Y { fixed * 4, fixed * 4 } }; canvas->drawBitmap(fBitmap, 10, 10, NULL); SkScalar x = SkIntToScalar(100); SkScalar y = SkIntToScalar(100); SkPaint paint; paint.setFilterQuality(kLow_SkFilterQuality); for (int iy = 0; iy < 2; ++iy) { for (int ix = 0; ix < 2; ++ix) { int i = ix * 2 + iy; SkRect r = SkRect::MakeXYWH(x + ix * fixed, y + iy * fixed, size[i].width(), size[i].height()); canvas->drawBitmapNine(fBitmap, fCenter, r, &paint); canvas->drawImageNine(fImage, fCenter, r.makeOffset(360, 0), &paint); } } }
bool GrClipStackClip::quickContains(const SkRect& rect) const { if (!fStack) { return true; } return fStack->quickContains(rect.makeOffset(SkIntToScalar(fOrigin.x()), SkIntToScalar(fOrigin.y()))); }
void onDraw(int loops, SkCanvas* canvas) override { SkRect rect = SkRect::MakeWH(fDstRectSize, fDstRectSize); SkPaint paint; paint.setAlpha(0x40); paint.setFilterQuality(kLow_SkFilterQuality); paint.setAntiAlias(fAA); for (int i = 0; i < loops; i++) { for (int j = 0; j < kNumImages; ++j) { SkVector translate = this->translation(i * kNumImages + j); canvas->drawImageRect(fImages[j].get(), rect.makeOffset(translate.fX, translate.fY), &paint); } // Prevent any batching except without multitexturing since we're trying to measure // drawing distinct images and just repeating images here to increase the workload for // timing reasons. canvas->flush(); } }
void onDrawContent(SkCanvas* canvas) override { const SkRect oval = fOval.makeOffset(fCenter.fX - fOval.centerX(), fCenter.fY - fOval.centerY()); SkPaint p; p.setAntiAlias(true); p.setStyle(SkPaint::kStroke_Style); canvas->drawOval(oval, p); const SkRect r = SkRect::MakeLTRB(200, 200, 300, 300); canvas->clipRect(r); p.setStyle(SkPaint::kFill_Style); p.setColor(SK_ColorRED); canvas->drawRect(r, p); p.setColor(0x800000FF); canvas->drawOval(oval, p); }