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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 void flushRecording(bool detachCurrentBlock); | 224 void flushRecording(bool detachCurrentBlock); |
225 size_t freeMemoryIfPossible(size_t bytesToFree); | 225 size_t freeMemoryIfPossible(size_t bytesToFree); |
226 | 226 |
227 size_t storageAllocatedForRecording() { | 227 size_t storageAllocatedForRecording() { |
228 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->bytesAllocated(); | 228 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->bytesAllocated(); |
229 } | 229 } |
230 | 230 |
231 // overrides from SkCanvas | 231 // overrides from SkCanvas |
232 virtual bool isDrawingToLayer() const SK_OVERRIDE; | 232 virtual bool isDrawingToLayer() const SK_OVERRIDE; |
233 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE; | |
234 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE; | |
235 virtual bool rotate(SkScalar degrees) SK_OVERRIDE; | |
236 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; | |
237 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; | |
238 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; | |
239 virtual void clear(SkColor) SK_OVERRIDE; | 233 virtual void clear(SkColor) SK_OVERRIDE; |
240 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; | 234 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
241 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], | 235 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], |
242 const SkPaint&) SK_OVERRIDE; | 236 const SkPaint&) SK_OVERRIDE; |
243 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; | 237 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; |
244 virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; | 238 virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; |
245 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; | 239 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; |
246 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; | 240 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; |
247 virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, | 241 virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, |
248 const SkPaint*) SK_OVERRIDE; | 242 const SkPaint*) SK_OVERRIDE; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 * 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 |
281 * according to slot. | 275 * according to slot. |
282 */ | 276 */ |
283 bool shuttleBitmap(const SkBitmap&, int32_t slot); | 277 bool shuttleBitmap(const SkBitmap&, int32_t slot); |
284 | 278 |
285 protected: | 279 protected: |
286 virtual void willSave(SaveFlags) SK_OVERRIDE; | 280 virtual void willSave(SaveFlags) SK_OVERRIDE; |
287 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; | 281 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; |
288 virtual void willRestore() SK_OVERRIDE; | 282 virtual void willRestore() SK_OVERRIDE; |
289 | 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; |
| 289 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
| 290 |
290 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; | 291 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; |
291 | 292 |
292 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 293 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
293 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; | 294 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; |
294 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 295 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
295 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; | 296 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; |
296 | 297 |
297 private: | 298 private: |
298 enum { | 299 enum { |
299 kNoSaveLayer = -1, | 300 kNoSaveLayer = -1, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 fFirstSaveLayerStackLevel = kNoSaveLayer; | 565 fFirstSaveLayerStackLevel = kNoSaveLayer; |
565 } | 566 } |
566 | 567 |
567 this->INHERITED::willRestore(); | 568 this->INHERITED::willRestore(); |
568 } | 569 } |
569 | 570 |
570 bool SkGPipeCanvas::isDrawingToLayer() const { | 571 bool SkGPipeCanvas::isDrawingToLayer() const { |
571 return kNoSaveLayer != fFirstSaveLayerStackLevel; | 572 return kNoSaveLayer != fFirstSaveLayerStackLevel; |
572 } | 573 } |
573 | 574 |
574 bool SkGPipeCanvas::translate(SkScalar dx, SkScalar dy) { | 575 void SkGPipeCanvas::didTranslate(SkScalar dx, SkScalar dy) { |
575 if (dx || dy) { | 576 if (dx || dy) { |
576 NOTIFY_SETUP(this); | 577 NOTIFY_SETUP(this); |
577 if (this->needOpBytes(2 * sizeof(SkScalar))) { | 578 if (this->needOpBytes(2 * sizeof(SkScalar))) { |
578 this->writeOp(kTranslate_DrawOp); | 579 this->writeOp(kTranslate_DrawOp); |
579 fWriter.writeScalar(dx); | 580 fWriter.writeScalar(dx); |
580 fWriter.writeScalar(dy); | 581 fWriter.writeScalar(dy); |
581 } | 582 } |
582 } | 583 } |
583 return this->INHERITED::translate(dx, dy); | 584 this->INHERITED::didTranslate(dx, dy); |
584 } | 585 } |
585 | 586 |
586 bool SkGPipeCanvas::scale(SkScalar sx, SkScalar sy) { | 587 void SkGPipeCanvas::didScale(SkScalar sx, SkScalar sy) { |
587 if (sx || sy) { | 588 if (sx || sy) { |
588 NOTIFY_SETUP(this); | 589 NOTIFY_SETUP(this); |
589 if (this->needOpBytes(2 * sizeof(SkScalar))) { | 590 if (this->needOpBytes(2 * sizeof(SkScalar))) { |
590 this->writeOp(kScale_DrawOp); | 591 this->writeOp(kScale_DrawOp); |
591 fWriter.writeScalar(sx); | 592 fWriter.writeScalar(sx); |
592 fWriter.writeScalar(sy); | 593 fWriter.writeScalar(sy); |
593 } | 594 } |
594 } | 595 } |
595 return this->INHERITED::scale(sx, sy); | 596 this->INHERITED::didScale(sx, sy); |
596 } | 597 } |
597 | 598 |
598 bool SkGPipeCanvas::rotate(SkScalar degrees) { | 599 void SkGPipeCanvas::didRotate(SkScalar degrees) { |
599 if (degrees) { | 600 if (degrees) { |
600 NOTIFY_SETUP(this); | 601 NOTIFY_SETUP(this); |
601 if (this->needOpBytes(sizeof(SkScalar))) { | 602 if (this->needOpBytes(sizeof(SkScalar))) { |
602 this->writeOp(kRotate_DrawOp); | 603 this->writeOp(kRotate_DrawOp); |
603 fWriter.writeScalar(degrees); | 604 fWriter.writeScalar(degrees); |
604 } | 605 } |
605 } | 606 } |
606 return this->INHERITED::rotate(degrees); | 607 this->INHERITED::didRotate(degrees); |
607 } | 608 } |
608 | 609 |
609 bool SkGPipeCanvas::skew(SkScalar sx, SkScalar sy) { | 610 void SkGPipeCanvas::didSkew(SkScalar sx, SkScalar sy) { |
610 if (sx || sy) { | 611 if (sx || sy) { |
611 NOTIFY_SETUP(this); | 612 NOTIFY_SETUP(this); |
612 if (this->needOpBytes(2 * sizeof(SkScalar))) { | 613 if (this->needOpBytes(2 * sizeof(SkScalar))) { |
613 this->writeOp(kSkew_DrawOp); | 614 this->writeOp(kSkew_DrawOp); |
614 fWriter.writeScalar(sx); | 615 fWriter.writeScalar(sx); |
615 fWriter.writeScalar(sy); | 616 fWriter.writeScalar(sy); |
616 } | 617 } |
617 } | 618 } |
618 return this->INHERITED::skew(sx, sy); | 619 this->INHERITED::didSkew(sx, sy); |
619 } | 620 } |
620 | 621 |
621 bool SkGPipeCanvas::concat(const SkMatrix& matrix) { | 622 void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { |
622 if (!matrix.isIdentity()) { | 623 if (!matrix.isIdentity()) { |
623 NOTIFY_SETUP(this); | 624 NOTIFY_SETUP(this); |
624 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 625 if (this->needOpBytes(matrix.writeToMemory(NULL))) { |
625 this->writeOp(kConcat_DrawOp); | 626 this->writeOp(kConcat_DrawOp); |
626 fWriter.writeMatrix(matrix); | 627 fWriter.writeMatrix(matrix); |
627 } | 628 } |
628 } | 629 } |
629 return this->INHERITED::concat(matrix); | 630 this->INHERITED::didConcat(matrix); |
630 } | 631 } |
631 | 632 |
632 void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) { | 633 void SkGPipeCanvas::didSetMatrix(const SkMatrix& matrix) { |
633 NOTIFY_SETUP(this); | 634 NOTIFY_SETUP(this); |
634 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 635 if (this->needOpBytes(matrix.writeToMemory(NULL))) { |
635 this->writeOp(kSetMatrix_DrawOp); | 636 this->writeOp(kSetMatrix_DrawOp); |
636 fWriter.writeMatrix(matrix); | 637 fWriter.writeMatrix(matrix); |
637 } | 638 } |
638 this->INHERITED::setMatrix(matrix); | 639 this->INHERITED::didSetMatrix(matrix); |
639 } | 640 } |
640 | 641 |
641 void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, | 642 void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, |
642 ClipEdgeStyle edgeStyle) { | 643 ClipEdgeStyle edgeStyle) { |
643 NOTIFY_SETUP(this); | 644 NOTIFY_SETUP(this); |
644 if (this->needOpBytes(sizeof(SkRect))) { | 645 if (this->needOpBytes(sizeof(SkRect))) { |
645 unsigned flags = 0; | 646 unsigned flags = 0; |
646 if (kSoft_ClipEdgeStyle == edgeStyle) { | 647 if (kSoft_ClipEdgeStyle == edgeStyle) { |
647 flags = kClip_HasAntiAlias_DrawOpFlag; | 648 flags = kClip_HasAntiAlias_DrawOpFlag; |
648 } | 649 } |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 return fCanvas->shuttleBitmap(bitmap, slot); | 1258 return fCanvas->shuttleBitmap(bitmap, slot); |
1258 } | 1259 } |
1259 | 1260 |
1260 void BitmapShuttle::removeCanvas() { | 1261 void BitmapShuttle::removeCanvas() { |
1261 if (NULL == fCanvas) { | 1262 if (NULL == fCanvas) { |
1262 return; | 1263 return; |
1263 } | 1264 } |
1264 fCanvas->unref(); | 1265 fCanvas->unref(); |
1265 fCanvas = NULL; | 1266 fCanvas = NULL; |
1266 } | 1267 } |
OLD | NEW |