| 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 "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 * Flatten an SkBitmap to send to the reader, where it will be referenced | 274 * Flatten an SkBitmap to send to the reader, where it will be referenced |
| 275 * according to slot. | 275 * according to slot. |
| 276 */ | 276 */ |
| 277 bool shuttleBitmap(const SkBitmap&, int32_t slot); | 277 bool shuttleBitmap(const SkBitmap&, int32_t slot); |
| 278 | 278 |
| 279 protected: | 279 protected: |
| 280 virtual void willSave(SaveFlags) SK_OVERRIDE; | 280 virtual void willSave(SaveFlags) SK_OVERRIDE; |
| 281 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; | 281 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; |
| 282 virtual void willRestore() SK_OVERRIDE; | 282 virtual void willRestore() SK_OVERRIDE; |
| 283 | 283 |
| 284 virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; | |
| 285 virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; | |
| 286 virtual void didRotate(SkScalar) SK_OVERRIDE; | |
| 287 virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; | |
| 288 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; | 284 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; |
| 289 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; | 285 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
| 290 | 286 |
| 291 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; | 287 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; |
| 292 | 288 |
| 293 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 289 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
| 294 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; | 290 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; |
| 295 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 291 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
| 296 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; | 292 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; |
| 297 | 293 |
| 298 private: | 294 private: |
| 295 void recordTranslate(const SkMatrix&); |
| 296 void recordScale(const SkMatrix&); |
| 297 void recordConcat(const SkMatrix&); |
| 298 |
| 299 enum { | 299 enum { |
| 300 kNoSaveLayer = -1, | 300 kNoSaveLayer = -1, |
| 301 }; | 301 }; |
| 302 SkNamedFactorySet* fFactorySet; | 302 SkNamedFactorySet* fFactorySet; |
| 303 int fFirstSaveLayerStackLevel; | 303 int fFirstSaveLayerStackLevel; |
| 304 SkBitmapHeap* fBitmapHeap; | 304 SkBitmapHeap* fBitmapHeap; |
| 305 SkGPipeController* fController; | 305 SkGPipeController* fController; |
| 306 SkWriter32& fWriter; | 306 SkWriter32& fWriter; |
| 307 size_t fBlockSize; // amount allocated for writer | 307 size_t fBlockSize; // amount allocated for writer |
| 308 size_t fBytesNotified; | 308 size_t fBytesNotified; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 fFirstSaveLayerStackLevel = kNoSaveLayer; | 565 fFirstSaveLayerStackLevel = kNoSaveLayer; |
| 566 } | 566 } |
| 567 | 567 |
| 568 this->INHERITED::willRestore(); | 568 this->INHERITED::willRestore(); |
| 569 } | 569 } |
| 570 | 570 |
| 571 bool SkGPipeCanvas::isDrawingToLayer() const { | 571 bool SkGPipeCanvas::isDrawingToLayer() const { |
| 572 return kNoSaveLayer != fFirstSaveLayerStackLevel; | 572 return kNoSaveLayer != fFirstSaveLayerStackLevel; |
| 573 } | 573 } |
| 574 | 574 |
| 575 void SkGPipeCanvas::didTranslate(SkScalar dx, SkScalar dy) { | 575 void SkGPipeCanvas::recordTranslate(const SkMatrix& m) { |
| 576 if (dx || dy) { | 576 if (this->needOpBytes(2 * sizeof(SkScalar))) { |
| 577 NOTIFY_SETUP(this); | 577 this->writeOp(kTranslate_DrawOp); |
| 578 if (this->needOpBytes(2 * sizeof(SkScalar))) { | 578 fWriter.writeScalar(m.getTranslateX()); |
| 579 this->writeOp(kTranslate_DrawOp); | 579 fWriter.writeScalar(m.getTranslateY()); |
| 580 fWriter.writeScalar(dx); | |
| 581 fWriter.writeScalar(dy); | |
| 582 } | |
| 583 } | 580 } |
| 584 this->INHERITED::didTranslate(dx, dy); | |
| 585 } | 581 } |
| 586 | 582 |
| 587 void SkGPipeCanvas::didScale(SkScalar sx, SkScalar sy) { | 583 void SkGPipeCanvas::recordScale(const SkMatrix& m) { |
| 588 if (sx || sy) { | 584 if (this->needOpBytes(2 * sizeof(SkScalar))) { |
| 589 NOTIFY_SETUP(this); | 585 this->writeOp(kScale_DrawOp); |
| 590 if (this->needOpBytes(2 * sizeof(SkScalar))) { | 586 fWriter.writeScalar(m.getScaleX()); |
| 591 this->writeOp(kScale_DrawOp); | 587 fWriter.writeScalar(m.getScaleY()); |
| 592 fWriter.writeScalar(sx); | |
| 593 fWriter.writeScalar(sy); | |
| 594 } | |
| 595 } | 588 } |
| 596 this->INHERITED::didScale(sx, sy); | |
| 597 } | 589 } |
| 598 | 590 |
| 599 void SkGPipeCanvas::didRotate(SkScalar degrees) { | 591 void SkGPipeCanvas::recordConcat(const SkMatrix& m) { |
| 600 if (degrees) { | 592 if (this->needOpBytes(m.writeToMemory(NULL))) { |
| 601 NOTIFY_SETUP(this); | 593 this->writeOp(kConcat_DrawOp); |
| 602 if (this->needOpBytes(sizeof(SkScalar))) { | 594 fWriter.writeMatrix(m); |
| 603 this->writeOp(kRotate_DrawOp); | |
| 604 fWriter.writeScalar(degrees); | |
| 605 } | |
| 606 } | 595 } |
| 607 this->INHERITED::didRotate(degrees); | |
| 608 } | |
| 609 | |
| 610 void SkGPipeCanvas::didSkew(SkScalar sx, SkScalar sy) { | |
| 611 if (sx || sy) { | |
| 612 NOTIFY_SETUP(this); | |
| 613 if (this->needOpBytes(2 * sizeof(SkScalar))) { | |
| 614 this->writeOp(kSkew_DrawOp); | |
| 615 fWriter.writeScalar(sx); | |
| 616 fWriter.writeScalar(sy); | |
| 617 } | |
| 618 } | |
| 619 this->INHERITED::didSkew(sx, sy); | |
| 620 } | 596 } |
| 621 | 597 |
| 622 void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { | 598 void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { |
| 623 if (!matrix.isIdentity()) { | 599 if (!matrix.isIdentity()) { |
| 624 NOTIFY_SETUP(this); | 600 NOTIFY_SETUP(this); |
| 625 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 601 switch (matrix.getType()) { |
| 626 this->writeOp(kConcat_DrawOp); | 602 case SkMatrix::kTranslate_Mask: |
| 627 fWriter.writeMatrix(matrix); | 603 this->recordTranslate(matrix); |
| 604 break; |
| 605 case SkMatrix::kScale_Mask: |
| 606 this->recordScale(matrix); |
| 607 break; |
| 608 default: |
| 609 this->recordConcat(matrix); |
| 610 break; |
| 628 } | 611 } |
| 629 } | 612 } |
| 613 |
| 630 this->INHERITED::didConcat(matrix); | 614 this->INHERITED::didConcat(matrix); |
| 631 } | 615 } |
| 632 | 616 |
| 633 void SkGPipeCanvas::didSetMatrix(const SkMatrix& matrix) { | 617 void SkGPipeCanvas::didSetMatrix(const SkMatrix& matrix) { |
| 634 NOTIFY_SETUP(this); | 618 NOTIFY_SETUP(this); |
| 635 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 619 if (this->needOpBytes(matrix.writeToMemory(NULL))) { |
| 636 this->writeOp(kSetMatrix_DrawOp); | 620 this->writeOp(kSetMatrix_DrawOp); |
| 637 fWriter.writeMatrix(matrix); | 621 fWriter.writeMatrix(matrix); |
| 638 } | 622 } |
| 639 this->INHERITED::didSetMatrix(matrix); | 623 this->INHERITED::didSetMatrix(matrix); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 return fCanvas->shuttleBitmap(bitmap, slot); | 1242 return fCanvas->shuttleBitmap(bitmap, slot); |
| 1259 } | 1243 } |
| 1260 | 1244 |
| 1261 void BitmapShuttle::removeCanvas() { | 1245 void BitmapShuttle::removeCanvas() { |
| 1262 if (NULL == fCanvas) { | 1246 if (NULL == fCanvas) { |
| 1263 return; | 1247 return; |
| 1264 } | 1248 } |
| 1265 fCanvas->unref(); | 1249 fCanvas->unref(); |
| 1266 fCanvas = NULL; | 1250 fCanvas = NULL; |
| 1267 } | 1251 } |
| OLD | NEW |