Add imagemasksubset GM

(GM for non-N32 SkImage subsetting)

BUG=skia:5687
R=bsalomon@google.com,robertphillips@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2286733002

Review-Url: https://codereview.chromium.org/2286733002
This commit is contained in:
fmalita 2016-08-26 10:13:39 -07:00 committed by Commit bot
parent 358f93de3d
commit ce2fc6a045
35 changed files with 226 additions and 1 deletions

84
gm/imagemasksubset.cpp Normal file
View File

@ -0,0 +1,84 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkCanvas.h"
#include "SkImage.h"
#include "SkImageGenerator.h"
#include "SkSurface.h"
#include "sk_tool_utils.h"
namespace {
const SkISize kSize = SkISize::Make(100, 100);
const SkIRect kSubset = SkIRect::MakeLTRB(25, 25, 75, 75);
const SkRect kDest = SkRect::MakeXYWH(10, 10, 100, 100);
sk_sp<SkImage> make_mask(const sk_sp<SkSurface>& surface) {
sk_tool_utils::draw_checkerboard(surface->getCanvas(), 0x80808080, 0x00000000, 5);
return surface->makeImageSnapshot();
}
class MaskGenerator final : public SkImageGenerator {
public:
MaskGenerator(const SkImageInfo& info) : INHERITED(info) {}
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor*,
int*) override {
if (info.colorType() == kIndex_8_SkColorType) {
return false;
}
make_mask(SkSurface::MakeRasterDirect(info, pixels, rowBytes));
return true;
}
private:
typedef SkImageGenerator INHERITED;
};
using MakerT = sk_sp<SkImage>(*)(SkCanvas*, const SkImageInfo&);
const MakerT makers[] = {
// SkImage_Raster
[](SkCanvas*, const SkImageInfo& info) -> sk_sp<SkImage> {
return make_mask(SkSurface::MakeRaster(info));
},
// SkImage_Gpu
[](SkCanvas* c, const SkImageInfo& info) -> sk_sp<SkImage> {
sk_sp<SkSurface> surface;
#if SK_SUPPORT_GPU
surface = SkSurface::MakeRenderTarget(c->getGrContext(), SkBudgeted::kNo, info);
#endif
return make_mask(surface ? surface : SkSurface::MakeRaster(info));
},
// SkImage_Generator
[](SkCanvas*, const SkImageInfo& info) -> sk_sp<SkImage> {
return SkImage::MakeFromGenerator(new MaskGenerator(info));
},
};
} // anonymous ns
// Checks whether subset SkImages preserve the original color type (A8 in this case).
DEF_SIMPLE_GM(imagemasksubset, canvas, 480, 480) {
SkPaint paint;
paint.setColor(0xff00ff00);
const SkImageInfo info = SkImageInfo::MakeA8(kSize.width(), kSize.height());
for (size_t i = 0; i < SK_ARRAY_COUNT(makers); ++i) {
sk_sp<SkImage> image = makers[i](canvas, info);
if (image) {
canvas->drawImageRect(image, SkRect::Make(kSubset), kDest, &paint);
sk_sp<SkImage> subset = image->makeSubset(kSubset);
canvas->drawImageRect(subset, kDest.makeOffset(kSize.width() * 1.5f, 0), &paint);
}
canvas->translate(0, kSize.height() * 1.5f);
}
}

View File

@ -609,6 +609,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -518,6 +518,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -611,6 +611,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -609,6 +609,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -610,6 +610,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -608,6 +608,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -609,6 +609,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -605,6 +605,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -326,6 +326,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -328,6 +328,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -320,6 +320,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -248,6 +248,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -300,6 +300,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -182,6 +182,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -299,6 +299,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -301,6 +301,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -182,6 +182,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -205,6 +205,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",
@ -642,6 +646,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",
@ -1080,6 +1088,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -331,6 +331,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -355,6 +355,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -348,6 +348,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -650,6 +650,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -604,6 +604,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -355,6 +355,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -706,6 +706,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -706,6 +706,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -706,6 +706,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -299,6 +299,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -610,6 +610,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -710,6 +710,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -710,6 +710,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -710,6 +710,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -304,6 +304,10 @@
"serialize-8888", "serialize-8888",
"gm", "gm",
"_", "_",
"imagemasksubset",
"serialize-8888",
"gm",
"_",
"bitmapfilters", "bitmapfilters",
"serialize-8888", "serialize-8888",
"gm", "gm",

View File

@ -217,7 +217,8 @@ def dm_flags(bot):
'fontmgr_bounds_1_-0.25', 'fontmgr_bounds_1_-0.25',
'fontmgr_bounds', 'fontmgr_bounds',
'fontmgr_match', 'fontmgr_match',
'fontmgr_iter'] 'fontmgr_iter',
'imagemasksubset']
# skia:5589 # skia:5589
bad_serialize_gms.extend(['bitmapfilters', bad_serialize_gms.extend(['bitmapfilters',