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

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

Issue 963853002: Flate: skia_alloc_func works on both miniz and zlib (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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 2010 The Android Open Source Project 3 * Copyright 2010 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 "SkData.h" 10 #include "SkData.h"
11 #include "SkFlate.h" 11 #include "SkFlate.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 13
14 #ifndef SK_NO_FLATE 14 #ifndef SK_NO_FLATE
15 15
16 namespace { 16 namespace {
17 17
18 #ifdef ZLIB_INCLUDE 18 #ifdef ZLIB_INCLUDE
19 #include ZLIB_INCLUDE 19 #include ZLIB_INCLUDE
20 #else 20 #else
21 #include "zlib.h" 21 #include "zlib.h"
22 #endif 22 #endif
23 23
24 // static 24 // static
25 const size_t kBufferSize = 1024; 25 const size_t kBufferSize = 1024;
26 26
27 static void* skia_alloc_func(void*, size_t items, size_t size) { 27 template <typename T> void* skia_alloc_func(void*, T items, T size) {
mtklein 2015/02/27 19:36:16 Shall we add // Different zlib implementations use
hal.canary 2015/02/27 19:40:40 Done.
28 return sk_calloc_throw(items * size); 28 return sk_calloc_throw(SkToSizeT(items) * SkToSizeT(size));
29 } 29 }
30 30
31 static void skia_free_func(void*, void* address) { sk_free(address); } 31 static void skia_free_func(void*, void* address) { sk_free(address); }
32 32
33 bool doFlate(bool compress, SkStream* src, SkWStream* dst) { 33 bool doFlate(bool compress, SkStream* src, SkWStream* dst) {
34 uint8_t inputBuffer[kBufferSize]; 34 uint8_t inputBuffer[kBufferSize];
35 uint8_t outputBuffer[kBufferSize]; 35 uint8_t outputBuffer[kBufferSize];
36 z_stream flateData; 36 z_stream flateData;
37 flateData.zalloc = &skia_alloc_func; 37 flateData.zalloc = &skia_alloc_func;
38 flateData.zfree = &skia_free_func; 38 flateData.zfree = &skia_free_func;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return true; 220 return true;
221 } 221 }
222 222
223 size_t SkDeflateWStream::bytesWritten() const { 223 size_t SkDeflateWStream::bytesWritten() const {
224 return fImpl->fZStream.total_in + fImpl->fInBufferIndex; 224 return fImpl->fZStream.total_in + fImpl->fInBufferIndex;
225 } 225 }
226 226
227 227
228 #endif // SK_NO_FLATE 228 #endif // SK_NO_FLATE
229 229
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698