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

Side by Side Diff: src/pipe/SkGPipeRead.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/pipe/SkGPipePriv.h ('k') | src/pipe/SkGPipeWrite.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 /* 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 9
10 #include "SkBitmapHeap.h" 10 #include "SkBitmapHeap.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void setReader(SkReadBuffer* reader) { 111 void setReader(SkReadBuffer* reader) {
112 fReader = reader; 112 fReader = reader;
113 this->updateReader(); 113 this->updateReader();
114 } 114 }
115 115
116 const SkPaint& paint() const { return fPaint; } 116 const SkPaint& paint() const { return fPaint; }
117 SkPaint* editPaint() { return &fPaint; } 117 SkPaint* editPaint() { return &fPaint; }
118 118
119 SkFlattenable* getFlat(unsigned index) const { 119 SkFlattenable* getFlat(unsigned index) const {
120 if (0 == index) { 120 if (0 == index) {
121 return NULL; 121 return nullptr;
122 } 122 }
123 return fFlatArray[index - 1]; 123 return fFlatArray[index - 1];
124 } 124 }
125 125
126 void defFlattenable(PaintFlats pf, int index) { 126 void defFlattenable(PaintFlats pf, int index) {
127 index--; 127 index--;
128 SkFlattenable* obj = fReader->readFlattenable(paintflat_to_flattype(pf)) ; 128 SkFlattenable* obj = fReader->readFlattenable(paintflat_to_flattype(pf)) ;
129 if (fFlatArray.count() == index) { 129 if (fFlatArray.count() == index) {
130 *fFlatArray.append() = obj; 130 *fFlatArray.append() = obj;
131 } else { 131 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 SkASSERT(shouldFlattenBitmaps(fFlags)); 167 SkASSERT(shouldFlattenBitmaps(fFlags));
168 return fBitmaps[index]; 168 return fBitmaps[index];
169 } 169 }
170 170
171 /** 171 /**
172 * Needed to be a non-abstract subclass of SkBitmapHeapReader. 172 * Needed to be a non-abstract subclass of SkBitmapHeapReader.
173 */ 173 */
174 void releaseRef(int32_t) override {} 174 void releaseRef(int32_t) override {}
175 175
176 void setSharedHeap(SkBitmapHeap* heap) { 176 void setSharedHeap(SkBitmapHeap* heap) {
177 SkASSERT(!shouldFlattenBitmaps(fFlags) || NULL == heap); 177 SkASSERT(!shouldFlattenBitmaps(fFlags) || nullptr == heap);
178 SkRefCnt_SafeAssign(fSharedHeap, heap); 178 SkRefCnt_SafeAssign(fSharedHeap, heap);
179 this->updateReader(); 179 this->updateReader();
180 } 180 }
181 181
182 void setImageHeap(SkImageHeap* heap) { 182 void setImageHeap(SkImageHeap* heap) {
183 fImageHeap.reset(SkRef(heap)); 183 fImageHeap.reset(SkRef(heap));
184 } 184 }
185 185
186 /** 186 /**
187 * Access the shared heap. Only used in the case when bitmaps are not 187 * Access the shared heap. Only used in the case when bitmaps are not
188 * flattened. 188 * flattened.
189 */ 189 */
190 SkBitmapHeap* getSharedHeap() const { 190 SkBitmapHeap* getSharedHeap() const {
191 SkASSERT(!shouldFlattenBitmaps(fFlags)); 191 SkASSERT(!shouldFlattenBitmaps(fFlags));
192 return fSharedHeap; 192 return fSharedHeap;
193 } 193 }
194 194
195 void addTypeface() { 195 void addTypeface() {
196 size_t size = fReader->read32(); 196 size_t size = fReader->read32();
197 const void* data = fReader->skip(SkAlign4(size)); 197 const void* data = fReader->skip(SkAlign4(size));
198 SkMemoryStream stream(data, size, false); 198 SkMemoryStream stream(data, size, false);
199 *fTypefaces.append() = SkTypeface::Deserialize(&stream); 199 *fTypefaces.append() = SkTypeface::Deserialize(&stream);
200 } 200 }
201 201
202 SkTypeface* getTypeface(unsigned id) const { 202 SkTypeface* getTypeface(unsigned id) const {
203 return id ? fTypefaces[id - 1] : NULL; 203 return id ? fTypefaces[id - 1] : nullptr;
204 } 204 }
205 205
206 const SkImage* getImage(int32_t slot) const { 206 const SkImage* getImage(int32_t slot) const {
207 return fImageHeap->get(slot); 207 return fImageHeap->get(slot);
208 } 208 }
209 209
210 private: 210 private:
211 void updateReader() { 211 void updateReader() {
212 if (NULL == fReader) { 212 if (nullptr == fReader) {
213 return; 213 return;
214 } 214 }
215 bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag) ; 215 bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag) ;
216 fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess, 216 fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess,
217 SkReadBuffer::kCrossProcess_Flag)); 217 SkReadBuffer::kCrossProcess_Flag));
218 if (crossProcess) { 218 if (crossProcess) {
219 fReader->setFactoryArray(&fFactoryArray); 219 fReader->setFactoryArray(&fFactoryArray);
220 } else { 220 } else {
221 fReader->setFactoryArray(NULL); 221 fReader->setFactoryArray(nullptr);
222 } 222 }
223 223
224 if (shouldFlattenBitmaps(fFlags)) { 224 if (shouldFlattenBitmaps(fFlags)) {
225 fReader->setBitmapStorage(this); 225 fReader->setBitmapStorage(this);
226 } else { 226 } else {
227 fReader->setBitmapStorage(fSharedHeap); 227 fReader->setBitmapStorage(fSharedHeap);
228 } 228 }
229 } 229 }
230 SkReadBuffer* fReader; 230 SkReadBuffer* fReader;
231 SkPaint fPaint; 231 SkPaint fPaint;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 static void save_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 330 static void save_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
331 SkGPipeState* state) { 331 SkGPipeState* state) {
332 canvas->save(); 332 canvas->save();
333 } 333 }
334 334
335 static void saveLayer_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 335 static void saveLayer_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
336 SkGPipeState* state) { 336 SkGPipeState* state) {
337 unsigned flags = DrawOp_unpackFlags(op32); 337 unsigned flags = DrawOp_unpackFlags(op32);
338 SkCanvas::SaveFlags saveFlags = (SkCanvas::SaveFlags)DrawOp_unpackData(op32) ; 338 SkCanvas::SaveFlags saveFlags = (SkCanvas::SaveFlags)DrawOp_unpackData(op32) ;
339 339
340 const SkRect* bounds = NULL; 340 const SkRect* bounds = nullptr;
341 if (flags & kSaveLayer_HasBounds_DrawOpFlag) { 341 if (flags & kSaveLayer_HasBounds_DrawOpFlag) {
342 bounds = skip<SkRect>(reader); 342 bounds = skip<SkRect>(reader);
343 } 343 }
344 const SkPaint* paint = NULL; 344 const SkPaint* paint = nullptr;
345 if (flags & kSaveLayer_HasPaint_DrawOpFlag) { 345 if (flags & kSaveLayer_HasPaint_DrawOpFlag) {
346 paint = &state->paint(); 346 paint = &state->paint();
347 } 347 }
348 canvas->saveLayer(bounds, paint, saveFlags); 348 canvas->saveLayer(bounds, paint, saveFlags);
349 } 349 }
350 350
351 static void restore_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 351 static void restore_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
352 SkGPipeState* state) { 352 SkGPipeState* state) {
353 canvas->restore(); 353 canvas->restore();
354 } 354 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 } 408 }
409 409
410 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 410 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
411 SkGPipeState* state) { 411 SkGPipeState* state) {
412 412
413 unsigned flags = DrawOp_unpackFlags(op32); 413 unsigned flags = DrawOp_unpackFlags(op32);
414 414
415 const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts); 415 const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts);
416 416
417 const SkColor* colors = NULL; 417 const SkColor* colors = nullptr;
418 if (flags & kDrawVertices_HasColors_DrawOpFlag) { 418 if (flags & kDrawVertices_HasColors_DrawOpFlag) {
419 colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners); 419 colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners);
420 } 420 }
421 const SkPoint* texCoords = NULL; 421 const SkPoint* texCoords = nullptr;
422 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { 422 if (flags & kDrawVertices_HasTexs_DrawOpFlag) {
423 texCoords = skip<SkPoint>(reader, SkPatchUtils::kNumCorners); 423 texCoords = skip<SkPoint>(reader, SkPatchUtils::kNumCorners);
424 } 424 }
425 SkAutoTUnref<SkXfermode> xfer; 425 SkAutoTUnref<SkXfermode> xfer;
426 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { 426 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
427 int mode = reader->readInt(); 427 int mode = reader->readInt();
428 if (mode < 0 || mode > SkXfermode::kLastMode) { 428 if (mode < 0 || mode > SkXfermode::kLastMode) {
429 mode = SkXfermode::kModulate_Mode; 429 mode = SkXfermode::kModulate_Mode;
430 } 430 }
431 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode)); 431 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode));
(...skipping 13 matching lines...) Expand all
445 } 445 }
446 446
447 static void drawVertices_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 447 static void drawVertices_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
448 SkGPipeState* state) { 448 SkGPipeState* state) {
449 unsigned flags = DrawOp_unpackFlags(op32); 449 unsigned flags = DrawOp_unpackFlags(op32);
450 450
451 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readU32(); 451 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readU32();
452 int vertexCount = reader->readU32(); 452 int vertexCount = reader->readU32();
453 const SkPoint* verts = skip<SkPoint>(reader, vertexCount); 453 const SkPoint* verts = skip<SkPoint>(reader, vertexCount);
454 454
455 const SkPoint* texs = NULL; 455 const SkPoint* texs = nullptr;
456 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { 456 if (flags & kDrawVertices_HasTexs_DrawOpFlag) {
457 texs = skip<SkPoint>(reader, vertexCount); 457 texs = skip<SkPoint>(reader, vertexCount);
458 } 458 }
459 459
460 const SkColor* colors = NULL; 460 const SkColor* colors = nullptr;
461 if (flags & kDrawVertices_HasColors_DrawOpFlag) { 461 if (flags & kDrawVertices_HasColors_DrawOpFlag) {
462 colors = skip<SkColor>(reader, vertexCount); 462 colors = skip<SkColor>(reader, vertexCount);
463 } 463 }
464 464
465 SkAutoTUnref<SkXfermode> xfer; 465 SkAutoTUnref<SkXfermode> xfer;
466 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { 466 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
467 SkXfermode::Mode mode = (SkXfermode::Mode)reader->readU32(); 467 SkXfermode::Mode mode = (SkXfermode::Mode)reader->readU32();
468 xfer.reset(SkXfermode::Create(mode)); 468 xfer.reset(SkXfermode::Create(mode));
469 } 469 }
470 470
471 int indexCount = 0; 471 int indexCount = 0;
472 const uint16_t* indices = NULL; 472 const uint16_t* indices = nullptr;
473 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { 473 if (flags & kDrawVertices_HasIndices_DrawOpFlag) {
474 indexCount = reader->readU32(); 474 indexCount = reader->readU32();
475 indices = skipAlign<uint16_t>(reader, indexCount); 475 indices = skipAlign<uint16_t>(reader, indexCount);
476 } 476 }
477 if (state->shouldDraw()) { 477 if (state->shouldDraw()) {
478 canvas->drawVertices(vmode, vertexCount, verts, texs, colors, xfer, 478 canvas->drawVertices(vmode, vertexCount, verts, texs, colors, xfer,
479 indices, indexCount, state->paint()); 479 indices, indexCount, state->paint());
480 } 480 }
481 } 481 }
482 482
483 static void drawAtlas_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, Sk GPipeState* state) { 483 static void drawAtlas_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, Sk GPipeState* state) {
484 unsigned flags = DrawOp_unpackFlags(op32); 484 unsigned flags = DrawOp_unpackFlags(op32);
485 485
486 const SkPaint* paint = NULL; 486 const SkPaint* paint = nullptr;
487 if (flags & kDrawAtlas_HasPaint_DrawOpFlag) { 487 if (flags & kDrawAtlas_HasPaint_DrawOpFlag) {
488 paint = &state->paint(); 488 paint = &state->paint();
489 } 489 }
490 const int slot = reader->readU32(); 490 const int slot = reader->readU32();
491 const SkImage* atlas = state->getImage(slot); 491 const SkImage* atlas = state->getImage(slot);
492 const int count = reader->readU32(); 492 const int count = reader->readU32();
493 SkXfermode::Mode mode = (SkXfermode::Mode)reader->readU32(); 493 SkXfermode::Mode mode = (SkXfermode::Mode)reader->readU32();
494 const SkRSXform* xform = skip<SkRSXform>(reader, count); 494 const SkRSXform* xform = skip<SkRSXform>(reader, count);
495 const SkRect* tex = skip<SkRect>(reader, count); 495 const SkRect* tex = skip<SkRect>(reader, count);
496 const SkColor* colors = NULL; 496 const SkColor* colors = nullptr;
497 if (flags & kDrawAtlas_HasColors_DrawOpFlag) { 497 if (flags & kDrawAtlas_HasColors_DrawOpFlag) {
498 colors = skip<SkColor>(reader, count); 498 colors = skip<SkColor>(reader, count);
499 } 499 }
500 const SkRect* cull = NULL; 500 const SkRect* cull = nullptr;
501 if (flags & kDrawAtlas_HasCull_DrawOpFlag) { 501 if (flags & kDrawAtlas_HasCull_DrawOpFlag) {
502 cull = skip<SkRect>(reader, 1); 502 cull = skip<SkRect>(reader, 1);
503 } 503 }
504 504
505 if (state->shouldDraw()) { 505 if (state->shouldDraw()) {
506 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); 506 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
507 } 507 }
508 } 508 }
509 509
510 /////////////////////////////////////////////////////////////////////////////// 510 ///////////////////////////////////////////////////////////////////////////////
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 static void drawTextOnPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op3 2, 545 static void drawTextOnPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op3 2,
546 SkGPipeState* state) { 546 SkGPipeState* state) {
547 size_t len = reader->readU32(); 547 size_t len = reader->readU32();
548 const void* text = reader->skip(SkAlign4(len)); 548 const void* text = reader->skip(SkAlign4(len));
549 549
550 SkPath path; 550 SkPath path;
551 reader->readPath(&path); 551 reader->readPath(&path);
552 552
553 SkMatrix matrixStorage; 553 SkMatrix matrixStorage;
554 const SkMatrix* matrix = NULL; 554 const SkMatrix* matrix = nullptr;
555 if (DrawOp_unpackFlags(op32) & kDrawTextOnPath_HasMatrix_DrawOpFlag) { 555 if (DrawOp_unpackFlags(op32) & kDrawTextOnPath_HasMatrix_DrawOpFlag) {
556 reader->readMatrix(&matrixStorage); 556 reader->readMatrix(&matrixStorage);
557 matrix = &matrixStorage; 557 matrix = &matrixStorage;
558 } 558 }
559 if (state->shouldDraw()) { 559 if (state->shouldDraw()) {
560 canvas->drawTextOnPath(text, len, path, matrix, state->paint()); 560 canvas->drawTextOnPath(text, len, path, matrix, state->paint());
561 } 561 }
562 } 562 }
563 563
564 /////////////////////////////////////////////////////////////////////////////// 564 ///////////////////////////////////////////////////////////////////////////////
565 565
566 class BitmapHolder : SkNoncopyable { 566 class BitmapHolder : SkNoncopyable {
567 public: 567 public:
568 BitmapHolder(SkReader32* reader, uint32_t op32, SkGPipeState* state); 568 BitmapHolder(SkReader32* reader, uint32_t op32, SkGPipeState* state);
569 ~BitmapHolder() { 569 ~BitmapHolder() {
570 if (fHeapEntry != NULL) { 570 if (fHeapEntry != nullptr) {
571 fHeapEntry->releaseRef(); 571 fHeapEntry->releaseRef();
572 } 572 }
573 } 573 }
574 const SkBitmap* getBitmap() { 574 const SkBitmap* getBitmap() {
575 return fBitmap; 575 return fBitmap;
576 } 576 }
577 private: 577 private:
578 SkBitmapHeapEntry* fHeapEntry; 578 SkBitmapHeapEntry* fHeapEntry;
579 const SkBitmap* fBitmap; 579 const SkBitmap* fBitmap;
580 SkBitmap fBitmapStorage; 580 SkBitmap fBitmapStorage;
581 }; 581 };
582 582
583 BitmapHolder::BitmapHolder(SkReader32* reader, uint32_t op32, 583 BitmapHolder::BitmapHolder(SkReader32* reader, uint32_t op32,
584 SkGPipeState* state) { 584 SkGPipeState* state) {
585 const unsigned flags = state->getFlags(); 585 const unsigned flags = state->getFlags();
586 const unsigned index = DrawOp_unpackData(op32); 586 const unsigned index = DrawOp_unpackData(op32);
587 if (shouldFlattenBitmaps(flags)) { 587 if (shouldFlattenBitmaps(flags)) {
588 fHeapEntry = NULL; 588 fHeapEntry = nullptr;
589 fBitmap = state->getBitmap(index); 589 fBitmap = state->getBitmap(index);
590 } else { 590 } else {
591 SkBitmapHeapEntry* entry = state->getSharedHeap()->getEntry(index); 591 SkBitmapHeapEntry* entry = state->getSharedHeap()->getEntry(index);
592 if (SkToBool(flags & SkGPipeWriter::kSimultaneousReaders_Flag)) { 592 if (SkToBool(flags & SkGPipeWriter::kSimultaneousReaders_Flag)) {
593 // Make a shallow copy for thread safety. Each thread will point to the same SkPixelRef, 593 // Make a shallow copy for thread safety. Each thread will point to the same SkPixelRef,
594 // which is thread safe. 594 // which is thread safe.
595 fBitmapStorage = *entry->getBitmap(); 595 fBitmapStorage = *entry->getBitmap();
596 fBitmap = &fBitmapStorage; 596 fBitmap = &fBitmapStorage;
597 // Release the ref on the bitmap now, since we made our own copy. 597 // Release the ref on the bitmap now, since we made our own copy.
598 entry->releaseRef(); 598 entry->releaseRef();
599 fHeapEntry = NULL; 599 fHeapEntry = nullptr;
600 } else { 600 } else {
601 SkASSERT(!shouldFlattenBitmaps(flags)); 601 SkASSERT(!shouldFlattenBitmaps(flags));
602 SkASSERT(!SkToBool(flags & SkGPipeWriter::kSimultaneousReaders_Flag) ); 602 SkASSERT(!SkToBool(flags & SkGPipeWriter::kSimultaneousReaders_Flag) );
603 fHeapEntry = entry; 603 fHeapEntry = entry;
604 fBitmap = fHeapEntry->getBitmap(); 604 fBitmap = fHeapEntry->getBitmap();
605 } 605 }
606 } 606 }
607 } 607 }
608 608
609 static void drawBitmap_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 609 static void drawBitmap_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
610 SkGPipeState* state) { 610 SkGPipeState* state) {
611 BitmapHolder holder(reader, op32, state); 611 BitmapHolder holder(reader, op32, state);
612 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag); 612 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag);
613 SkScalar left = reader->readScalar(); 613 SkScalar left = reader->readScalar();
614 SkScalar top = reader->readScalar(); 614 SkScalar top = reader->readScalar();
615 const SkBitmap* bitmap = holder.getBitmap(); 615 const SkBitmap* bitmap = holder.getBitmap();
616 if (state->shouldDraw()) { 616 if (state->shouldDraw()) {
617 canvas->drawBitmap(*bitmap, left, top, hasPaint ? &state->paint() : NULL ); 617 canvas->drawBitmap(*bitmap, left, top, hasPaint ? &state->paint() : null ptr);
618 } 618 }
619 } 619 }
620 620
621 static void drawBitmapNine_rp(SkCanvas* canvas, SkReader32* reader, 621 static void drawBitmapNine_rp(SkCanvas* canvas, SkReader32* reader,
622 uint32_t op32, SkGPipeState* state) { 622 uint32_t op32, SkGPipeState* state) {
623 BitmapHolder holder(reader, op32, state); 623 BitmapHolder holder(reader, op32, state);
624 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag); 624 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag);
625 const SkIRect* center = skip<SkIRect>(reader); 625 const SkIRect* center = skip<SkIRect>(reader);
626 const SkRect* dst = skip<SkRect>(reader); 626 const SkRect* dst = skip<SkRect>(reader);
627 const SkBitmap* bitmap = holder.getBitmap(); 627 const SkBitmap* bitmap = holder.getBitmap();
628 if (state->shouldDraw()) { 628 if (state->shouldDraw()) {
629 canvas->drawBitmapNine(*bitmap, *center, *dst, 629 canvas->drawBitmapNine(*bitmap, *center, *dst,
630 hasPaint ? &state->paint() : NULL); 630 hasPaint ? &state->paint() : nullptr);
631 } 631 }
632 } 632 }
633 633
634 static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader, 634 static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
635 uint32_t op32, SkGPipeState* state) { 635 uint32_t op32, SkGPipeState* state) {
636 BitmapHolder holder(reader, op32, state); 636 BitmapHolder holder(reader, op32, state);
637 unsigned flags = DrawOp_unpackFlags(op32); 637 unsigned flags = DrawOp_unpackFlags(op32);
638 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); 638 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
639 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); 639 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
640 const SkRect* src; 640 const SkRect* src;
641 if (hasSrc) { 641 if (hasSrc) {
642 src = skip<SkRect>(reader); 642 src = skip<SkRect>(reader);
643 } else { 643 } else {
644 src = NULL; 644 src = nullptr;
645 } 645 }
646 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint ; 646 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint ;
647 if (flags & kDrawBitmap_Bleed_DrawOpFlag) { 647 if (flags & kDrawBitmap_Bleed_DrawOpFlag) {
648 constraint = SkCanvas::kFast_SrcRectConstraint; 648 constraint = SkCanvas::kFast_SrcRectConstraint;
649 } 649 }
650 const SkRect* dst = skip<SkRect>(reader); 650 const SkRect* dst = skip<SkRect>(reader);
651 const SkBitmap* bitmap = holder.getBitmap(); 651 const SkBitmap* bitmap = holder.getBitmap();
652 if (state->shouldDraw()) { 652 if (state->shouldDraw()) {
653 canvas->legacy_drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->pai nt() : NULL, constraint); 653 canvas->legacy_drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->pai nt() : nullptr, constraint);
654 } 654 }
655 } 655 }
656 656
657 static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 657 static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
658 SkGPipeState* state) { 658 SkGPipeState* state) {
659 BitmapHolder holder(reader, op32, state); 659 BitmapHolder holder(reader, op32, state);
660 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag); 660 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra wOpFlag);
661 const SkIPoint* point = skip<SkIPoint>(reader); 661 const SkIPoint* point = skip<SkIPoint>(reader);
662 const SkBitmap* bitmap = holder.getBitmap(); 662 const SkBitmap* bitmap = holder.getBitmap();
663 if (state->shouldDraw()) { 663 if (state->shouldDraw()) {
664 canvas->drawSprite(*bitmap, point->fX, point->fY, hasPaint ? &state->pai nt() : NULL); 664 canvas->drawSprite(*bitmap, point->fX, point->fY, hasPaint ? &state->pai nt() : nullptr);
665 } 665 }
666 } 666 }
667 667
668 static void drawImage_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, Sk GPipeState* state) { 668 static void drawImage_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, Sk GPipeState* state) {
669 unsigned slot = DrawOp_unpackData(op32); 669 unsigned slot = DrawOp_unpackData(op32);
670 unsigned flags = DrawOp_unpackFlags(op32); 670 unsigned flags = DrawOp_unpackFlags(op32);
671 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); 671 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
672 SkScalar x = reader->readScalar(); 672 SkScalar x = reader->readScalar();
673 SkScalar y = reader->readScalar(); 673 SkScalar y = reader->readScalar();
674 const SkImage* image = state->getImage(slot); 674 const SkImage* image = state->getImage(slot);
675 if (state->shouldDraw()) { 675 if (state->shouldDraw()) {
676 canvas->drawImage(image, x, y, hasPaint ? &state->paint() : NULL); 676 canvas->drawImage(image, x, y, hasPaint ? &state->paint() : nullptr);
677 } 677 }
678 } 678 }
679 679
680 static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32 , 680 static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32 ,
681 SkGPipeState* state) { 681 SkGPipeState* state) {
682 unsigned slot = DrawOp_unpackData(op32); 682 unsigned slot = DrawOp_unpackData(op32);
683 unsigned flags = DrawOp_unpackFlags(op32); 683 unsigned flags = DrawOp_unpackFlags(op32);
684 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); 684 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
685 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); 685 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
686 const SkRect* src = NULL; 686 const SkRect* src = nullptr;
687 if (hasSrc) { 687 if (hasSrc) {
688 src = skip<SkRect>(reader); 688 src = skip<SkRect>(reader);
689 } 689 }
690 const SkRect* dst = skip<SkRect>(reader); 690 const SkRect* dst = skip<SkRect>(reader);
691 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader ->readInt(); 691 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader ->readInt();
692 692
693 const SkImage* image = state->getImage(slot); 693 const SkImage* image = state->getImage(slot);
694 if (state->shouldDraw()) { 694 if (state->shouldDraw()) {
695 canvas->legacy_drawImageRect(image, src, *dst, hasPaint ? &state->paint( ) : NULL, constraint); 695 canvas->legacy_drawImageRect(image, src, *dst, hasPaint ? &state->paint( ) : nullptr, constraint);
696 } 696 }
697 } 697 }
698 698
699 static void drawImageNine_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32 , 699 static void drawImageNine_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32 ,
700 SkGPipeState* state) { 700 SkGPipeState* state) {
701 unsigned slot = DrawOp_unpackData(op32); 701 unsigned slot = DrawOp_unpackData(op32);
702 unsigned flags = DrawOp_unpackFlags(op32); 702 unsigned flags = DrawOp_unpackFlags(op32);
703 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); 703 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
704 const SkIRect* center = skip<SkIRect>(reader); 704 const SkIRect* center = skip<SkIRect>(reader);
705 const SkRect* dst = skip<SkRect>(reader); 705 const SkRect* dst = skip<SkRect>(reader);
706 const SkImage* image = state->getImage(slot); 706 const SkImage* image = state->getImage(slot);
707 if (state->shouldDraw()) { 707 if (state->shouldDraw()) {
708 canvas->drawImageNine(image, *center, *dst, hasPaint ? &state->paint() : NULL); 708 canvas->drawImageNine(image, *center, *dst, hasPaint ? &state->paint() : nullptr);
709 } 709 }
710 } 710 }
711 711
712 /////////////////////////////////////////////////////////////////////////////// 712 ///////////////////////////////////////////////////////////////////////////////
713 713
714 static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, 714 static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
715 SkGPipeState* state) { 715 SkGPipeState* state) {
716 UNIMPLEMENTED 716 UNIMPLEMENTED
717 } 717 }
718 718
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 static void annotation_rp(SkCanvas*, SkReader32* reader, uint32_t op32, 805 static void annotation_rp(SkCanvas*, SkReader32* reader, uint32_t op32,
806 SkGPipeState* state) { 806 SkGPipeState* state) {
807 SkPaint* p = state->editPaint(); 807 SkPaint* p = state->editPaint();
808 808
809 const size_t size = DrawOp_unpackData(op32); 809 const size_t size = DrawOp_unpackData(op32);
810 if (size > 0) { 810 if (size > 0) {
811 SkReadBuffer buffer(reader->skip(size), size); 811 SkReadBuffer buffer(reader->skip(size), size);
812 p->setAnnotation(SkAnnotation::Create(buffer))->unref(); 812 p->setAnnotation(SkAnnotation::Create(buffer))->unref();
813 SkASSERT(buffer.offset() == size); 813 SkASSERT(buffer.offset() == size);
814 } else { 814 } else {
815 p->setAnnotation(NULL); 815 p->setAnnotation(nullptr);
816 } 816 }
817 } 817 }
818 818
819 /////////////////////////////////////////////////////////////////////////////// 819 ///////////////////////////////////////////////////////////////////////////////
820 820
821 static void def_Typeface_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* stat e) { 821 static void def_Typeface_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* stat e) {
822 state->addTypeface(); 822 state->addTypeface();
823 } 823 }
824 824
825 static void def_PaintFlat_rp(SkCanvas*, SkReader32*, uint32_t op32, 825 static void def_PaintFlat_rp(SkCanvas*, SkReader32*, uint32_t op32,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 shareBitmapHeap_rp, 918 shareBitmapHeap_rp,
919 shareImageHeap_rp, 919 shareImageHeap_rp,
920 done_rp 920 done_rp
921 }; 921 };
922 922
923 /////////////////////////////////////////////////////////////////////////////// 923 ///////////////////////////////////////////////////////////////////////////////
924 924
925 SkGPipeState::SkGPipeState() 925 SkGPipeState::SkGPipeState()
926 : fReader(0) 926 : fReader(0)
927 , fSilent(false) 927 , fSilent(false)
928 , fSharedHeap(NULL) 928 , fSharedHeap(nullptr)
929 , fFlags(0) { 929 , fFlags(0) {
930 930
931 } 931 }
932 932
933 SkGPipeState::~SkGPipeState() { 933 SkGPipeState::~SkGPipeState() {
934 fTypefaces.safeUnrefAll(); 934 fTypefaces.safeUnrefAll();
935 fFlatArray.safeUnrefAll(); 935 fFlatArray.safeUnrefAll();
936 fBitmaps.deleteAll(); 936 fBitmaps.deleteAll();
937 SkSafeUnref(fSharedHeap); 937 SkSafeUnref(fSharedHeap);
938 } 938 }
939 939
940 /////////////////////////////////////////////////////////////////////////////// 940 ///////////////////////////////////////////////////////////////////////////////
941 941
942 #include "SkGPipe.h" 942 #include "SkGPipe.h"
943 943
944 SkGPipeReader::SkGPipeReader() { 944 SkGPipeReader::SkGPipeReader() {
945 fCanvas = NULL; 945 fCanvas = nullptr;
946 fState = NULL; 946 fState = nullptr;
947 fProc = NULL; 947 fProc = nullptr;
948 } 948 }
949 949
950 SkGPipeReader::SkGPipeReader(SkCanvas* target) { 950 SkGPipeReader::SkGPipeReader(SkCanvas* target) {
951 fCanvas = NULL; 951 fCanvas = nullptr;
952 this->setCanvas(target); 952 this->setCanvas(target);
953 fState = NULL; 953 fState = nullptr;
954 fProc = NULL; 954 fProc = nullptr;
955 } 955 }
956 956
957 void SkGPipeReader::setCanvas(SkCanvas *target) { 957 void SkGPipeReader::setCanvas(SkCanvas *target) {
958 SkRefCnt_SafeAssign(fCanvas, target); 958 SkRefCnt_SafeAssign(fCanvas, target);
959 } 959 }
960 960
961 SkGPipeReader::~SkGPipeReader() { 961 SkGPipeReader::~SkGPipeReader() {
962 SkSafeUnref(fCanvas); 962 SkSafeUnref(fCanvas);
963 delete fState; 963 delete fState;
964 } 964 }
965 965
966 SkGPipeReader::Status SkGPipeReader::playback(const void* data, size_t length, 966 SkGPipeReader::Status SkGPipeReader::playback(const void* data, size_t length,
967 uint32_t playbackFlags, size_t* by tesRead) { 967 uint32_t playbackFlags, size_t* by tesRead) {
968 if (NULL == fCanvas) { 968 if (nullptr == fCanvas) {
969 return kError_Status; 969 return kError_Status;
970 } 970 }
971 971
972 if (NULL == fState) { 972 if (nullptr == fState) {
973 fState = new SkGPipeState; 973 fState = new SkGPipeState;
974 } 974 }
975 975
976 fState->setSilent(playbackFlags & kSilent_PlaybackFlag); 976 fState->setSilent(playbackFlags & kSilent_PlaybackFlag);
977 977
978 SkASSERT(SK_ARRAY_COUNT(gReadTable) == (kDone_DrawOp + 1)); 978 SkASSERT(SK_ARRAY_COUNT(gReadTable) == (kDone_DrawOp + 1));
979 979
980 const ReadProc* table = gReadTable; 980 const ReadProc* table = gReadTable;
981 SkReadBuffer reader(data, length); 981 SkReadBuffer reader(data, length);
982 reader.setBitmapDecoder(fProc); 982 reader.setBitmapDecoder(fProc);
(...skipping 25 matching lines...) Expand all
1008 status = kReadAtom_Status; 1008 status = kReadAtom_Status;
1009 break; 1009 break;
1010 } 1010 }
1011 } 1011 }
1012 1012
1013 if (bytesRead) { 1013 if (bytesRead) {
1014 *bytesRead = reader.offset(); 1014 *bytesRead = reader.offset();
1015 } 1015 }
1016 return status; 1016 return status;
1017 } 1017 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipePriv.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698