| 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 "SkCachingPixelRef.h" | 8 #include "SkCachingPixelRef.h" |
| 9 #include "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
| 10 #include "SkRect.h" | 10 #include "SkRect.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 fLockedBitmap.getPixels(), fRowBytes); | 56 fLockedBitmap.getPixels(), fRowBytes); |
| 57 switch (result) { | 57 switch (result) { |
| 58 case SkImageGenerator::kIncompleteInput: | 58 case SkImageGenerator::kIncompleteInput: |
| 59 case SkImageGenerator::kSuccess: | 59 case SkImageGenerator::kSuccess: |
| 60 break; | 60 break; |
| 61 default: | 61 default: |
| 62 fErrorInDecoding = true; | 62 fErrorInDecoding = true; |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 fLockedBitmap.setImmutable(); | 65 fLockedBitmap.setImmutable(); |
| 66 SkBitmapCache::Add( | 66 SkBitmapCache::Add(this, info.bounds(), fLockedBitmap); |
| 67 this->getGenerationID(), info.bounds(), fLockedBitmap); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 // Now bitmap should contain a concrete PixelRef of the decoded image. | 69 // Now bitmap should contain a concrete PixelRef of the decoded image. |
| 71 void* pixels = fLockedBitmap.getPixels(); | 70 void* pixels = fLockedBitmap.getPixels(); |
| 72 SkASSERT(pixels != NULL); | 71 SkASSERT(pixels != NULL); |
| 73 rec->fPixels = pixels; | 72 rec->fPixels = pixels; |
| 74 rec->fColorTable = NULL; | 73 rec->fColorTable = NULL; |
| 75 rec->fRowBytes = fLockedBitmap.rowBytes(); | 74 rec->fRowBytes = fLockedBitmap.rowBytes(); |
| 76 return true; | 75 return true; |
| 77 } | 76 } |
| 78 | 77 |
| 79 void SkCachingPixelRef::onUnlockPixels() { | 78 void SkCachingPixelRef::onUnlockPixels() { |
| 80 fLockedBitmap.reset(); | 79 fLockedBitmap.reset(); |
| 81 } | 80 } |
| OLD | NEW |