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

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

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. 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/SkImageRef_ashmem.h ('k') | src/images/SkMovie.cpp » ('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 13 matching lines...) Expand all
24 #endif 24 #endif
25 25
26 // ashmem likes lengths on page boundaries 26 // ashmem likes lengths on page boundaries
27 static size_t roundToPageSize(size_t size) { 27 static size_t roundToPageSize(size_t size) {
28 const size_t mask = getpagesize() - 1; 28 const size_t mask = getpagesize() - 1;
29 size_t newsize = (size + mask) & ~mask; 29 size_t newsize = (size + mask) & ~mask;
30 // SkDebugf("---- oldsize %d newsize %d\n", size, newsize); 30 // SkDebugf("---- oldsize %d newsize %d\n", size, newsize);
31 return newsize; 31 return newsize;
32 } 32 }
33 33
34 SkImageRef_ashmem::SkImageRef_ashmem(SkStream* stream, 34 SkImageRef_ashmem::SkImageRef_ashmem(SkStreamRewindable* stream,
35 SkBitmap::Config config, 35 SkBitmap::Config config,
36 int sampleSize) 36 int sampleSize)
37 : SkImageRef(stream, config, sampleSize) { 37 : SkImageRef(stream, config, sampleSize) {
38 38
39 fRec.fFD = -1; 39 fRec.fFD = -1;
40 fRec.fAddr = NULL; 40 fRec.fAddr = NULL;
41 fRec.fSize = 0; 41 fRec.fSize = 0;
42 fRec.fPinned = false; 42 fRec.fPinned = false;
43 43
44 fCT = NULL; 44 fCT = NULL;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 fRec->fPinned = true; 119 fRec->fPinned = true;
120 return true; 120 return true;
121 } 121 }
122 122
123 private: 123 private:
124 // we just point to our caller's memory, these are not copies 124 // we just point to our caller's memory, these are not copies
125 SkAshmemRec* fRec; 125 SkAshmemRec* fRec;
126 const char* fName; 126 const char* fName;
127 }; 127 };
128 128
129 bool SkImageRef_ashmem::onDecode(SkImageDecoder* codec, SkStream* stream, 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 AshmemAllocator alloc(&fRec, this->getURI()); 137 AshmemAllocator alloc(&fRec, this->getURI());
138 138
139 codec->setAllocator(&alloc); 139 codec->setAllocator(&alloc);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 fRec.fFD = -1; 221 fRec.fFD = -1;
222 fRec.fAddr = NULL; 222 fRec.fAddr = NULL;
223 fRec.fSize = 0; 223 fRec.fSize = 0;
224 fRec.fPinned = false; 224 fRec.fPinned = false;
225 fCT = NULL; 225 fCT = NULL;
226 226
227 SkString uri; 227 SkString uri;
228 buffer.readString(&uri); 228 buffer.readString(&uri);
229 this->setURI(uri); 229 this->setURI(uri);
230 } 230 }
OLDNEW
« no previous file with comments | « src/images/SkImageRef_ashmem.h ('k') | src/images/SkMovie.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698