| OLD | NEW |
| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDocument.h" | 10 #include "SkDocument.h" |
| 11 #include "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
| 12 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 | 15 |
| 16 #include "Test.h" | 16 #include "Test.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // SkPixelRef which fails to lock, as a lazy pixel ref might if its pixels | 20 // SkPixelRef which fails to lock, as a lazy pixel ref might if its pixels |
| 21 // cannot be generated. | 21 // cannot be generated. |
| 22 class InvalidPixelRef : public SkPixelRef { | 22 class InvalidPixelRef : public SkPixelRef { |
| 23 public: | 23 public: |
| 24 InvalidPixelRef(const SkImageInfo& info) : SkPixelRef(info) {} | 24 InvalidPixelRef(const SkImageInfo& info) : SkPixelRef(info) {} |
| 25 private: | 25 private: |
| 26 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE { return false; } | 26 bool onNewLockPixels(LockRec*) SK_OVERRIDE { return false; } |
| 27 virtual void onUnlockPixels() SK_OVERRIDE { | 27 void onUnlockPixels() SK_OVERRIDE { |
| 28 SkDEBUGFAIL("InvalidPixelRef can't be locked"); | 28 SkDEBUGFAIL("InvalidPixelRef can't be locked"); |
| 29 } | 29 } |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 SkBitmap make_invalid_bitmap(const SkImageInfo& imageInfo) { | 32 SkBitmap make_invalid_bitmap(const SkImageInfo& imageInfo) { |
| 33 SkBitmap bitmap; | 33 SkBitmap bitmap; |
| 34 bitmap.setInfo(imageInfo); | 34 bitmap.setInfo(imageInfo); |
| 35 bitmap.setPixelRef(SkNEW_ARGS(InvalidPixelRef, (imageInfo)))->unref(); | 35 bitmap.setPixelRef(SkNEW_ARGS(InvalidPixelRef, (imageInfo)))->unref(); |
| 36 return bitmap; | 36 return bitmap; |
| 37 } | 37 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 canvas->drawBitmap(SkBitmap(), 0, 0); | 51 canvas->drawBitmap(SkBitmap(), 0, 0); |
| 52 canvas->drawBitmap(make_invalid_bitmap(SkImageInfo()), 0, 0); | 52 canvas->drawBitmap(make_invalid_bitmap(SkImageInfo()), 0, 0); |
| 53 canvas->drawBitmap(make_invalid_bitmap(kN32_SkColorType), 0, 0); | 53 canvas->drawBitmap(make_invalid_bitmap(kN32_SkColorType), 0, 0); |
| 54 canvas->drawBitmap(make_invalid_bitmap(kIndex_8_SkColorType), 0, 0); | 54 canvas->drawBitmap(make_invalid_bitmap(kIndex_8_SkColorType), 0, 0); |
| 55 canvas->drawBitmap(make_invalid_bitmap(kARGB_4444_SkColorType), 0, 0); | 55 canvas->drawBitmap(make_invalid_bitmap(kARGB_4444_SkColorType), 0, 0); |
| 56 canvas->drawBitmap(make_invalid_bitmap(kRGB_565_SkColorType), 0, 0); | 56 canvas->drawBitmap(make_invalid_bitmap(kRGB_565_SkColorType), 0, 0); |
| 57 canvas->drawBitmap(make_invalid_bitmap(kAlpha_8_SkColorType), 0, 0); | 57 canvas->drawBitmap(make_invalid_bitmap(kAlpha_8_SkColorType), 0, 0); |
| 58 | 58 |
| 59 // This test passes if it does not crash. | 59 // This test passes if it does not crash. |
| 60 } | 60 } |
| OLD | NEW |