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

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

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkImageRef_ashmem.h" 8 #include "SkImageRef_ashmem.h"
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h"
11 #include "SkThread.h" 12 #include "SkThread.h"
12 13
13 #include "android/ashmem.h" 14 #include "android/ashmem.h"
14 15
15 #include <sys/mman.h> 16 #include <sys/mman.h>
16 #include <unistd.h> 17 #include <unistd.h>
17 18
18 //#define TRACE_ASH_PURGE // just trace purges 19 //#define TRACE_ASH_PURGE // just trace purges
19 20
20 #ifdef DUMP_IMAGEREF_LIFECYCLE 21 #ifdef DUMP_IMAGEREF_LIFECYCLE
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 ashmem_unpin_region(fRec.fFD, 0, 0); 205 ashmem_unpin_region(fRec.fFD, 0, 0);
205 fRec.fPinned = false; 206 fRec.fPinned = false;
206 } 207 }
207 208
208 // we clear this with or without an error, since we've either closed or 209 // we clear this with or without an error, since we've either closed or
209 // unpinned the region 210 // unpinned the region
210 fBitmap.setPixels(NULL, NULL); 211 fBitmap.setPixels(NULL, NULL);
211 } 212 }
212 213
213 void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) const { 214 void SkImageRef_ashmem::flatten(SkWriteBuffer& buffer) const {
214 this->INHERITED::flatten(buffer); 215 this->INHERITED::flatten(buffer);
215 buffer.writeString(getURI()); 216 buffer.writeString(getURI());
216 } 217 }
217 218
218 SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer) 219 SkImageRef_ashmem::SkImageRef_ashmem(SkReadBuffer& buffer)
219 : INHERITED(buffer) { 220 : INHERITED(buffer) {
220 fRec.fFD = -1; 221 fRec.fFD = -1;
221 fRec.fAddr = NULL; 222 fRec.fAddr = NULL;
222 fRec.fSize = 0; 223 fRec.fSize = 0;
223 fRec.fPinned = false; 224 fRec.fPinned = false;
224 fCT = NULL; 225 fCT = NULL;
225 226
226 SkString uri; 227 SkString uri;
227 buffer.readString(&uri); 228 buffer.readString(&uri);
228 this->setURI(uri); 229 this->setURI(uri);
229 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698