Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: gm/image.cpp

Issue 1364443002: remove unused (by the outside) SkImage::newSurface, and simplify newImage -> newSubset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/image_pict.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image.cpp
diff --git a/gm/image.cpp b/gm/image.cpp
index 726ab97a8f9aa5859b774cd4fd5a6584718e655c..27cce2342e24a10ffddb13b3f61c036170de7433 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -192,96 +192,3 @@ private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ImageGM; )
-
-class ImageResizeGM : public skiagm::GM {
- enum {
- W = 100,
- H = 100,
- };
-public:
- ImageResizeGM() {}
-
-protected:
- SkString onShortName() override { return SkString("image-resize"); }
-
- SkISize onISize() override { return SkISize::Make(510, 480); }
-
- void drawIntoImage(SkCanvas* canvas) {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(3);
- SkRandom rand;
- for (int i = 0; i < 60; ++i) {
- paint.setColor(rand.nextU());
- SkScalar x = rand.nextUScalar1() * W;
- SkScalar y = rand.nextUScalar1() * H;
- SkScalar r = rand.nextUScalar1() * W / 2;
- canvas->drawCircle(x, y, r, paint);
- }
- }
-
- SkImage* makeImage(SkCanvas* canvas) {
- const SkImageInfo info = SkImageInfo::MakeN32Premul(W, H);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
- if (!surface) {
- surface.reset(SkSurface::NewRaster(info));
- }
- this->drawIntoImage(surface->getCanvas());
- return surface->newImageSnapshot();
- }
-
- void drawResized(SkCanvas* canvas, SkImage* image, int newW, int newH, const SkIRect* subset,
- SkFilterQuality fq) {
- // canvas method
- SkPaint paint;
- paint.setFilterQuality(fq);
- SkRect dstR = SkRect::MakeWH(SkIntToScalar(newW), SkIntToScalar(newH));
- SkRect srcR;
- if (subset) {
- srcR.set(*subset);
- }
- canvas->legacy_drawImageRect(image, subset ? &srcR : nullptr, dstR, &paint);
- canvas->translate(newW + 20.0f, 0);
-
- // image method
- SkAutoTUnref<SkImage> image2(image->newImage(newW, newH, subset, fq));
- canvas->drawImage(image2, 0, 0, nullptr);
- canvas->translate(image2->width() + 20.0f, 0);
- }
-
- void drawImage(SkCanvas* canvas, SkImage* image, SkFilterQuality fq) {
-
- canvas->drawImage(image, 0, 0, nullptr);
- canvas->translate(image->width() + 20.0f, 0);
- this->drawResized(canvas, image, image->width()*4/10, image->height()*4/10, nullptr, fq);
-
- SkIRect subset = SkIRect::MakeLTRB(W/4, H/4, W/2, H/2);
- this->drawResized(canvas, image, W, H, &subset, fq);
- }
-
- void onDraw(SkCanvas* canvas) override {
- canvas->translate(10, 10);
-
- SkAutoTUnref<SkImage> image(this->makeImage(canvas));
-
- const SkFilterQuality fq[] = {
- kNone_SkFilterQuality,
- kLow_SkFilterQuality,
- kMedium_SkFilterQuality,
- kHigh_SkFilterQuality,
- };
- for (size_t i = 0; i < SK_ARRAY_COUNT(fq); ++i) {
- {
- SkAutoCanvasRestore acr(canvas, true);
- this->drawImage(canvas, image, fq[i]);
- }
- canvas->translate(0, image->height() + 20.0f);
- }
- }
-
-private:
- typedef skiagm::GM INHERITED;
-};
-DEF_GM( return new ImageResizeGM; )
-
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/image_pict.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698