Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: src/core/SkCanvas.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT, re-add SkBaseDevice::config & default parameter Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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
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
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
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 if (filter->filterImage(&proxy, src, *iter.fMatrix, &dst, &pos)) { 1002 if (filter->filterImage(&proxy, src, *iter.fMatrix, &dst, &pos)) {
1003 SkPaint tmpUnfiltered(*paint); 1003 SkPaint tmpUnfiltered(*paint);
1004 tmpUnfiltered.setImageFilter(NULL); 1004 tmpUnfiltered.setImageFilter(NULL);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 // but relaxing the test above triggers GM asserts in 1157 // but relaxing the test above triggers GM asserts in
1158 // SkRgnBuilder::blitH(). We need to investigate what's going on. 1158 // SkRgnBuilder::blitH(). We need to investigate what's going on.
1159 return currClip->setPath(devPath, currClip->bwRgn(), doAA); 1159 return currClip->setPath(devPath, currClip->bwRgn(), doAA);
1160 } else { 1160 } else {
1161 base.setRect(currClip->getBounds()); 1161 base.setRect(currClip->getBounds());
1162 SkRasterClip clip; 1162 SkRasterClip clip;
1163 clip.setPath(devPath, base, doAA); 1163 clip.setPath(devPath, base, doAA);
1164 return currClip->op(clip, op); 1164 return currClip->op(clip, op);
1165 } 1165 }
1166 } else { 1166 } else {
1167 const SkDevice* device = canvas->getDevice(); 1167 const SkBaseDevice* device = canvas->getDevice();
1168 if (!device) { 1168 if (!device) {
1169 return currClip->setEmpty(); 1169 return currClip->setEmpty();
1170 } 1170 }
1171 1171
1172 base.setRect(0, 0, device->width(), device->height()); 1172 base.setRect(0, 0, device->width(), device->height());
1173 1173
1174 if (SkRegion::kReplace_Op == op) { 1174 if (SkRegion::kReplace_Op == op) {
1175 return currClip->setPath(devPath, base, doAA); 1175 return currClip->setPath(devPath, base, doAA);
1176 } else { 1176 } else {
1177 SkRasterClip clip; 1177 SkRasterClip clip;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 // todo: signal fClipStack that we have a region, and therefore (I guess) 1351 // todo: signal fClipStack that we have a region, and therefore (I guess)
1352 // we have to ignore it, and use the region directly? 1352 // we have to ignore it, and use the region directly?
1353 fClipStack.clipDevRect(rgn.getBounds(), op); 1353 fClipStack.clipDevRect(rgn.getBounds(), op);
1354 1354
1355 return fMCRec->fRasterClip->op(rgn, op); 1355 return fMCRec->fRasterClip->op(rgn, op);
1356 } 1356 }
1357 1357
1358 #ifdef SK_DEBUG 1358 #ifdef SK_DEBUG
1359 void SkCanvas::validateClip() const { 1359 void SkCanvas::validateClip() const {
1360 // construct clipRgn from the clipstack 1360 // construct clipRgn from the clipstack
1361 const SkDevice* device = this->getDevice(); 1361 const SkBaseDevice* device = this->getDevice();
1362 if (!device) { 1362 if (!device) {
1363 SkASSERT(this->getTotalClip().isEmpty()); 1363 SkASSERT(this->getTotalClip().isEmpty());
1364 return; 1364 return;
1365 } 1365 }
1366 1366
1367 SkIRect ir; 1367 SkIRect ir;
1368 ir.set(0, 0, device->width(), device->height()); 1368 ir.set(0, 0, device->width(), device->height());
1369 SkRasterClip tmpClip(ir); 1369 SkRasterClip tmpClip(ir);
1370 1370
1371 SkClipStack::B2TIter iter(fClipStack); 1371 SkClipStack::B2TIter iter(fClipStack);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 SkCanvas::ClipType SkCanvas::getClipType() const { 1536 SkCanvas::ClipType SkCanvas::getClipType() const {
1537 if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType; 1537 if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType;
1538 if (fMCRec->fRasterClip->isRect()) return kRect_ClipType; 1538 if (fMCRec->fRasterClip->isRect()) return kRect_ClipType;
1539 return kComplex_ClipType; 1539 return kComplex_ClipType;
1540 } 1540 }
1541 1541
1542 const SkRegion& SkCanvas::getTotalClip() const { 1542 const SkRegion& SkCanvas::getTotalClip() const {
1543 return fMCRec->fRasterClip->forceGetBW(); 1543 return fMCRec->fRasterClip->forceGetBW();
1544 } 1544 }
1545 1545
1546 SkDevice* SkCanvas::createLayerDevice(SkBitmap::Config config, 1546 SkBaseDevice* SkCanvas::createLayerDevice(SkBitmap::Config config,
1547 int width, int height, 1547 int width, int height,
1548 bool isOpaque) { 1548 bool isOpaque) {
1549 SkDevice* device = this->getTopDevice(); 1549 SkBaseDevice* device = this->getTopDevice();
1550 if (device) { 1550 if (device) {
1551 return device->createCompatibleDeviceForSaveLayer(config, width, height, 1551 return device->createCompatibleDeviceForSaveLayer(config, width, height,
1552 isOpaque); 1552 isOpaque);
1553 } else { 1553 } else {
1554 return NULL; 1554 return NULL;
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 SkDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config, 1558 SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
1559 int width, int height, 1559 int width, int height,
1560 bool isOpaque) { 1560 bool isOpaque) {
1561 SkDevice* device = this->getDevice(); 1561 SkBaseDevice* device = this->getDevice();
1562 if (device) { 1562 if (device) {
1563 return device->createCompatibleDevice(config, width, height, isOpaque); 1563 return device->createCompatibleDevice(config, width, height, isOpaque);
1564 } else { 1564 } else {
1565 return NULL; 1565 return NULL;
1566 } 1566 }
1567 } 1567 }
1568 1568
1569 1569
1570 ////////////////////////////////////////////////////////////////////////////// 1570 //////////////////////////////////////////////////////////////////////////////
1571 // These are the virtual drawing methods 1571 // These are the virtual drawing methods
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 1867 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
1868 const SkRect& dst, const SkPaint* paint) { 1868 const SkRect& dst, const SkPaint* paint) {
1869 SkDEBUGCODE(bitmap.validate();) 1869 SkDEBUGCODE(bitmap.validate();)
1870 1870
1871 // Need a device entry-point, so gpu can use a mesh 1871 // Need a device entry-point, so gpu can use a mesh
1872 this->internalDrawBitmapNine(bitmap, center, dst, paint); 1872 this->internalDrawBitmapNine(bitmap, center, dst, paint);
1873 } 1873 }
1874 1874
1875 class SkDeviceFilteredPaint { 1875 class SkDeviceFilteredPaint {
1876 public: 1876 public:
1877 SkDeviceFilteredPaint(SkDevice* device, const SkPaint& paint) { 1877 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) {
1878 SkDevice::TextFlags flags; 1878 SkBaseDevice::TextFlags flags;
1879 if (device->filterTextFlags(paint, &flags)) { 1879 if (device->filterTextFlags(paint, &flags)) {
1880 SkPaint* newPaint = fLazy.set(paint); 1880 SkPaint* newPaint = fLazy.set(paint);
1881 newPaint->setFlags(flags.fFlags); 1881 newPaint->setFlags(flags.fFlags);
1882 newPaint->setHinting(flags.fHinting); 1882 newPaint->setHinting(flags.fHinting);
1883 fPaint = newPaint; 1883 fPaint = newPaint;
1884 } else { 1884 } else {
1885 fPaint = &paint; 1885 fPaint = &paint;
1886 } 1886 }
1887 } 1887 }
1888 1888
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 } 2196 }
2197 2197
2198 SkCanvas::LayerIter::~LayerIter() { 2198 SkCanvas::LayerIter::~LayerIter() {
2199 fImpl->~SkDrawIter(); 2199 fImpl->~SkDrawIter();
2200 } 2200 }
2201 2201
2202 void SkCanvas::LayerIter::next() { 2202 void SkCanvas::LayerIter::next() {
2203 fDone = !fImpl->next(); 2203 fDone = !fImpl->next();
2204 } 2204 }
2205 2205
2206 SkDevice* SkCanvas::LayerIter::device() const { 2206 SkBaseDevice* SkCanvas::LayerIter::device() const {
2207 return fImpl->getDevice(); 2207 return fImpl->getDevice();
2208 } 2208 }
2209 2209
2210 const SkMatrix& SkCanvas::LayerIter::matrix() const { 2210 const SkMatrix& SkCanvas::LayerIter::matrix() const {
2211 return fImpl->getMatrix(); 2211 return fImpl->getMatrix();
2212 } 2212 }
2213 2213
2214 const SkPaint& SkCanvas::LayerIter::paint() const { 2214 const SkPaint& SkCanvas::LayerIter::paint() const {
2215 const SkPaint* paint = fImpl->getPaint(); 2215 const SkPaint* paint = fImpl->getPaint();
2216 if (NULL == paint) { 2216 if (NULL == paint) {
2217 paint = &fDefaultPaint; 2217 paint = &fDefaultPaint;
2218 } 2218 }
2219 return *paint; 2219 return *paint;
2220 } 2220 }
2221 2221
2222 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2222 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2223 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2223 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2224 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2224 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2225 2225
2226 /////////////////////////////////////////////////////////////////////////////// 2226 ///////////////////////////////////////////////////////////////////////////////
2227 2227
2228 SkCanvas::ClipVisitor::~ClipVisitor() { } 2228 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW
« include/core/SkDevice.h ('K') | « src/core/SkBBoxRecord.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698