| OLD | NEW |
| 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" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Hide all zlib impl details. | 60 // Hide all zlib impl details. |
| 61 struct SkDeflateWStream::Impl { | 61 struct SkDeflateWStream::Impl { |
| 62 SkWStream* fOut; | 62 SkWStream* fOut; |
| 63 unsigned char fInBuffer[SKDEFLATEWSTREAM_INPUT_BUFFER_SIZE]; | 63 unsigned char fInBuffer[SKDEFLATEWSTREAM_INPUT_BUFFER_SIZE]; |
| 64 size_t fInBufferIndex; | 64 size_t fInBufferIndex; |
| 65 z_stream fZStream; | 65 z_stream fZStream; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 SkDeflateWStream::SkDeflateWStream(SkWStream* out) | 68 SkDeflateWStream::SkDeflateWStream(SkWStream* out) : fImpl(new SkDeflateWStream:
:Impl) { |
| 69 : fImpl(SkNEW(SkDeflateWStream::Impl)) { | |
| 70 fImpl->fOut = out; | 69 fImpl->fOut = out; |
| 71 fImpl->fInBufferIndex = 0; | 70 fImpl->fInBufferIndex = 0; |
| 72 if (!fImpl->fOut) { | 71 if (!fImpl->fOut) { |
| 73 return; | 72 return; |
| 74 } | 73 } |
| 75 fImpl->fZStream.zalloc = &skia_alloc_func; | 74 fImpl->fZStream.zalloc = &skia_alloc_func; |
| 76 fImpl->fZStream.zfree = &skia_free_func; | 75 fImpl->fZStream.zfree = &skia_free_func; |
| 77 fImpl->fZStream.opaque = NULL; | 76 fImpl->fZStream.opaque = NULL; |
| 78 SkDEBUGCODE(int r =) deflateInit(&fImpl->fZStream, Z_DEFAULT_COMPRESSION); | 77 SkDEBUGCODE(int r =) deflateInit(&fImpl->fZStream, Z_DEFAULT_COMPRESSION); |
| 79 SkASSERT(Z_OK == r); | 78 SkASSERT(Z_OK == r); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 fImpl->fInBuffer, fImpl->fInBufferIndex); | 110 fImpl->fInBuffer, fImpl->fInBufferIndex); |
| 112 fImpl->fInBufferIndex = 0; | 111 fImpl->fInBufferIndex = 0; |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 return true; | 114 return true; |
| 116 } | 115 } |
| 117 | 116 |
| 118 size_t SkDeflateWStream::bytesWritten() const { | 117 size_t SkDeflateWStream::bytesWritten() const { |
| 119 return fImpl->fZStream.total_in + fImpl->fInBufferIndex; | 118 return fImpl->fZStream.total_in + fImpl->fInBufferIndex; |
| 120 } | 119 } |
| OLD | NEW |