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

Side by Side Diff: gm/bleed.cpp

Issue 2179303004: Update bleed-downscale GM to use power of 2 texture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return surface; 456 return surface;
457 } 457 }
458 458
459 // Construct an image and return the inner "src" rect. Build the image such that the interior is 459 // Construct an image and return the inner "src" rect. Build the image such that the interior is
460 // blue, with a margin of blue (2px) but then an outer margin of red. 460 // blue, with a margin of blue (2px) but then an outer margin of red.
461 // 461 //
462 // Show that kFast_SrcRectConstraint sees even the red margin (due to mipmapping ) when the image 462 // Show that kFast_SrcRectConstraint sees even the red margin (due to mipmapping ) when the image
463 // is scaled down far enough. 463 // is scaled down far enough.
464 // 464 //
465 static sk_sp<SkImage> make_image(SkCanvas* canvas, SkRect* srcR) { 465 static sk_sp<SkImage> make_image(SkCanvas* canvas, SkRect* srcR) {
466 const int N = 9 + 2 + 7 + 2 + 9; 466 // Intentially making the size a power of 2 to avoid the noise from how diff erent GPUs will
467 // produce different mipmap filtering when we have an odd sized texture.
468 const int N = 10 + 2 + 8 + 2 + 10;
467 SkImageInfo info = SkImageInfo::MakeN32Premul(N, N); 469 SkImageInfo info = SkImageInfo::MakeN32Premul(N, N);
468 auto surface = make_surface(canvas, info); 470 auto surface = make_surface(canvas, info);
469 SkCanvas* c = surface->getCanvas(); 471 SkCanvas* c = surface->getCanvas();
470 SkRect r = SkRect::MakeIWH(info.width(), info.height()); 472 SkRect r = SkRect::MakeIWH(info.width(), info.height());
471 SkPaint paint; 473 SkPaint paint;
472 474
473 paint.setColor(SK_ColorRED); 475 paint.setColor(SK_ColorRED);
474 c->drawRect(r, paint); 476 c->drawRect(r, paint);
475 r.inset(4, 4); 477 r.inset(10, 10);
476 paint.setColor(SK_ColorBLUE); 478 paint.setColor(SK_ColorBLUE);
477 c->drawRect(r, paint); 479 c->drawRect(r, paint);
478 480
479 *srcR = r.makeInset(2, 2); 481 *srcR = r.makeInset(2, 2);
480 return surface->makeImageSnapshot(); 482 return surface->makeImageSnapshot();
481 } 483 }
482 484
483 DEF_SIMPLE_GM(bleed_downscale, canvas, 360, 240) { 485 DEF_SIMPLE_GM(bleed_downscale, canvas, 360, 240) {
484 SkRect src; 486 SkRect src;
485 sk_sp<SkImage> img = make_image(canvas, &src); 487 sk_sp<SkImage> img = make_image(canvas, &src);
(...skipping 16 matching lines...) Expand all
502 // now blow up the 1 pixel result 504 // now blow up the 1 pixel result
503 canvas->drawImageRect(surf->makeImageSnapshot(), SkRect::MakeWH(100, 100), nullptr); 505 canvas->drawImageRect(surf->makeImageSnapshot(), SkRect::MakeWH(100, 100), nullptr);
504 canvas->translate(120, 0); 506 canvas->translate(120, 0);
505 } 507 }
506 canvas->restore(); 508 canvas->restore();
507 canvas->translate(0, 120); 509 canvas->translate(0, 120);
508 } 510 }
509 } 511 }
510 512
511 513
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698