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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (NULL == fDiscardableMemory) { | 64 if (NULL == fDiscardableMemory) { |
65 fDiscardableMemoryIsLocked = false; | 65 fDiscardableMemoryIsLocked = false; |
66 return false; // Memory allocation failed. | 66 return false; // Memory allocation failed. |
67 } | 67 } |
68 | 68 |
69 void* pixels = fDiscardableMemory->data(); | 69 void* pixels = fDiscardableMemory->data(); |
70 const SkImageInfo& info = this->info(); | 70 const SkImageInfo& info = this->info(); |
71 SkPMColor colors[256]; | 71 SkPMColor colors[256]; |
72 int colorCount = 0; | 72 int colorCount = 0; |
73 | 73 |
74 const SkImageGenerator::Result result = fGenerator->getPixels(info, pixels,
fRowBytes, | 74 const SkImageGenerator::Result result = fGenerator->getPixels(info, pixels,
fRowBytes, NULL, |
75 colors, &color
Count); | 75 colors, &color
Count); |
76 switch (result) { | 76 switch (result) { |
77 case SkImageGenerator::kSuccess: | 77 case SkImageGenerator::kSuccess: |
78 case SkImageGenerator::kIncompleteInput: | 78 case SkImageGenerator::kIncompleteInput: |
79 break; | 79 break; |
80 default: | 80 default: |
81 fDiscardableMemory->unlock(); | 81 fDiscardableMemory->unlock(); |
82 fDiscardableMemoryIsLocked = false; | 82 fDiscardableMemoryIsLocked = false; |
83 SkDELETE(fDiscardableMemory); | 83 SkDELETE(fDiscardableMemory); |
84 fDiscardableMemory = NULL; | 84 fDiscardableMemory = NULL; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // These are the public API | 134 // These are the public API |
135 | 135 |
136 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { | 136 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { |
137 return SkInstallDiscardablePixelRef(generator, dst, NULL); | 137 return SkInstallDiscardablePixelRef(generator, dst, NULL); |
138 } | 138 } |
139 | 139 |
140 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { | 140 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { |
141 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded); | 141 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded); |
142 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals
e; | 142 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals
e; |
143 } | 143 } |
OLD | NEW |