| OLD | NEW |
| 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 "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 /** | 241 /** |
| 242 * Flatten an SkBitmap to send to the reader, where it will be referenced | 242 * Flatten an SkBitmap to send to the reader, where it will be referenced |
| 243 * according to slot. | 243 * according to slot. |
| 244 */ | 244 */ |
| 245 bool shuttleBitmap(const SkBitmap&, int32_t slot); | 245 bool shuttleBitmap(const SkBitmap&, int32_t slot); |
| 246 | 246 |
| 247 void resetImageHeap(); | 247 void resetImageHeap(); |
| 248 | 248 |
| 249 protected: | 249 protected: |
| 250 void willSave() override; | 250 void willSave() override; |
| 251 SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) ov
erride; | 251 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
| 252 void willRestore() override; | 252 void willRestore() override; |
| 253 | 253 |
| 254 void didConcat(const SkMatrix&) override; | 254 void didConcat(const SkMatrix&) override; |
| 255 void didSetMatrix(const SkMatrix&) override; | 255 void didSetMatrix(const SkMatrix&) override; |
| 256 | 256 |
| 257 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; | 257 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
| 258 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, | 258 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 259 const SkPaint&) override; | 259 const SkPaint&) override; |
| 260 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], | 260 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 261 const SkPaint&) override; | 261 const SkPaint&) override; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 535 |
| 536 void SkGPipeCanvas::willSave() { | 536 void SkGPipeCanvas::willSave() { |
| 537 NOTIFY_SETUP(this); | 537 NOTIFY_SETUP(this); |
| 538 if (this->needOpBytes()) { | 538 if (this->needOpBytes()) { |
| 539 this->writeOp(kSave_DrawOp); | 539 this->writeOp(kSave_DrawOp); |
| 540 } | 540 } |
| 541 | 541 |
| 542 this->INHERITED::willSave(); | 542 this->INHERITED::willSave(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, c
onst SkPaint* paint, | 545 SkCanvas::SaveLayerStrategy SkGPipeCanvas::getSaveLayerStrategy(const SaveLayerR
ec& rec) { |
| 546 SaveFlags saveFlags) { | |
| 547 NOTIFY_SETUP(this); | 546 NOTIFY_SETUP(this); |
| 548 size_t size = 0; | 547 size_t size = 0; |
| 549 unsigned opFlags = 0; | 548 unsigned opFlags = 0; |
| 550 | 549 |
| 551 if (bounds) { | 550 if (rec.fBounds) { |
| 552 opFlags |= kSaveLayer_HasBounds_DrawOpFlag; | 551 opFlags |= kSaveLayer_HasBounds_DrawOpFlag; |
| 553 size += sizeof(SkRect); | 552 size += sizeof(SkRect); |
| 554 } | 553 } |
| 555 if (paint) { | 554 if (rec.fPaint) { |
| 556 opFlags |= kSaveLayer_HasPaint_DrawOpFlag; | 555 opFlags |= kSaveLayer_HasPaint_DrawOpFlag; |
| 557 this->writePaint(*paint); | 556 this->writePaint(*rec.fPaint); |
| 558 } | 557 } |
| 559 | 558 |
| 560 if (this->needOpBytes(size)) { | 559 if (this->needOpBytes(size)) { |
| 561 this->writeOp(kSaveLayer_DrawOp, opFlags, saveFlags); | 560 this->writeOp(kSaveLayer_DrawOp, opFlags, rec.fSaveLayerFlags); |
| 562 if (bounds) { | 561 if (rec.fBounds) { |
| 563 fWriter.writeRect(*bounds); | 562 fWriter.writeRect(*rec.fBounds); |
| 564 } | 563 } |
| 565 } | 564 } |
| 566 | 565 |
| 567 this->INHERITED::willSaveLayer(bounds, paint, saveFlags); | 566 (void)this->INHERITED::getSaveLayerStrategy(rec); |
| 568 // we don't create a layer | 567 // we don't create a layer |
| 569 return kNoLayer_SaveLayerStrategy; | 568 return kNoLayer_SaveLayerStrategy; |
| 570 } | 569 } |
| 571 | 570 |
| 572 void SkGPipeCanvas::willRestore() { | 571 void SkGPipeCanvas::willRestore() { |
| 573 NOTIFY_SETUP(this); | 572 NOTIFY_SETUP(this); |
| 574 if (this->needOpBytes()) { | 573 if (this->needOpBytes()) { |
| 575 this->writeOp(kRestore_DrawOp); | 574 this->writeOp(kRestore_DrawOp); |
| 576 } | 575 } |
| 577 | 576 |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 int32_t slot = this->find(img); | 1474 int32_t slot = this->find(img); |
| 1476 if (slot) { | 1475 if (slot) { |
| 1477 return slot; | 1476 return slot; |
| 1478 } | 1477 } |
| 1479 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1478 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
| 1480 fBytesInCache += img->width() * img->height() * 4; | 1479 fBytesInCache += img->width() * img->height() * 4; |
| 1481 *fArray.append() = SkRef(img); | 1480 *fArray.append() = SkRef(img); |
| 1482 return fArray.count(); // slot is always index+1 | 1481 return fArray.count(); // slot is always index+1 |
| 1483 } | 1482 } |
| 1484 | 1483 |
| OLD | NEW |