discardable pixelrefs are gone, update tests accordingly
BUG=skia:4328
Review URL: https://codereview.chromium.org/1340803002
diff --git a/gm/astcbitmap.cpp b/gm/astcbitmap.cpp
index d3191e25..211e8da 100644
--- a/gm/astcbitmap.cpp
+++ b/gm/astcbitmap.cpp
@@ -38,7 +38,6 @@
if (idx < 0 || kNumASTCFilenames <= idx) {
return "";
}
-
return kASTCFilenames[idx];
}
@@ -48,28 +47,27 @@
} // namespace
DEF_SIMPLE_GM(astcbitmap, canvas, kGMDimension, kGMDimension) {
- for (int j = 0; j < 4; ++j) {
- for (int i = 0; i < 4; ++i) {
- SkString filename = GetResourcePath(get_astc_filename(j*4+i));
- if (filename == GetResourcePath("")) {
- continue;
- }
-
- SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
- if (nullptr == fileData) {
- SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n");
- return;
- }
-
- SkBitmap bm;
- if (!SkInstallDiscardablePixelRef(fileData, &bm)) {
- SkDebugf("Could not install discardable pixel ref.\n");
- return;
- }
-
+ for (int j = 0; j < 4; ++j) {
+ for (int i = 0; i < 4; ++i) {
+ SkBitmap bm;
+ if (GetResourceAsBitmap(get_astc_filename(j*4+i), &bm)) {
const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension);
const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension);
canvas->drawBitmap(bm, bmX, bmY);
}
}
+ }
+}
+
+DEF_SIMPLE_GM(astc_image, canvas, kGMDimension, kGMDimension) {
+ for (int j = 0; j < 4; ++j) {
+ for (int i = 0; i < 4; ++i) {
+ SkAutoTUnref<SkImage> image(GetResourceAsImage(get_astc_filename(j*4+i)));
+ if (image) {
+ const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension);
+ const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension);
+ canvas->drawImage(image, bmX, bmY);
+ }
+ }
+ }
}
diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp
index 11a700e..bbe7561 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -103,12 +103,8 @@
return;
}
- if (!SkInstallDiscardablePixelRef(fileData, &bm)) {
- SkDebugf("Could not install discardable pixel ref.\n");
- return;
- }
-
- canvas->drawBitmap(bm, 0, 0);
+ SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(fileData));
+ canvas->drawImage(image, 0, 0);
}
private:
@@ -202,12 +198,8 @@
size_t dataSz = etc1_get_encoded_data_size(width, height) + ETC_PKM_HEADER_SIZE;
SkAutoDataUnref nonPOTData(SkData::NewWithCopy(am.get(), dataSz));
- if (!SkInstallDiscardablePixelRef(nonPOTData, &bm)) {
- SkDebugf("Could not install discardable pixel ref.\n");
- return;
- }
-
- canvas->drawBitmap(bm, 0, 0);
+ SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(nonPOTData));
+ canvas->drawImage(image, 0, 0);
}
private:
diff --git a/gm/pictureimagegenerator.cpp b/gm/pictureimagegenerator.cpp
index 9149ec1..829006d 100644
--- a/gm/pictureimagegenerator.cpp
+++ b/gm/pictureimagegenerator.cpp
@@ -160,7 +160,7 @@
SkImageGenerator::NewFromPicture(configs[i].size, fPicture.get(), &m,
p.getAlpha() != 255 ? &p : nullptr));
SkBitmap bm;
- SkAssertResult(SkInstallDiscardablePixelRef(gen.detach(), &bm));
+ gen->generateBitmap(&bm);
const SkScalar x = kDrawSize * (i % kDrawsPerRow);
const SkScalar y = kDrawSize * (i / kDrawsPerRow);