| 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 "SkDiscardablePixelRef.h" | 8 #include "SkDiscardablePixelRef.h" |
| 9 #include "SkDiscardableMemory.h" | 9 #include "SkDiscardableMemory.h" |
| 10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 if (NULL == fDiscardableMemory) { | 57 if (NULL == fDiscardableMemory) { |
| 58 return false; // Memory allocation failed. | 58 return false; // Memory allocation failed. |
| 59 } | 59 } |
| 60 | 60 |
| 61 void* pixels = fDiscardableMemory->data(); | 61 void* pixels = fDiscardableMemory->data(); |
| 62 if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) { | 62 if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) { |
| 63 fDiscardableMemory->unlock(); | 63 fDiscardableMemory->unlock(); |
| 64 SkDELETE(fDiscardableMemory); | 64 SkDELETE(fDiscardableMemory); |
| 65 fDiscardableMemory = NULL; | 65 fDiscardableMemory = NULL; |
| 66 return NULL; | 66 return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 rec->fPixels = pixels; | 69 rec->fPixels = pixels; |
| 70 rec->fColorTable = NULL; | 70 rec->fColorTable = NULL; |
| 71 rec->fRowBytes = fRowBytes; | 71 rec->fRowBytes = fRowBytes; |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SkDiscardablePixelRef::onUnlockPixels() { | 75 void SkDiscardablePixelRef::onUnlockPixels() { |
| 76 fDiscardableMemory->unlock(); | 76 fDiscardableMemory->unlock(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 92 SkDELETE(generator); // Do not need this anymore. | 92 SkDELETE(generator); // Do not need this anymore. |
| 93 return dst->allocPixels(NULL, NULL); | 93 return dst->allocPixels(NULL, NULL); |
| 94 } | 94 } |
| 95 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, | 95 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, |
| 96 (generator, info, | 96 (generator, info, |
| 97 dst->rowBytes(), | 97 dst->rowBytes(), |
| 98 factory))); | 98 factory))); |
| 99 dst->setPixelRef(ref); | 99 dst->setPixelRef(ref); |
| 100 return true; | 100 return true; |
| 101 } | 101 } |
| OLD | NEW |