| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 9 |
| 10 #include "Resources.h" | 10 #include "Resources.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void onDraw(SkCanvas* canvas) override { | 64 void onDraw(SkCanvas* canvas) override { |
| 65 for (int j = 0; j < 4; ++j) { | 65 for (int j = 0; j < 4; ++j) { |
| 66 for (int i = 0; i < 4; ++i) { | 66 for (int i = 0; i < 4; ++i) { |
| 67 SkString filename = GetResourcePath(get_astc_filename(j*4+i)); | 67 SkString filename = GetResourcePath(get_astc_filename(j*4+i)); |
| 68 if (filename == GetResourcePath("")) { | 68 if (filename == GetResourcePath("")) { |
| 69 continue; | 69 continue; |
| 70 } | 70 } |
| 71 | 71 |
| 72 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c
_str())); | 72 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c
_str())); |
| 73 if (NULL == fileData) { | 73 if (nullptr == fileData) { |
| 74 SkDebugf("Could not open the file. Did you forget to set the
resourcePath?\n"); | 74 SkDebugf("Could not open the file. Did you forget to set the
resourcePath?\n"); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 SkBitmap bm; | 78 SkBitmap bm; |
| 79 if (!SkInstallDiscardablePixelRef(fileData, &bm)) { | 79 if (!SkInstallDiscardablePixelRef(fileData, &bm)) { |
| 80 SkDebugf("Could not install discardable pixel ref.\n"); | 80 SkDebugf("Could not install discardable pixel ref.\n"); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 | 83 |
| 84 const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension); | 84 const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension); |
| 85 const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension); | 85 const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension); |
| 86 canvas->drawBitmap(bm, bmX, bmY); | 86 canvas->drawBitmap(bm, bmX, bmY); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 static const int kGMDimension = 600; | 92 static const int kGMDimension = 600; |
| 93 static const int kBitmapDimension = kGMDimension/4; | 93 static const int kBitmapDimension = kGMDimension/4; |
| 94 | 94 |
| 95 typedef GM INHERITED; | 95 typedef GM INHERITED; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 } // namespace skiagm | 98 } // namespace skiagm |
| 99 | 99 |
| 100 ////////////////////////////////////////////////////////////////////////////// | 100 ////////////////////////////////////////////////////////////////////////////// |
| 101 | 101 |
| 102 DEF_GM(return new skiagm::ASTCBitmapGM;) | 102 DEF_GM(return new skiagm::ASTCBitmapGM;) |
| OLD | NEW |