OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkBitmapDevice.h" |
11 #include "SkBounder.h" | 12 #include "SkBounder.h" |
12 #include "SkDevice.h" | |
13 #include "SkDeviceImageFilterProxy.h" | 13 #include "SkDeviceImageFilterProxy.h" |
14 #include "SkDraw.h" | 14 #include "SkDraw.h" |
15 #include "SkDrawFilter.h" | 15 #include "SkDrawFilter.h" |
16 #include "SkDrawLooper.h" | 16 #include "SkDrawLooper.h" |
17 #include "SkMetaData.h" | 17 #include "SkMetaData.h" |
18 #include "SkPathOps.h" | 18 #include "SkPathOps.h" |
19 #include "SkPicture.h" | 19 #include "SkPicture.h" |
20 #include "SkRasterClip.h" | 20 #include "SkRasterClip.h" |
21 #include "SkRRect.h" | 21 #include "SkRRect.h" |
22 #include "SkScalarCompare.h" | 22 #include "SkScalarCompare.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 typedef SkTLazy<SkPaint> SkLazyPaint; | 122 typedef SkTLazy<SkPaint> SkLazyPaint; |
123 | 123 |
124 void SkCanvas::predrawNotify() { | 124 void SkCanvas::predrawNotify() { |
125 if (fSurfaceBase) { | 125 if (fSurfaceBase) { |
126 fSurfaceBase->aboutToDraw(SkSurface::kRetain_ContentChangeMode); | 126 fSurfaceBase->aboutToDraw(SkSurface::kRetain_ContentChangeMode); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 /////////////////////////////////////////////////////////////////////////////// | 130 /////////////////////////////////////////////////////////////////////////////// |
131 | 131 |
132 /* This is the record we keep for each SkDevice that the user installs. | 132 /* This is the record we keep for each SkBaseDevice that the user installs. |
133 The clip/matrix/proc are fields that reflect the top of the save/restore | 133 The clip/matrix/proc are fields that reflect the top of the save/restore |
134 stack. Whenever the canvas changes, it marks a dirty flag, and then before | 134 stack. Whenever the canvas changes, it marks a dirty flag, and then before |
135 these are used (assuming we're not on a layer) we rebuild these cache | 135 these are used (assuming we're not on a layer) we rebuild these cache |
136 values: they reflect the top of the save stack, but translated and clipped | 136 values: they reflect the top of the save stack, but translated and clipped |
137 by the device's XY offset and bitmap-bounds. | 137 by the device's XY offset and bitmap-bounds. |
138 */ | 138 */ |
139 struct DeviceCM { | 139 struct DeviceCM { |
140 DeviceCM* fNext; | 140 DeviceCM* fNext; |
141 SkDevice* fDevice; | 141 SkBaseDevice* fDevice; |
142 SkRasterClip fClip; | 142 SkRasterClip fClip; |
143 const SkMatrix* fMatrix; | 143 const SkMatrix* fMatrix; |
144 SkPaint* fPaint; // may be null (in the future) | 144 SkPaint* fPaint; // may be null (in the future) |
145 | 145 |
146 DeviceCM(SkDevice* device, int x, int y, const SkPaint* paint, SkCanvas* can
vas) | 146 DeviceCM(SkBaseDevice* device, int x, int y, const SkPaint* paint, SkCanvas*
canvas) |
147 : fNext(NULL) { | 147 : fNext(NULL) { |
148 if (NULL != device) { | 148 if (NULL != device) { |
149 device->ref(); | 149 device->ref(); |
150 device->onAttachToCanvas(canvas); | 150 device->onAttachToCanvas(canvas); |
151 } | 151 } |
152 fDevice = device; | 152 fDevice = device; |
153 fPaint = paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL; | 153 fPaint = paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL; |
154 } | 154 } |
155 | 155 |
156 ~DeviceCM() { | 156 ~DeviceCM() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (fBounder) { | 308 if (fBounder) { |
309 fBounder->setClip(fClip); | 309 fBounder->setClip(fClip); |
310 } | 310 } |
311 // fCurrLayer may be NULL now | 311 // fCurrLayer may be NULL now |
312 | 312 |
313 return true; | 313 return true; |
314 } | 314 } |
315 return false; | 315 return false; |
316 } | 316 } |
317 | 317 |
318 SkDevice* getDevice() const { return fDevice; } | 318 SkBaseDevice* getDevice() const { return fDevice; } |
319 int getX() const { return fDevice->getOrigin().x(); } | 319 int getX() const { return fDevice->getOrigin().x(); } |
320 int getY() const { return fDevice->getOrigin().y(); } | 320 int getY() const { return fDevice->getOrigin().y(); } |
321 const SkMatrix& getMatrix() const { return *fMatrix; } | 321 const SkMatrix& getMatrix() const { return *fMatrix; } |
322 const SkRegion& getClip() const { return *fClip; } | 322 const SkRegion& getClip() const { return *fClip; } |
323 const SkPaint* getPaint() const { return fPaint; } | 323 const SkPaint* getPaint() const { return fPaint; } |
324 | 324 |
325 private: | 325 private: |
326 SkCanvas* fCanvas; | 326 SkCanvas* fCanvas; |
327 const DeviceCM* fCurrLayer; | 327 const DeviceCM* fCurrLayer; |
328 const SkPaint* fPaint; // May be null. | 328 const SkPaint* fPaint; // May be null. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 this->predrawNotify(); \ | 475 this->predrawNotify(); \ |
476 AutoDrawLooper looper(this, paint); \ | 476 AutoDrawLooper looper(this, paint); \ |
477 while (looper.next(type)) { \ | 477 while (looper.next(type)) { \ |
478 SkAutoBounderCommit ac(fBounder); \ | 478 SkAutoBounderCommit ac(fBounder); \ |
479 SkDrawIter iter(this); | 479 SkDrawIter iter(this); |
480 | 480 |
481 #define LOOPER_END } | 481 #define LOOPER_END } |
482 | 482 |
483 //////////////////////////////////////////////////////////////////////////// | 483 //////////////////////////////////////////////////////////////////////////// |
484 | 484 |
485 SkDevice* SkCanvas::init(SkDevice* device) { | 485 SkBaseDevice* SkCanvas::init(SkBaseDevice* device) { |
486 fBounder = NULL; | 486 fBounder = NULL; |
487 fLocalBoundsCompareType.setEmpty(); | 487 fLocalBoundsCompareType.setEmpty(); |
488 fLocalBoundsCompareTypeDirty = true; | 488 fLocalBoundsCompareTypeDirty = true; |
489 fAllowSoftClip = true; | 489 fAllowSoftClip = true; |
490 fAllowSimplifyClip = false; | 490 fAllowSimplifyClip = false; |
491 fDeviceCMDirty = false; | 491 fDeviceCMDirty = false; |
492 fSaveLayerCount = 0; | 492 fSaveLayerCount = 0; |
493 fMetaData = NULL; | 493 fMetaData = NULL; |
494 | 494 |
495 fMCRec = (MCRec*)fMCStack.push_back(); | 495 fMCRec = (MCRec*)fMCStack.push_back(); |
496 new (fMCRec) MCRec(NULL, 0); | 496 new (fMCRec) MCRec(NULL, 0); |
497 | 497 |
498 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL)); | 498 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL)); |
499 fMCRec->fTopLayer = fMCRec->fLayer; | 499 fMCRec->fTopLayer = fMCRec->fLayer; |
500 fMCRec->fNext = NULL; | 500 fMCRec->fNext = NULL; |
501 | 501 |
502 fSurfaceBase = NULL; | 502 fSurfaceBase = NULL; |
503 | 503 |
504 return this->setDevice(device); | 504 return this->setDevice(device); |
505 } | 505 } |
506 | 506 |
507 SkCanvas::SkCanvas() | 507 SkCanvas::SkCanvas() |
508 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { | 508 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { |
509 inc_canvas(); | 509 inc_canvas(); |
510 | 510 |
511 this->init(NULL); | 511 this->init(NULL); |
512 } | 512 } |
513 | 513 |
514 SkCanvas::SkCanvas(SkDevice* device) | 514 SkCanvas::SkCanvas(SkBaseDevice* device) |
515 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { | 515 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { |
516 inc_canvas(); | 516 inc_canvas(); |
517 | 517 |
518 this->init(device); | 518 this->init(device); |
519 } | 519 } |
520 | 520 |
521 SkCanvas::SkCanvas(const SkBitmap& bitmap) | 521 SkCanvas::SkCanvas(const SkBitmap& bitmap) |
522 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { | 522 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { |
523 inc_canvas(); | 523 inc_canvas(); |
524 | 524 |
525 this->init(SkNEW_ARGS(SkDevice, (bitmap)))->unref(); | 525 this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)))->unref(); |
526 } | 526 } |
527 | 527 |
528 SkCanvas::~SkCanvas() { | 528 SkCanvas::~SkCanvas() { |
529 // free up the contents of our deque | 529 // free up the contents of our deque |
530 this->restoreToCount(1); // restore everything but the last | 530 this->restoreToCount(1); // restore everything but the last |
531 SkASSERT(0 == fSaveLayerCount); | 531 SkASSERT(0 == fSaveLayerCount); |
532 | 532 |
533 this->internalRestore(); // restore the last, since we're going away | 533 this->internalRestore(); // restore the last, since we're going away |
534 | 534 |
535 SkSafeUnref(fBounder); | 535 SkSafeUnref(fBounder); |
(...skipping 21 matching lines...) Expand all Loading... |
557 // can decide to just make it a field in the device (rather than a ptr) | 557 // can decide to just make it a field in the device (rather than a ptr) |
558 if (NULL == fMetaData) { | 558 if (NULL == fMetaData) { |
559 fMetaData = new SkMetaData; | 559 fMetaData = new SkMetaData; |
560 } | 560 } |
561 return *fMetaData; | 561 return *fMetaData; |
562 } | 562 } |
563 | 563 |
564 /////////////////////////////////////////////////////////////////////////////// | 564 /////////////////////////////////////////////////////////////////////////////// |
565 | 565 |
566 void SkCanvas::flush() { | 566 void SkCanvas::flush() { |
567 SkDevice* device = this->getDevice(); | 567 SkBaseDevice* device = this->getDevice(); |
568 if (device) { | 568 if (device) { |
569 device->flush(); | 569 device->flush(); |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
573 SkISize SkCanvas::getDeviceSize() const { | 573 SkISize SkCanvas::getDeviceSize() const { |
574 SkDevice* d = this->getDevice(); | 574 SkBaseDevice* d = this->getDevice(); |
575 return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0); | 575 return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0); |
576 } | 576 } |
577 | 577 |
578 SkDevice* SkCanvas::getDevice() const { | 578 SkBaseDevice* SkCanvas::getDevice() const { |
579 // return root device | 579 // return root device |
580 MCRec* rec = (MCRec*) fMCStack.front(); | 580 MCRec* rec = (MCRec*) fMCStack.front(); |
581 SkASSERT(rec && rec->fLayer); | 581 SkASSERT(rec && rec->fLayer); |
582 return rec->fLayer->fDevice; | 582 return rec->fLayer->fDevice; |
583 } | 583 } |
584 | 584 |
585 SkDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { | 585 SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { |
586 if (updateMatrixClip) { | 586 if (updateMatrixClip) { |
587 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); | 587 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); |
588 } | 588 } |
589 return fMCRec->fTopLayer->fDevice; | 589 return fMCRec->fTopLayer->fDevice; |
590 } | 590 } |
591 | 591 |
592 SkDevice* SkCanvas::setDevice(SkDevice* device) { | 592 SkBaseDevice* SkCanvas::setDevice(SkBaseDevice* device) { |
593 // return root device | 593 // return root device |
594 SkDeque::F2BIter iter(fMCStack); | 594 SkDeque::F2BIter iter(fMCStack); |
595 MCRec* rec = (MCRec*)iter.next(); | 595 MCRec* rec = (MCRec*)iter.next(); |
596 SkASSERT(rec && rec->fLayer); | 596 SkASSERT(rec && rec->fLayer); |
597 SkDevice* rootDevice = rec->fLayer->fDevice; | 597 SkBaseDevice* rootDevice = rec->fLayer->fDevice; |
598 | 598 |
599 if (rootDevice == device) { | 599 if (rootDevice == device) { |
600 return device; | 600 return device; |
601 } | 601 } |
602 | 602 |
603 if (device) { | 603 if (device) { |
604 device->onAttachToCanvas(this); | 604 device->onAttachToCanvas(this); |
605 } | 605 } |
606 if (rootDevice) { | 606 if (rootDevice) { |
607 rootDevice->onDetachFromCanvas(); | 607 rootDevice->onDetachFromCanvas(); |
(...skipping 29 matching lines...) Expand all Loading... |
637 while ((rec = (MCRec*)iter.next()) != NULL) { | 637 while ((rec = (MCRec*)iter.next()) != NULL) { |
638 (void)rec->fRasterClip->op(bounds, SkRegion::kIntersect_Op); | 638 (void)rec->fRasterClip->op(bounds, SkRegion::kIntersect_Op); |
639 } | 639 } |
640 | 640 |
641 return device; | 641 return device; |
642 } | 642 } |
643 | 643 |
644 bool SkCanvas::readPixels(SkBitmap* bitmap, | 644 bool SkCanvas::readPixels(SkBitmap* bitmap, |
645 int x, int y, | 645 int x, int y, |
646 Config8888 config8888) { | 646 Config8888 config8888) { |
647 SkDevice* device = this->getDevice(); | 647 SkBaseDevice* device = this->getDevice(); |
648 if (!device) { | 648 if (!device) { |
649 return false; | 649 return false; |
650 } | 650 } |
651 return device->readPixels(bitmap, x, y, config8888); | 651 return device->readPixels(bitmap, x, y, config8888); |
652 } | 652 } |
653 | 653 |
654 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { | 654 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { |
655 SkDevice* device = this->getDevice(); | 655 SkBaseDevice* device = this->getDevice(); |
656 if (!device) { | 656 if (!device) { |
657 return false; | 657 return false; |
658 } | 658 } |
659 | 659 |
660 SkIRect bounds; | 660 SkIRect bounds; |
661 bounds.set(0, 0, device->width(), device->height()); | 661 bounds.set(0, 0, device->width(), device->height()); |
662 if (!bounds.intersect(srcRect)) { | 662 if (!bounds.intersect(srcRect)) { |
663 return false; | 663 return false; |
664 } | 664 } |
665 | 665 |
666 SkBitmap tmp; | 666 SkBitmap tmp; |
667 tmp.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), | 667 tmp.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), |
668 bounds.height()); | 668 bounds.height()); |
669 if (this->readPixels(&tmp, bounds.fLeft, bounds.fTop)) { | 669 if (this->readPixels(&tmp, bounds.fLeft, bounds.fTop)) { |
670 bitmap->swap(tmp); | 670 bitmap->swap(tmp); |
671 return true; | 671 return true; |
672 } else { | 672 } else { |
673 return false; | 673 return false; |
674 } | 674 } |
675 } | 675 } |
676 | 676 |
677 void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y, | 677 void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y, |
678 Config8888 config8888) { | 678 Config8888 config8888) { |
679 SkDevice* device = this->getDevice(); | 679 SkBaseDevice* device = this->getDevice(); |
680 if (device) { | 680 if (device) { |
681 if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()), | 681 if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()), |
682 SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.h
eight()))) { | 682 SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.h
eight()))) { |
683 device->accessBitmap(true); | 683 device->accessBitmap(true); |
684 device->writePixels(bitmap, x, y, config8888); | 684 device->writePixels(bitmap, x, y, config8888); |
685 } | 685 } |
686 } | 686 } |
687 } | 687 } |
688 | 688 |
689 SkCanvas* SkCanvas::canvasForDrawIter() { | 689 SkCanvas* SkCanvas::canvasForDrawIter() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 const SkIRect& bounds, | 741 const SkIRect& bounds, |
742 SkCanvas::SaveFlags flags, | 742 SkCanvas::SaveFlags flags, |
743 bool* isOpaque) { | 743 bool* isOpaque) { |
744 *isOpaque = (flags & SkCanvas::kHasAlphaLayer_SaveFlag) == 0; | 744 *isOpaque = (flags & SkCanvas::kHasAlphaLayer_SaveFlag) == 0; |
745 | 745 |
746 #if 0 | 746 #if 0 |
747 // loop through and union all the configs we may draw into | 747 // loop through and union all the configs we may draw into |
748 uint32_t configMask = 0; | 748 uint32_t configMask = 0; |
749 for (int i = canvas->countLayerDevices() - 1; i >= 0; --i) | 749 for (int i = canvas->countLayerDevices() - 1; i >= 0; --i) |
750 { | 750 { |
751 SkDevice* device = canvas->getLayerDevice(i); | 751 SkBaseDevice* device = canvas->getLayerDevice(i); |
752 if (device->intersects(bounds)) | 752 if (device->intersects(bounds)) |
753 configMask |= 1 << device->config(); | 753 configMask |= 1 << device->config(); |
754 } | 754 } |
755 | 755 |
756 // if the caller wants alpha or fullcolor, we can't return 565 | 756 // if the caller wants alpha or fullcolor, we can't return 565 |
757 if (flags & (SkCanvas::kFullColorLayer_SaveFlag | | 757 if (flags & (SkCanvas::kFullColorLayer_SaveFlag | |
758 SkCanvas::kHasAlphaLayer_SaveFlag)) | 758 SkCanvas::kHasAlphaLayer_SaveFlag)) |
759 configMask &= ~C16MASK; | 759 configMask &= ~C16MASK; |
760 | 760 |
761 switch (configMask) { | 761 switch (configMask) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 } | 842 } |
843 SkPaint* p = lazyP.set(*paint); | 843 SkPaint* p = lazyP.set(*paint); |
844 p->setImageFilter(NULL); | 844 p->setImageFilter(NULL); |
845 paint = p; | 845 paint = p; |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 bool isOpaque; | 849 bool isOpaque; |
850 SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque); | 850 SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque); |
851 | 851 |
852 SkDevice* device; | 852 SkBaseDevice* device; |
853 if (paint && paint->getImageFilter()) { | 853 if (paint && paint->getImageFilter()) { |
854 device = this->createCompatibleDevice(config, ir.width(), ir.height(), | 854 device = this->createCompatibleDevice(config, ir.width(), ir.height(), |
855 isOpaque); | 855 isOpaque); |
856 } else { | 856 } else { |
857 device = this->createLayerDevice(config, ir.width(), ir.height(), | 857 device = this->createLayerDevice(config, ir.width(), ir.height(), |
858 isOpaque); | 858 isOpaque); |
859 } | 859 } |
860 if (NULL == device) { | 860 if (NULL == device) { |
861 SkDebugf("Unable to create device for layer."); | 861 SkDebugf("Unable to create device for layer."); |
862 return count; | 862 return count; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 | 974 |
975 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type) | 975 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type) |
976 | 976 |
977 while (iter.next()) { | 977 while (iter.next()) { |
978 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint()); | 978 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint()); |
979 } | 979 } |
980 | 980 |
981 LOOPER_END | 981 LOOPER_END |
982 } | 982 } |
983 | 983 |
984 void SkCanvas::internalDrawDevice(SkDevice* srcDev, int x, int y, | 984 void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, |
985 const SkPaint* paint) { | 985 const SkPaint* paint) { |
986 SkPaint tmp; | 986 SkPaint tmp; |
987 if (NULL == paint) { | 987 if (NULL == paint) { |
988 tmp.setDither(true); | 988 tmp.setDither(true); |
989 paint = &tmp; | 989 paint = &tmp; |
990 } | 990 } |
991 | 991 |
992 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) | 992 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
993 while (iter.next()) { | 993 while (iter.next()) { |
994 SkDevice* dstDev = iter.fDevice; | 994 SkBaseDevice* dstDev = iter.fDevice; |
995 paint = &looper.paint(); | 995 paint = &looper.paint(); |
996 SkImageFilter* filter = paint->getImageFilter(); | 996 SkImageFilter* filter = paint->getImageFilter(); |
997 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 997 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
998 if (filter && !dstDev->canHandleImageFilter(filter)) { | 998 if (filter && !dstDev->canHandleImageFilter(filter)) { |
999 SkDeviceImageFilterProxy proxy(dstDev); | 999 SkDeviceImageFilterProxy proxy(dstDev); |
1000 SkBitmap dst; | 1000 SkBitmap dst; |
1001 const SkBitmap& src = srcDev->accessBitmap(false); | 1001 const SkBitmap& src = srcDev->accessBitmap(false); |
1002 SkMatrix matrix = *iter.fMatrix; | 1002 SkMatrix matrix = *iter.fMatrix; |
1003 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1003 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1004 if (filter->filterImage(&proxy, src, matrix, &dst, &pos)) { | 1004 if (filter->filterImage(&proxy, src, matrix, &dst, &pos)) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 // but relaxing the test above triggers GM asserts in | 1160 // but relaxing the test above triggers GM asserts in |
1161 // SkRgnBuilder::blitH(). We need to investigate what's going on. | 1161 // SkRgnBuilder::blitH(). We need to investigate what's going on. |
1162 return currClip->setPath(devPath, currClip->bwRgn(), doAA); | 1162 return currClip->setPath(devPath, currClip->bwRgn(), doAA); |
1163 } else { | 1163 } else { |
1164 base.setRect(currClip->getBounds()); | 1164 base.setRect(currClip->getBounds()); |
1165 SkRasterClip clip; | 1165 SkRasterClip clip; |
1166 clip.setPath(devPath, base, doAA); | 1166 clip.setPath(devPath, base, doAA); |
1167 return currClip->op(clip, op); | 1167 return currClip->op(clip, op); |
1168 } | 1168 } |
1169 } else { | 1169 } else { |
1170 const SkDevice* device = canvas->getDevice(); | 1170 const SkBaseDevice* device = canvas->getDevice(); |
1171 if (!device) { | 1171 if (!device) { |
1172 return currClip->setEmpty(); | 1172 return currClip->setEmpty(); |
1173 } | 1173 } |
1174 | 1174 |
1175 base.setRect(0, 0, device->width(), device->height()); | 1175 base.setRect(0, 0, device->width(), device->height()); |
1176 | 1176 |
1177 if (SkRegion::kReplace_Op == op) { | 1177 if (SkRegion::kReplace_Op == op) { |
1178 return currClip->setPath(devPath, base, doAA); | 1178 return currClip->setPath(devPath, base, doAA); |
1179 } else { | 1179 } else { |
1180 SkRasterClip clip; | 1180 SkRasterClip clip; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 // todo: signal fClipStack that we have a region, and therefore (I guess) | 1354 // todo: signal fClipStack that we have a region, and therefore (I guess) |
1355 // we have to ignore it, and use the region directly? | 1355 // we have to ignore it, and use the region directly? |
1356 fClipStack.clipDevRect(rgn.getBounds(), op); | 1356 fClipStack.clipDevRect(rgn.getBounds(), op); |
1357 | 1357 |
1358 return fMCRec->fRasterClip->op(rgn, op); | 1358 return fMCRec->fRasterClip->op(rgn, op); |
1359 } | 1359 } |
1360 | 1360 |
1361 #ifdef SK_DEBUG | 1361 #ifdef SK_DEBUG |
1362 void SkCanvas::validateClip() const { | 1362 void SkCanvas::validateClip() const { |
1363 // construct clipRgn from the clipstack | 1363 // construct clipRgn from the clipstack |
1364 const SkDevice* device = this->getDevice(); | 1364 const SkBaseDevice* device = this->getDevice(); |
1365 if (!device) { | 1365 if (!device) { |
1366 SkASSERT(this->getTotalClip().isEmpty()); | 1366 SkASSERT(this->getTotalClip().isEmpty()); |
1367 return; | 1367 return; |
1368 } | 1368 } |
1369 | 1369 |
1370 SkIRect ir; | 1370 SkIRect ir; |
1371 ir.set(0, 0, device->width(), device->height()); | 1371 ir.set(0, 0, device->width(), device->height()); |
1372 SkRasterClip tmpClip(ir); | 1372 SkRasterClip tmpClip(ir); |
1373 | 1373 |
1374 SkClipStack::B2TIter iter(fClipStack); | 1374 SkClipStack::B2TIter iter(fClipStack); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 SkCanvas::ClipType SkCanvas::getClipType() const { | 1539 SkCanvas::ClipType SkCanvas::getClipType() const { |
1540 if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType; | 1540 if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType; |
1541 if (fMCRec->fRasterClip->isRect()) return kRect_ClipType; | 1541 if (fMCRec->fRasterClip->isRect()) return kRect_ClipType; |
1542 return kComplex_ClipType; | 1542 return kComplex_ClipType; |
1543 } | 1543 } |
1544 | 1544 |
1545 const SkRegion& SkCanvas::getTotalClip() const { | 1545 const SkRegion& SkCanvas::getTotalClip() const { |
1546 return fMCRec->fRasterClip->forceGetBW(); | 1546 return fMCRec->fRasterClip->forceGetBW(); |
1547 } | 1547 } |
1548 | 1548 |
1549 SkDevice* SkCanvas::createLayerDevice(SkBitmap::Config config, | 1549 SkBaseDevice* SkCanvas::createLayerDevice(SkBitmap::Config config, |
1550 int width, int height, | 1550 int width, int height, |
1551 bool isOpaque) { | 1551 bool isOpaque) { |
1552 SkDevice* device = this->getTopDevice(); | 1552 SkBaseDevice* device = this->getTopDevice(); |
1553 if (device) { | 1553 if (device) { |
1554 return device->createCompatibleDeviceForSaveLayer(config, width, height, | 1554 return device->createCompatibleDeviceForSaveLayer(config, width, height, |
1555 isOpaque); | 1555 isOpaque); |
1556 } else { | 1556 } else { |
1557 return NULL; | 1557 return NULL; |
1558 } | 1558 } |
1559 } | 1559 } |
1560 | 1560 |
1561 SkDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config, | 1561 SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config, |
1562 int width, int height, | 1562 int width, int height, |
1563 bool isOpaque) { | 1563 bool isOpaque) { |
1564 SkDevice* device = this->getDevice(); | 1564 SkBaseDevice* device = this->getDevice(); |
1565 if (device) { | 1565 if (device) { |
1566 return device->createCompatibleDevice(config, width, height, isOpaque); | 1566 return device->createCompatibleDevice(config, width, height, isOpaque); |
1567 } else { | 1567 } else { |
1568 return NULL; | 1568 return NULL; |
1569 } | 1569 } |
1570 } | 1570 } |
1571 | 1571 |
1572 | 1572 |
1573 ////////////////////////////////////////////////////////////////////////////// | 1573 ////////////////////////////////////////////////////////////////////////////// |
1574 // These are the virtual drawing methods | 1574 // These are the virtual drawing methods |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 1870 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
1871 const SkRect& dst, const SkPaint* paint) { | 1871 const SkRect& dst, const SkPaint* paint) { |
1872 SkDEBUGCODE(bitmap.validate();) | 1872 SkDEBUGCODE(bitmap.validate();) |
1873 | 1873 |
1874 // Need a device entry-point, so gpu can use a mesh | 1874 // Need a device entry-point, so gpu can use a mesh |
1875 this->internalDrawBitmapNine(bitmap, center, dst, paint); | 1875 this->internalDrawBitmapNine(bitmap, center, dst, paint); |
1876 } | 1876 } |
1877 | 1877 |
1878 class SkDeviceFilteredPaint { | 1878 class SkDeviceFilteredPaint { |
1879 public: | 1879 public: |
1880 SkDeviceFilteredPaint(SkDevice* device, const SkPaint& paint) { | 1880 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { |
1881 SkDevice::TextFlags flags; | 1881 SkBaseDevice::TextFlags flags; |
1882 if (device->filterTextFlags(paint, &flags)) { | 1882 if (device->filterTextFlags(paint, &flags)) { |
1883 SkPaint* newPaint = fLazy.set(paint); | 1883 SkPaint* newPaint = fLazy.set(paint); |
1884 newPaint->setFlags(flags.fFlags); | 1884 newPaint->setFlags(flags.fFlags); |
1885 newPaint->setHinting(flags.fHinting); | 1885 newPaint->setHinting(flags.fHinting); |
1886 fPaint = newPaint; | 1886 fPaint = newPaint; |
1887 } else { | 1887 } else { |
1888 fPaint = &paint; | 1888 fPaint = &paint; |
1889 } | 1889 } |
1890 } | 1890 } |
1891 | 1891 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 } | 2199 } |
2200 | 2200 |
2201 SkCanvas::LayerIter::~LayerIter() { | 2201 SkCanvas::LayerIter::~LayerIter() { |
2202 fImpl->~SkDrawIter(); | 2202 fImpl->~SkDrawIter(); |
2203 } | 2203 } |
2204 | 2204 |
2205 void SkCanvas::LayerIter::next() { | 2205 void SkCanvas::LayerIter::next() { |
2206 fDone = !fImpl->next(); | 2206 fDone = !fImpl->next(); |
2207 } | 2207 } |
2208 | 2208 |
2209 SkDevice* SkCanvas::LayerIter::device() const { | 2209 SkBaseDevice* SkCanvas::LayerIter::device() const { |
2210 return fImpl->getDevice(); | 2210 return fImpl->getDevice(); |
2211 } | 2211 } |
2212 | 2212 |
2213 const SkMatrix& SkCanvas::LayerIter::matrix() const { | 2213 const SkMatrix& SkCanvas::LayerIter::matrix() const { |
2214 return fImpl->getMatrix(); | 2214 return fImpl->getMatrix(); |
2215 } | 2215 } |
2216 | 2216 |
2217 const SkPaint& SkCanvas::LayerIter::paint() const { | 2217 const SkPaint& SkCanvas::LayerIter::paint() const { |
2218 const SkPaint* paint = fImpl->getPaint(); | 2218 const SkPaint* paint = fImpl->getPaint(); |
2219 if (NULL == paint) { | 2219 if (NULL == paint) { |
2220 paint = &fDefaultPaint; | 2220 paint = &fDefaultPaint; |
2221 } | 2221 } |
2222 return *paint; | 2222 return *paint; |
2223 } | 2223 } |
2224 | 2224 |
2225 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2225 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2226 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2226 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2227 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2227 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2228 | 2228 |
2229 /////////////////////////////////////////////////////////////////////////////// | 2229 /////////////////////////////////////////////////////////////////////////////// |
2230 | 2230 |
2231 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2231 SkCanvas::ClipVisitor::~ClipVisitor() { } |
OLD | NEW |