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

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

Issue 187653003: Add size_t bytesWritten() const to SkWStream. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add and use SkToSizeT 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
« no previous file with comments | « src/core/SkDebug.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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 this->reset(); 799 this->reset();
800 return stream; 800 return stream;
801 } 801 }
802 802
803 /////////////////////////////////////////////////////////////////////////////// 803 ///////////////////////////////////////////////////////////////////////////////
804 804
805 void SkDebugWStream::newline() 805 void SkDebugWStream::newline()
806 { 806 {
807 #if defined(SK_DEBUG) || defined(SK_DEVELOPER) 807 #if defined(SK_DEBUG) || defined(SK_DEVELOPER)
808 SkDebugf("\n"); 808 SkDebugf("\n");
809 fBytesWritten++;
809 #endif 810 #endif
810 } 811 }
811 812
812 bool SkDebugWStream::write(const void* buffer, size_t size) 813 bool SkDebugWStream::write(const void* buffer, size_t size)
813 { 814 {
814 #if defined(SK_DEBUG) || defined(SK_DEVELOPER) 815 #if defined(SK_DEBUG) || defined(SK_DEVELOPER)
815 char* s = new char[size+1]; 816 char* s = new char[size+1];
816 memcpy(s, buffer, size); 817 memcpy(s, buffer, size);
817 s[size] = 0; 818 s[size] = 0;
818 SkDebugf("%s", s); 819 SkDebugf("%s", s);
819 delete[] s; 820 delete[] s;
821 fBytesWritten += size+1;
820 #endif 822 #endif
hal.canary 2014/03/06 18:23:45 are you sure this isn't just size? printf doesn't
mtklein 2014/03/06 18:28:11 Oh, good catch. This should be += size. It seems
821 return true; 823 return true;
822 } 824 }
823 825
824 /////////////////////////////////////////////////////////////////////////////// 826 ///////////////////////////////////////////////////////////////////////////////
825 /////////////////////////////////////////////////////////////////////////////// 827 ///////////////////////////////////////////////////////////////////////////////
826 828
827 829
828 static SkData* mmap_filename(const char path[]) { 830 static SkData* mmap_filename(const char path[]) {
829 SkFILE* file = sk_fopen(path, kRead_SkFILE_Flag); 831 SkFILE* file = sk_fopen(path, kRead_SkFILE_Flag);
830 if (NULL == file) { 832 if (NULL == file) {
(...skipping 13 matching lines...) Expand all
844 846
845 // If we get here, then our attempt at using mmap failed, so try normal 847 // If we get here, then our attempt at using mmap failed, so try normal
846 // file access. 848 // file access.
847 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); 849 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
848 if (!stream->isValid()) { 850 if (!stream->isValid()) {
849 stream->unref(); 851 stream->unref();
850 stream = NULL; 852 stream = NULL;
851 } 853 }
852 return stream; 854 return stream;
853 } 855 }
OLDNEW
« no previous file with comments | « src/core/SkDebug.cpp ('k') | src/utils/SkMD5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698