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

Unified Diff: gm/astcbitmap.cpp

Issue 1340803002: discardable pixelrefs are gone, update tests accordingly (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 | « bench/ETCBitmapBench.cpp ('k') | gm/etc1bitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/astcbitmap.cpp
diff --git a/gm/astcbitmap.cpp b/gm/astcbitmap.cpp
index d3191e25cca5f331b6b4fbc7d14053c4fb8f8dc2..211e8daff06e636925fd118e46f30b21d55d0c20 100644
--- a/gm/astcbitmap.cpp
+++ b/gm/astcbitmap.cpp
@@ -38,7 +38,6 @@ static inline const char *get_astc_filename(int idx) {
if (idx < 0 || kNumASTCFilenames <= idx) {
return "";
}
-
return kASTCFilenames[idx];
}
@@ -48,28 +47,27 @@ const int kBitmapDimension = kGMDimension / 4;
} // 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);
+ }
+ }
+ }
}
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | gm/etc1bitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698