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

Side by Side Diff: src/doc/SkDocument.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/device/xps/SkXPSDevice.cpp ('k') | src/doc/SkDocument_PDF.cpp » ('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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 10
11 SkDocument::SkDocument(SkWStream* stream, void (*doneProc)(SkWStream*, bool)) { 11 SkDocument::SkDocument(SkWStream* stream, void (*doneProc)(SkWStream*, bool)) {
12 fStream = stream; // we do not own this object. 12 fStream = stream; // we do not own this object.
13 fDoneProc = doneProc; 13 fDoneProc = doneProc;
14 fState = kBetweenPages_State; 14 fState = kBetweenPages_State;
15 } 15 }
16 16
17 SkDocument::~SkDocument() { 17 SkDocument::~SkDocument() {
18 this->close(); 18 this->close();
19 } 19 }
20 20
21 SkCanvas* SkDocument::beginPage(SkScalar width, SkScalar height, 21 SkCanvas* SkDocument::beginPage(SkScalar width, SkScalar height,
22 const SkRect* content) { 22 const SkRect* content) {
23 if (width <= 0 || height <= 0) { 23 if (width <= 0 || height <= 0) {
24 return NULL; 24 return nullptr;
25 } 25 }
26 26
27 SkRect outer = SkRect::MakeWH(width, height); 27 SkRect outer = SkRect::MakeWH(width, height);
28 SkRect inner; 28 SkRect inner;
29 if (content) { 29 if (content) {
30 inner = *content; 30 inner = *content;
31 if (!inner.intersect(outer)) { 31 if (!inner.intersect(outer)) {
32 return NULL; 32 return nullptr;
33 } 33 }
34 } else { 34 } else {
35 inner = outer; 35 inner = outer;
36 } 36 }
37 37
38 for (;;) { 38 for (;;) {
39 switch (fState) { 39 switch (fState) {
40 case kBetweenPages_State: 40 case kBetweenPages_State:
41 fState = kInPage_State; 41 fState = kInPage_State;
42 return this->onBeginPage(width, height, inner); 42 return this->onBeginPage(width, height, inner);
43 case kInPage_State: 43 case kInPage_State:
44 this->endPage(); 44 this->endPage();
45 break; 45 break;
46 case kClosed_State: 46 case kClosed_State:
47 return NULL; 47 return nullptr;
48 } 48 }
49 } 49 }
50 SkDEBUGFAIL("never get here"); 50 SkDEBUGFAIL("never get here");
51 return NULL; 51 return nullptr;
52 } 52 }
53 53
54 void SkDocument::endPage() { 54 void SkDocument::endPage() {
55 if (kInPage_State == fState) { 55 if (kInPage_State == fState) {
56 fState = kBetweenPages_State; 56 fState = kBetweenPages_State;
57 this->onEndPage(); 57 this->onEndPage();
58 } 58 }
59 } 59 }
60 60
61 bool SkDocument::close() { 61 bool SkDocument::close() {
62 for (;;) { 62 for (;;) {
63 switch (fState) { 63 switch (fState) {
64 case kBetweenPages_State: { 64 case kBetweenPages_State: {
65 fState = kClosed_State; 65 fState = kClosed_State;
66 bool success = this->onClose(fStream); 66 bool success = this->onClose(fStream);
67 67
68 if (fDoneProc) { 68 if (fDoneProc) {
69 fDoneProc(fStream, false); 69 fDoneProc(fStream, false);
70 } 70 }
71 // we don't own the stream, but we mark it NULL since we can 71 // we don't own the stream, but we mark it nullptr since we can
72 // no longer write to it. 72 // no longer write to it.
73 fStream = NULL; 73 fStream = nullptr;
74 return success; 74 return success;
75 } 75 }
76 case kInPage_State: 76 case kInPage_State:
77 this->endPage(); 77 this->endPage();
78 break; 78 break;
79 case kClosed_State: 79 case kClosed_State:
80 return false; 80 return false;
81 } 81 }
82 } 82 }
83 } 83 }
84 84
85 void SkDocument::abort() { 85 void SkDocument::abort() {
86 this->onAbort(); 86 this->onAbort();
87 87
88 fState = kClosed_State; 88 fState = kClosed_State;
89 if (fDoneProc) { 89 if (fDoneProc) {
90 fDoneProc(fStream, true); 90 fDoneProc(fStream, true);
91 } 91 }
92 // we don't own the stream, but we mark it NULL since we can 92 // we don't own the stream, but we mark it nullptr since we can
93 // no longer write to it. 93 // no longer write to it.
94 fStream = NULL; 94 fStream = nullptr;
95 } 95 }
OLDNEW
« no previous file with comments | « src/device/xps/SkXPSDevice.cpp ('k') | src/doc/SkDocument_PDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698