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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 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/core/SkMatrixImageFilter.cpp ('k') | src/core/SkMipMap.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 2015 Google Inc. 2 * Copyright 2015 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkTLazy.h" 9 #include "SkTLazy.h"
10 #include "SkLazyPtr.h" 10 #include "SkLazyPtr.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkRect fCull; 55 SkRect fCull;
56 T fOp; 56 T fOp;
57 }; 57 };
58 58
59 59
60 SkMiniRecorder::SkMiniRecorder() : fState(State::kEmpty) {} 60 SkMiniRecorder::SkMiniRecorder() : fState(State::kEmpty) {}
61 SkMiniRecorder::~SkMiniRecorder() { 61 SkMiniRecorder::~SkMiniRecorder() {
62 if (fState != State::kEmpty) { 62 if (fState != State::kEmpty) {
63 // We have internal state pending. 63 // We have internal state pending.
64 // Detaching then deleting a picture is an easy way to clean up. 64 // Detaching then deleting a picture is an easy way to clean up.
65 SkDELETE(this->detachAsPicture(SkRect::MakeEmpty())); 65 delete this->detachAsPicture(SkRect::MakeEmpty());
66 } 66 }
67 SkASSERT(fState == State::kEmpty); 67 SkASSERT(fState == State::kEmpty);
68 } 68 }
69 69
70 #define TRY_TO_STORE(Type, ...) \ 70 #define TRY_TO_STORE(Type, ...) \
71 if (fState != State::kEmpty) { return false; } \ 71 if (fState != State::kEmpty) { return false; } \
72 fState = State::k##Type; \ 72 fState = State::k##Type; \
73 new (fBuffer.get()) Type(__VA_ARGS__); \ 73 new (fBuffer.get()) Type(__VA_ARGS__); \
74 return true 74 return true
75 75
(...skipping 19 matching lines...) Expand all
95 TRY_TO_STORE(DrawPath, paint, path); 95 TRY_TO_STORE(DrawPath, paint, path);
96 } 96 }
97 97
98 bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c onst SkPaint& p) { 98 bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c onst SkPaint& p) {
99 TRY_TO_STORE(DrawTextBlob, p, b, x, y); 99 TRY_TO_STORE(DrawTextBlob, p, b, x, y);
100 } 100 }
101 #undef TRY_TO_STORE 101 #undef TRY_TO_STORE
102 102
103 103
104 SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) { 104 SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
105 #define CASE(Type) \ 105 #define CASE(Type) \
106 case State::k##Type: \ 106 case State::k##Type: \
107 fState = State::kEmpty; \ 107 fState = State::kEmpty; \
108 return SkNEW_ARGS(SkMiniPicture<Type>, (cull, reinterpret_cast<Type*>(fB uffer.get()))) 108 return new SkMiniPicture<Type>(cull, reinterpret_cast<Type*>(fBuffer.get ()))
109 109
110 switch (fState) { 110 switch (fState) {
111 case State::kEmpty: return SkRef(gEmptyPicture.get()); 111 case State::kEmpty: return SkRef(gEmptyPicture.get());
112 CASE(DrawBitmapRectFixedSize); 112 CASE(DrawBitmapRectFixedSize);
113 CASE(DrawPath); 113 CASE(DrawPath);
114 CASE(DrawRect); 114 CASE(DrawRect);
115 CASE(DrawTextBlob); 115 CASE(DrawTextBlob);
116 } 116 }
117 SkASSERT(false); 117 SkASSERT(false);
118 return nullptr; 118 return nullptr;
(...skipping 12 matching lines...) Expand all
131 switch (fState) { 131 switch (fState) {
132 case State::kEmpty: return; 132 case State::kEmpty: return;
133 CASE(DrawBitmapRectFixedSize); 133 CASE(DrawBitmapRectFixedSize);
134 CASE(DrawPath); 134 CASE(DrawPath);
135 CASE(DrawRect); 135 CASE(DrawRect);
136 CASE(DrawTextBlob); 136 CASE(DrawTextBlob);
137 } 137 }
138 SkASSERT(false); 138 SkASSERT(false);
139 #undef CASE 139 #undef CASE
140 } 140 }
OLDNEW
« no previous file with comments | « src/core/SkMatrixImageFilter.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698