Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: src/images/SkImageRef_ashmem.cpp

Issue 24269006: Add an option on SkImageDecoder to skip writing 0s. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebase, plus update the benchmark Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkScaledBitmapSampler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
127 }; 127 };
128 128
129 bool SkImageRef_ashmem::onDecode(SkImageDecoder* codec, SkStreamRewindable* stre am, 129 bool SkImageRef_ashmem::onDecode(SkImageDecoder* codec, SkStreamRewindable* stre am,
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
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 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkScaledBitmapSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698