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

Side by Side Diff: src/pdf/SkPDFTypes.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/pdf/SkPDFTypes.h ('k') | src/pipe/SkGPipePriv.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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkDeflate.h" 9 #include "SkDeflate.h"
10 #include "SkPDFTypes.h" 10 #include "SkPDFTypes.h"
(...skipping 20 matching lines...) Expand all
31 SkSafeUnref(fObject); 31 SkSafeUnref(fObject);
32 return; 32 return;
33 default: 33 default:
34 return; 34 return;
35 } 35 }
36 } 36 }
37 37
38 SkPDFUnion& SkPDFUnion::operator=(SkPDFUnion&& other) { 38 SkPDFUnion& SkPDFUnion::operator=(SkPDFUnion&& other) {
39 if (this != &other) { 39 if (this != &other) {
40 this->~SkPDFUnion(); 40 this->~SkPDFUnion();
41 SkNEW_PLACEMENT_ARGS(this, SkPDFUnion, (other.move())); 41 new (this) SkPDFUnion(other.move());
42 } 42 }
43 return *this; 43 return *this;
44 } 44 }
45 45
46 SkPDFUnion::SkPDFUnion(SkPDFUnion&& other) { 46 SkPDFUnion::SkPDFUnion(SkPDFUnion&& other) {
47 SkASSERT(this != &other); 47 SkASSERT(this != &other);
48 memcpy(this, &other, sizeof(*this)); 48 memcpy(this, &other, sizeof(*this));
49 other.fType = Type::kDestroyed; 49 other.fType = Type::kDestroyed;
50 } 50 }
51 51
52 #if 0 52 #if 0
53 SkPDFUnion SkPDFUnion::copy() const { 53 SkPDFUnion SkPDFUnion::copy() const {
54 SkPDFUnion u(fType); 54 SkPDFUnion u(fType);
55 memcpy(&u, this, sizeof(u)); 55 memcpy(&u, this, sizeof(u));
56 switch (fType) { 56 switch (fType) {
57 case Type::kNameSkS: 57 case Type::kNameSkS:
58 case Type::kStringSkS: 58 case Type::kStringSkS:
59 SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString, 59 new (pun(u.fSkString)) SkString ( *pun(fSkString));
60 (*pun(fSkString)));
61 return u.move(); 60 return u.move();
62 case Type::kObjRef: 61 case Type::kObjRef:
63 case Type::kObject: 62 case Type::kObject:
64 SkRef(u.fObject); 63 SkRef(u.fObject);
65 return u.move(); 64 return u.move();
66 default: 65 default:
67 return u.move(); 66 return u.move();
68 } 67 }
69 } 68 }
70 SkPDFUnion& SkPDFUnion::operator=(const SkPDFUnion& other) { 69 SkPDFUnion& SkPDFUnion::operator=(const SkPDFUnion& other) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 218
220 SkPDFUnion SkPDFUnion::String(const char* value) { 219 SkPDFUnion SkPDFUnion::String(const char* value) {
221 SkPDFUnion u(Type::kString); 220 SkPDFUnion u(Type::kString);
222 SkASSERT(value); 221 SkASSERT(value);
223 u.fStaticString = value; 222 u.fStaticString = value;
224 return u.move(); 223 return u.move();
225 } 224 }
226 225
227 SkPDFUnion SkPDFUnion::Name(const SkString& s) { 226 SkPDFUnion SkPDFUnion::Name(const SkString& s) {
228 SkPDFUnion u(Type::kNameSkS); 227 SkPDFUnion u(Type::kNameSkS);
229 SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString, (s)); 228 new (pun(u.fSkString)) SkString(s);
230 return u.move(); 229 return u.move();
231 } 230 }
232 231
233 SkPDFUnion SkPDFUnion::String(const SkString& s) { 232 SkPDFUnion SkPDFUnion::String(const SkString& s) {
234 SkPDFUnion u(Type::kStringSkS); 233 SkPDFUnion u(Type::kStringSkS);
235 SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString, (s)); 234 new (pun(u.fSkString)) SkString(s);
236 return u.move(); 235 return u.move();
237 } 236 }
238 237
239 SkPDFUnion SkPDFUnion::ObjRef(SkPDFObject* ptr) { 238 SkPDFUnion SkPDFUnion::ObjRef(SkPDFObject* ptr) {
240 SkPDFUnion u(Type::kObjRef); 239 SkPDFUnion u(Type::kObjRef);
241 SkASSERT(ptr); 240 SkASSERT(ptr);
242 u.fObject = ptr; 241 u.fObject = ptr;
243 return u.move(); 242 return u.move();
244 } 243 }
245 244
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 stream->writeText("]"); 290 stream->writeText("]");
292 } 291 }
293 292
294 void SkPDFArray::addResources(SkPDFObjNumMap* catalog, 293 void SkPDFArray::addResources(SkPDFObjNumMap* catalog,
295 const SkPDFSubstituteMap& substitutes) const { 294 const SkPDFSubstituteMap& substitutes) const {
296 for (const SkPDFUnion& value : fValues) { 295 for (const SkPDFUnion& value : fValues) {
297 value.addResources(catalog, substitutes); 296 value.addResources(catalog, substitutes);
298 } 297 }
299 } 298 }
300 299
301 void SkPDFArray::append(SkPDFUnion&& value) { 300 void SkPDFArray::append(SkPDFUnion&& value) { new (fValues.append()) SkPDFUnion( value.move()); }
302 SkNEW_PLACEMENT_ARGS(fValues.append(), SkPDFUnion, (value.move()));
303 }
304 301
305 void SkPDFArray::appendInt(int32_t value) { 302 void SkPDFArray::appendInt(int32_t value) {
306 this->append(SkPDFUnion::Int(value)); 303 this->append(SkPDFUnion::Int(value));
307 } 304 }
308 305
309 void SkPDFArray::appendBool(bool value) { 306 void SkPDFArray::appendBool(bool value) {
310 this->append(SkPDFUnion::Bool(value)); 307 this->append(SkPDFUnion::Bool(value));
311 } 308 }
312 309
313 void SkPDFArray::appendScalar(SkScalar value) { 310 void SkPDFArray::appendScalar(SkScalar value) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 const SkPDFSubstituteMap& substitutes) const { 368 const SkPDFSubstituteMap& substitutes) const {
372 for (int i = 0; i < fRecords.count(); i++) { 369 for (int i = 0; i < fRecords.count(); i++) {
373 fRecords[i].fKey.addResources(catalog, substitutes); 370 fRecords[i].fKey.addResources(catalog, substitutes);
374 fRecords[i].fValue.addResources(catalog, substitutes); 371 fRecords[i].fValue.addResources(catalog, substitutes);
375 } 372 }
376 } 373 }
377 374
378 void SkPDFDict::set(SkPDFUnion&& name, SkPDFUnion&& value) { 375 void SkPDFDict::set(SkPDFUnion&& name, SkPDFUnion&& value) {
379 Record* rec = fRecords.append(); 376 Record* rec = fRecords.append();
380 SkASSERT(name.isName()); 377 SkASSERT(name.isName());
381 SkNEW_PLACEMENT_ARGS(&rec->fKey, SkPDFUnion, (name.move())); 378 new (&rec->fKey) SkPDFUnion(name.move());
382 SkNEW_PLACEMENT_ARGS(&rec->fValue, SkPDFUnion, (value.move())); 379 new (&rec->fValue) SkPDFUnion(value.move());
383 } 380 }
384 381
385 int SkPDFDict::size() const { return fRecords.count(); } 382 int SkPDFDict::size() const { return fRecords.count(); }
386 383
387 void SkPDFDict::insertObjRef(const char key[], SkPDFObject* value) { 384 void SkPDFDict::insertObjRef(const char key[], SkPDFObject* value) {
388 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value)); 385 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value));
389 } 386 }
390 void SkPDFDict::insertObjRef(const SkString& key, SkPDFObject* value) { 387 void SkPDFDict::insertObjRef(const SkString& key, SkPDFObject* value) {
391 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value)); 388 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value));
392 } 389 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 fObjects.push(obj); 499 fObjects.push(obj);
503 return true; 500 return true;
504 } 501 }
505 502
506 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const { 503 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const {
507 int32_t* objectNumberFound = fObjectNumbers.find(obj); 504 int32_t* objectNumberFound = fObjectNumbers.find(obj);
508 SkASSERT(objectNumberFound); 505 SkASSERT(objectNumberFound);
509 return *objectNumberFound; 506 return *objectNumberFound;
510 } 507 }
511 508
OLDNEW
« no previous file with comments | « src/pdf/SkPDFTypes.h ('k') | src/pipe/SkGPipePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698