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

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

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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
« no previous file with comments | « src/core/SkBlitter_Sprite.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 * Remove the imagefilter and the xfermode from the paint that we (AutoDrawLooper) 477 * Remove the imagefilter and the xfermode from the paint that we (AutoDrawLooper)
478 * return (fPaint). We then draw the primitive (using srcover) into a cleared 478 * return (fPaint). We then draw the primitive (using srcover) into a cleared
479 * buffer/surface. 479 * buffer/surface.
480 * 3. Restore the layer created in #1 480 * 3. Restore the layer created in #1
481 * The imagefilter is passed the buffer/surface from the layer (now filled with the 481 * The imagefilter is passed the buffer/surface from the layer (now filled with the
482 * src pixels of the primitive). It returns a new "filtered" bu ffer, which we 482 * src pixels of the primitive). It returns a new "filtered" bu ffer, which we
483 * draw onto the previous layer using the xfermode from the ori ginal paint. 483 * draw onto the previous layer using the xfermode from the ori ginal paint.
484 */ 484 */
485 SkPaint tmp; 485 SkPaint tmp;
486 tmp.setImageFilter(fPaint->getImageFilter()); 486 tmp.setImageFilter(fPaint->getImageFilter());
487 tmp.setXfermode(sk_ref_sp(fPaint->getXfermode())); 487 tmp.setBlendMode(fPaint->getBlendMode());
488 SkRect storage; 488 SkRect storage;
489 if (rawBounds) { 489 if (rawBounds) {
490 // Make rawBounds include all paint outsets except for those due to image filters. 490 // Make rawBounds include all paint outsets except for those due to image filters.
491 rawBounds = &apply_paint_to_bounds_sans_imagefilter(*fPaint, *ra wBounds, &storage); 491 rawBounds = &apply_paint_to_bounds_sans_imagefilter(*fPaint, *ra wBounds, &storage);
492 } 492 }
493 (void)canvas->internalSaveLayer(SkCanvas::SaveLayerRec(rawBounds, &t mp), 493 (void)canvas->internalSaveLayer(SkCanvas::SaveLayerRec(rawBounds, &t mp),
494 SkCanvas::kFullLayer_SaveLayerStrate gy); 494 SkCanvas::kFullLayer_SaveLayerStrate gy);
495 fTempLayerForImageFilter = true; 495 fTempLayerForImageFilter = true;
496 // we remove the imagefilter/xfermode inside doNext() 496 // we remove the imagefilter/xfermode inside doNext()
497 } 497 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { 551 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
552 fPaint = nullptr; 552 fPaint = nullptr;
553 SkASSERT(!fIsSimple); 553 SkASSERT(!fIsSimple);
554 SkASSERT(fLooperContext || fFilter || fTempLayerForImageFilter); 554 SkASSERT(fLooperContext || fFilter || fTempLayerForImageFilter);
555 555
556 SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ? 556 SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ?
557 *fLazyPaintInit.get() : fOrigPaint) ; 557 *fLazyPaintInit.get() : fOrigPaint) ;
558 558
559 if (fTempLayerForImageFilter) { 559 if (fTempLayerForImageFilter) {
560 paint->setImageFilter(nullptr); 560 paint->setImageFilter(nullptr);
561 paint->setXfermode(nullptr); 561 paint->setBlendMode(SkBlendMode::kSrcOver);
562 } 562 }
563 563
564 if (fLooperContext && !fLooperContext->next(fCanvas, paint)) { 564 if (fLooperContext && !fLooperContext->next(fCanvas, paint)) {
565 fDone = true; 565 fDone = true;
566 return false; 566 return false;
567 } 567 }
568 if (fFilter) { 568 if (fFilter) {
569 if (!fFilter->filter(paint, drawType)) { 569 if (!fFilter->filter(paint, drawType)) {
570 fDone = true; 570 fDone = true;
571 return false; 571 return false;
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 } 2627 }
2628 2628
2629 void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, 2629 void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
2630 const char text[], size_t byteLength, 2630 const char text[], size_t byteLength,
2631 SkScalar x, SkScalar y) { 2631 SkScalar x, SkScalar y) {
2632 SkASSERT(byteLength == 0 || text != nullptr); 2632 SkASSERT(byteLength == 0 || text != nullptr);
2633 2633
2634 // nothing to draw 2634 // nothing to draw
2635 if (text == nullptr || byteLength == 0 || 2635 if (text == nullptr || byteLength == 0 ||
2636 draw.fRC->isEmpty() || 2636 draw.fRC->isEmpty() ||
2637 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { 2637 (paint.getAlpha() == 0 && paint.isSrcOver())) {
2638 return; 2638 return;
2639 } 2639 }
2640 2640
2641 SkScalar width = 0; 2641 SkScalar width = 0;
2642 SkPoint start; 2642 SkPoint start;
2643 2643
2644 start.set(0, 0); // to avoid warning 2644 start.set(0, 0); // to avoid warning
2645 if (paint.getFlags() & (SkPaint::kUnderlineText_Flag | 2645 if (paint.getFlags() & (SkPaint::kUnderlineText_Flag |
2646 SkPaint::kStrikeThruText_Flag)) { 2646 SkPaint::kStrikeThruText_Flag)) {
2647 width = paint.measureText(text, byteLength); 2647 width = paint.measureText(text, byteLength);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 iter.fDevice->drawAnnotation(iter, rect, key, value); 2931 iter.fDevice->drawAnnotation(iter, rect, key, value);
2932 } 2932 }
2933 LOOPER_END 2933 LOOPER_END
2934 } 2934 }
2935 2935
2936 ////////////////////////////////////////////////////////////////////////////// 2936 //////////////////////////////////////////////////////////////////////////////
2937 // These methods are NOT virtual, and therefore must call back into virtual 2937 // These methods are NOT virtual, and therefore must call back into virtual
2938 // methods, rather than actually drawing themselves. 2938 // methods, rather than actually drawing themselves.
2939 ////////////////////////////////////////////////////////////////////////////// 2939 //////////////////////////////////////////////////////////////////////////////
2940 2940
2941 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, 2941 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkBlendMode mode) {
2942 SkXfermode::Mode mode) {
2943 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawARGB()"); 2942 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawARGB()");
2944 SkPaint paint; 2943 SkPaint paint;
2945 2944
2946 paint.setARGB(a, r, g, b); 2945 paint.setARGB(a, r, g, b);
2947 if (SkXfermode::kSrcOver_Mode != mode) { 2946 paint.setBlendMode(mode);
2948 paint.setXfermodeMode(mode);
2949 }
2950 this->drawPaint(paint); 2947 this->drawPaint(paint);
2951 } 2948 }
2952 2949
2953 void SkCanvas::drawColor(SkColor c, SkXfermode::Mode mode) { 2950 void SkCanvas::drawColor(SkColor c, SkBlendMode mode) {
2954 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawColor()"); 2951 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawColor()");
2955 SkPaint paint; 2952 SkPaint paint;
2956 2953
2957 paint.setColor(c); 2954 paint.setColor(c);
2958 if (SkXfermode::kSrcOver_Mode != mode) { 2955 paint.setBlendMode(mode);
2959 paint.setXfermodeMode(mode);
2960 }
2961 this->drawPaint(paint); 2956 this->drawPaint(paint);
2962 } 2957 }
2963 2958
2964 void SkCanvas::drawPoint(SkScalar x, SkScalar y, const SkPaint& paint) { 2959 void SkCanvas::drawPoint(SkScalar x, SkScalar y, const SkPaint& paint) {
2965 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPoint(SkPaint)"); 2960 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPoint(SkPaint)");
2966 SkPoint pt; 2961 SkPoint pt;
2967 2962
2968 pt.set(x, y); 2963 pt.set(x, y);
2969 this->drawPoints(kPoints_PointMode, 1, &pt, paint); 2964 this->drawPoints(kPoints_PointMode, 1, &pt, paint);
2970 } 2965 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
3400 const SkCanvas::ClipOp SkCanvas::kXOR_Op; 3395 const SkCanvas::ClipOp SkCanvas::kXOR_Op;
3401 const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op; 3396 const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op;
3402 const SkCanvas::ClipOp SkCanvas::kReplace_Op; 3397 const SkCanvas::ClipOp SkCanvas::kReplace_Op;
3403 3398
3404 static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp , ""); 3399 static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp , "");
3405 static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp, ""); 3400 static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp, "");
3406 static_assert((int)SkRegion::kUnion_Op == (int)kUnion_SkClipOp, "") ; 3401 static_assert((int)SkRegion::kUnion_Op == (int)kUnion_SkClipOp, "") ;
3407 static_assert((int)SkRegion::kXOR_Op == (int)kXOR_SkClipOp, ""); 3402 static_assert((int)SkRegion::kXOR_Op == (int)kXOR_SkClipOp, "");
3408 static_assert((int)SkRegion::kReverseDifference_Op == (int)kReverseDifference_S kClipOp, ""); 3403 static_assert((int)SkRegion::kReverseDifference_Op == (int)kReverseDifference_S kClipOp, "");
3409 static_assert((int)SkRegion::kReplace_Op == (int)kReplace_SkClipOp, " "); 3404 static_assert((int)SkRegion::kReplace_Op == (int)kReplace_SkClipOp, " ");
OLDNEW
« no previous file with comments | « src/core/SkBlitter_Sprite.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698