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

Side by Side Diff: src/core/SkStream.cpp

Issue 182733008: Switch the factory chunk in the skps to storing its size in bytes (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added comment Created 6 years, 9 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/core/SkPicturePlayback.cpp ('k') | src/utils/SkMD5.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 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 8
9 9
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 bool SkWStream::write32(uint32_t value) { 135 bool SkWStream::write32(uint32_t value) {
136 return this->write(&value, 4); 136 return this->write(&value, 4);
137 } 137 }
138 138
139 bool SkWStream::writeScalar(SkScalar value) { 139 bool SkWStream::writeScalar(SkScalar value) {
140 return this->write(&value, sizeof(value)); 140 return this->write(&value, sizeof(value));
141 } 141 }
142 142
143 int SkWStream::SizeOfPackedUInt(size_t value) {
144 if (value <= SK_MAX_BYTE_FOR_U8) {
145 return 1;
146 } else if (value <= 0xFFFF) {
147 return 3;
148 }
149 return 5;
150 }
151
143 bool SkWStream::writePackedUInt(size_t value) { 152 bool SkWStream::writePackedUInt(size_t value) {
144 uint8_t data[5]; 153 uint8_t data[5];
145 size_t len = 1; 154 size_t len = 1;
146 if (value <= SK_MAX_BYTE_FOR_U8) { 155 if (value <= SK_MAX_BYTE_FOR_U8) {
147 data[0] = value; 156 data[0] = value;
148 len = 1; 157 len = 1;
149 } else if (value <= 0xFFFF) { 158 } else if (value <= 0xFFFF) {
150 uint16_t value16 = value; 159 uint16_t value16 = value;
151 data[0] = SK_BYTE_SENTINEL_FOR_U16; 160 data[0] = SK_BYTE_SENTINEL_FOR_U16;
152 memcpy(&data[1], &value16, 2); 161 memcpy(&data[1], &value16, 2);
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 844
836 // If we get here, then our attempt at using mmap failed, so try normal 845 // If we get here, then our attempt at using mmap failed, so try normal
837 // file access. 846 // file access.
838 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); 847 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
839 if (!stream->isValid()) { 848 if (!stream->isValid()) {
840 stream->unref(); 849 stream->unref();
841 stream = NULL; 850 stream = NULL;
842 } 851 }
843 return stream; 852 return stream;
844 } 853 }
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/utils/SkMD5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698