| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkImageRef_ashmem.h" | 8 #include "SkImageRef_ashmem.h" |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 bool SkImageRef_ashmem::onDecode(SkImageDecoder* codec, SkStream* stream, | 129 bool SkImageRef_ashmem::onDecode(SkImageDecoder* codec, SkStream* stream, |
| 130 SkBitmap* bitmap, SkBitmap::Config config, | 130 SkBitmap* bitmap, SkBitmap::Config config, |
| 131 SkImageDecoder::Mode mode) { | 131 SkImageDecoder::Mode mode) { |
| 132 | 132 |
| 133 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 133 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
| 134 return this->INHERITED::onDecode(codec, stream, bitmap, config, mode); | 134 return this->INHERITED::onDecode(codec, stream, bitmap, config, mode); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Ashmem memory is guaranteed to be initialized to 0. |
| 138 codec->setSkipWritingZeroes(true); |
| 139 |
| 137 AshmemAllocator alloc(&fRec, this->getURI()); | 140 AshmemAllocator alloc(&fRec, this->getURI()); |
| 138 | 141 |
| 139 codec->setAllocator(&alloc); | 142 codec->setAllocator(&alloc); |
| 140 bool success = this->INHERITED::onDecode(codec, stream, bitmap, config, | 143 bool success = this->INHERITED::onDecode(codec, stream, bitmap, config, |
| 141 mode); | 144 mode); |
| 142 // remove the allocator, since its on the stack | 145 // remove the allocator, since its on the stack |
| 143 codec->setAllocator(NULL); | 146 codec->setAllocator(NULL); |
| 144 | 147 |
| 145 if (success) { | 148 if (success) { |
| 146 // remember the colortable (if any) | 149 // remember the colortable (if any) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 fRec.fFD = -1; | 224 fRec.fFD = -1; |
| 222 fRec.fAddr = NULL; | 225 fRec.fAddr = NULL; |
| 223 fRec.fSize = 0; | 226 fRec.fSize = 0; |
| 224 fRec.fPinned = false; | 227 fRec.fPinned = false; |
| 225 fCT = NULL; | 228 fCT = NULL; |
| 226 | 229 |
| 227 SkString uri; | 230 SkString uri; |
| 228 buffer.readString(&uri); | 231 buffer.readString(&uri); |
| 229 this->setURI(uri); | 232 this->setURI(uri); |
| 230 } | 233 } |
| OLD | NEW |