| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 virtual int saveLayer(const SkRect* bounds, const SkPaint*, | 233 virtual int saveLayer(const SkRect* bounds, const SkPaint*, |
| 234 SaveFlags) SK_OVERRIDE; | 234 SaveFlags) SK_OVERRIDE; |
| 235 virtual void restore() SK_OVERRIDE; | 235 virtual void restore() SK_OVERRIDE; |
| 236 virtual bool isDrawingToLayer() const SK_OVERRIDE; | 236 virtual bool isDrawingToLayer() const SK_OVERRIDE; |
| 237 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE; | 237 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE; |
| 238 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE; | 238 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE; |
| 239 virtual bool rotate(SkScalar degrees) SK_OVERRIDE; | 239 virtual bool rotate(SkScalar degrees) SK_OVERRIDE; |
| 240 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; | 240 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; |
| 241 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; | 241 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; |
| 242 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; | 242 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; |
| 243 virtual bool clipRect(const SkRect&, SkRegion::Op op, bool doAntiAlias = fal
se) SK_OVERRIDE; | |
| 244 virtual bool clipRRect(const SkRRect&, SkRegion::Op op, bool doAntiAlias = f
alse) SK_OVERRIDE; | |
| 245 virtual bool clipPath(const SkPath& path, SkRegion::Op op, | |
| 246 bool doAntiAlias = false) SK_OVERRIDE; | |
| 247 virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE
; | |
| 248 virtual void clear(SkColor) SK_OVERRIDE; | 243 virtual void clear(SkColor) SK_OVERRIDE; |
| 249 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; | 244 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
| 250 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], | 245 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], |
| 251 const SkPaint&) SK_OVERRIDE; | 246 const SkPaint&) SK_OVERRIDE; |
| 252 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; | 247 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; |
| 253 virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; | 248 virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; |
| 254 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; | 249 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; |
| 255 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; | 250 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; |
| 256 virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, | 251 virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, |
| 257 const SkPaint*) SK_OVERRIDE; | 252 const SkPaint*) SK_OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 287 | 282 |
| 288 /** | 283 /** |
| 289 * Flatten an SkBitmap to send to the reader, where it will be referenced | 284 * Flatten an SkBitmap to send to the reader, where it will be referenced |
| 290 * according to slot. | 285 * according to slot. |
| 291 */ | 286 */ |
| 292 bool shuttleBitmap(const SkBitmap&, int32_t slot); | 287 bool shuttleBitmap(const SkBitmap&, int32_t slot); |
| 293 | 288 |
| 294 protected: | 289 protected: |
| 295 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; | 290 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; |
| 296 | 291 |
| 292 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 onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
| 295 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; |
| 296 |
| 297 private: | 297 private: |
| 298 enum { | 298 enum { |
| 299 kNoSaveLayer = -1, | 299 kNoSaveLayer = -1, |
| 300 }; | 300 }; |
| 301 SkNamedFactorySet* fFactorySet; | 301 SkNamedFactorySet* fFactorySet; |
| 302 int fFirstSaveLayerStackLevel; | 302 int fFirstSaveLayerStackLevel; |
| 303 SkBitmapHeap* fBitmapHeap; | 303 SkBitmapHeap* fBitmapHeap; |
| 304 SkGPipeController* fController; | 304 SkGPipeController* fController; |
| 305 SkWriter32& fWriter; | 305 SkWriter32& fWriter; |
| 306 size_t fBlockSize; // amount allocated for writer | 306 size_t fBlockSize; // amount allocated for writer |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 628 |
| 629 void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) { | 629 void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) { |
| 630 NOTIFY_SETUP(this); | 630 NOTIFY_SETUP(this); |
| 631 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 631 if (this->needOpBytes(matrix.writeToMemory(NULL))) { |
| 632 this->writeOp(kSetMatrix_DrawOp); | 632 this->writeOp(kSetMatrix_DrawOp); |
| 633 fWriter.writeMatrix(matrix); | 633 fWriter.writeMatrix(matrix); |
| 634 } | 634 } |
| 635 this->INHERITED::setMatrix(matrix); | 635 this->INHERITED::setMatrix(matrix); |
| 636 } | 636 } |
| 637 | 637 |
| 638 bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp, | 638 void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, |
| 639 bool doAntiAlias) { | 639 ClipEdgeStyle edgeStyle) { |
| 640 NOTIFY_SETUP(this); | 640 NOTIFY_SETUP(this); |
| 641 if (this->needOpBytes(sizeof(SkRect))) { | 641 if (this->needOpBytes(sizeof(SkRect))) { |
| 642 unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; | 642 unsigned flags = 0; |
| 643 if (kSoft_ClipEdgeStyle == edgeStyle) { |
| 644 flags = kClip_HasAntiAlias_DrawOpFlag; |
| 645 } |
| 643 this->writeOp(kClipRect_DrawOp, flags, rgnOp); | 646 this->writeOp(kClipRect_DrawOp, flags, rgnOp); |
| 644 fWriter.writeRect(rect); | 647 fWriter.writeRect(rect); |
| 645 } | 648 } |
| 646 return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias); | 649 this->INHERITED::onClipRect(rect, rgnOp, edgeStyle); |
| 647 } | 650 } |
| 648 | 651 |
| 649 bool SkGPipeCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, | 652 void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, |
| 650 bool doAntiAlias) { | 653 ClipEdgeStyle edgeStyle) { |
| 651 NOTIFY_SETUP(this); | 654 NOTIFY_SETUP(this); |
| 652 if (this->needOpBytes(kSizeOfFlatRRect)) { | 655 if (this->needOpBytes(kSizeOfFlatRRect)) { |
| 653 unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; | 656 unsigned flags = 0; |
| 657 if (kSoft_ClipEdgeStyle == edgeStyle) { |
| 658 flags = kClip_HasAntiAlias_DrawOpFlag; |
| 659 } |
| 654 this->writeOp(kClipRRect_DrawOp, flags, rgnOp); | 660 this->writeOp(kClipRRect_DrawOp, flags, rgnOp); |
| 655 fWriter.writeRRect(rrect); | 661 fWriter.writeRRect(rrect); |
| 656 } | 662 } |
| 657 return this->INHERITED::clipRRect(rrect, rgnOp, doAntiAlias); | 663 this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle); |
| 658 } | 664 } |
| 659 | 665 |
| 660 bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp, | 666 void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp, |
| 661 bool doAntiAlias) { | 667 ClipEdgeStyle edgeStyle) { |
| 662 NOTIFY_SETUP(this); | 668 NOTIFY_SETUP(this); |
| 663 if (this->needOpBytes(path.writeToMemory(NULL))) { | 669 if (this->needOpBytes(path.writeToMemory(NULL))) { |
| 664 unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; | 670 unsigned flags = 0; |
| 671 if (kSoft_ClipEdgeStyle == edgeStyle) { |
| 672 flags = kClip_HasAntiAlias_DrawOpFlag; |
| 673 } |
| 665 this->writeOp(kClipPath_DrawOp, flags, rgnOp); | 674 this->writeOp(kClipPath_DrawOp, flags, rgnOp); |
| 666 fWriter.writePath(path); | 675 fWriter.writePath(path); |
| 667 } | 676 } |
| 668 // we just pass on the bounds of the path | 677 // we just pass on the bounds of the path |
| 669 return this->INHERITED::clipRect(path.getBounds(), rgnOp, doAntiAlias); | 678 this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle); |
| 670 } | 679 } |
| 671 | 680 |
| 672 bool SkGPipeCanvas::clipRegion(const SkRegion& region, SkRegion::Op rgnOp) { | 681 void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) { |
| 673 NOTIFY_SETUP(this); | 682 NOTIFY_SETUP(this); |
| 674 if (this->needOpBytes(region.writeToMemory(NULL))) { | 683 if (this->needOpBytes(region.writeToMemory(NULL))) { |
| 675 this->writeOp(kClipRegion_DrawOp, 0, rgnOp); | 684 this->writeOp(kClipRegion_DrawOp, 0, rgnOp); |
| 676 fWriter.writeRegion(region); | 685 fWriter.writeRegion(region); |
| 677 } | 686 } |
| 678 return this->INHERITED::clipRegion(region, rgnOp); | 687 this->INHERITED::onClipRegion(region, rgnOp); |
| 679 } | 688 } |
| 680 | 689 |
| 681 /////////////////////////////////////////////////////////////////////////////// | 690 /////////////////////////////////////////////////////////////////////////////// |
| 682 | 691 |
| 683 void SkGPipeCanvas::clear(SkColor color) { | 692 void SkGPipeCanvas::clear(SkColor color) { |
| 684 NOTIFY_SETUP(this); | 693 NOTIFY_SETUP(this); |
| 685 unsigned flags = 0; | 694 unsigned flags = 0; |
| 686 if (color) { | 695 if (color) { |
| 687 flags |= kClear_HasColor_DrawOpFlag; | 696 flags |= kClear_HasColor_DrawOpFlag; |
| 688 } | 697 } |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 return fCanvas->shuttleBitmap(bitmap, slot); | 1254 return fCanvas->shuttleBitmap(bitmap, slot); |
| 1246 } | 1255 } |
| 1247 | 1256 |
| 1248 void BitmapShuttle::removeCanvas() { | 1257 void BitmapShuttle::removeCanvas() { |
| 1249 if (NULL == fCanvas) { | 1258 if (NULL == fCanvas) { |
| 1250 return; | 1259 return; |
| 1251 } | 1260 } |
| 1252 fCanvas->unref(); | 1261 fCanvas->unref(); |
| 1253 fCanvas = NULL; | 1262 fCanvas = NULL; |
| 1254 } | 1263 } |
| OLD | NEW |