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

Side by Side Diff: src/utils/SkDataUtils.cpp

Issue 274463004: Revert of extract some common code from PictureRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « src/utils/SkDataUtils.h ('k') | tools/PictureRenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkData.h"
9 #include "SkDataUtils.h"
10 #include "SkStream.h"
11
12 /*static*/ SkData* SkDataUtils::ReadIntoSkData(SkStream &stream, size_t maxBytes ) {
13 if (0 == maxBytes) {
14 return SkData::NewEmpty();
15 }
16 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes));
17 char* bufPtr = bufStart;
18 size_t bytesRemaining = maxBytes;
19 while (bytesRemaining > 0) {
20 size_t bytesReadThisTime = stream.read(bufPtr, bytesRemaining);
21 if (0 == bytesReadThisTime) {
22 break;
23 }
24 bytesRemaining -= bytesReadThisTime;
25 bufPtr += bytesReadThisTime;
26 }
27 return SkData::NewFromMalloc(bufStart, maxBytes - bytesRemaining);
28 }
OLDNEW
« no previous file with comments | « src/utils/SkDataUtils.h ('k') | tools/PictureRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698