modify nothingToDraw to notice filters
This reverts commit c71ffd4e76
.
TBR=
Review URL: https://codereview.chromium.org/683003003
This commit is contained in:
parent
842ab70966
commit
f539b8cdee
@ -55,3 +55,6 @@ complexclip2_rect_aa
|
|||||||
complexclip2_rrect_aa
|
complexclip2_rrect_aa
|
||||||
convex_poly_clip
|
convex_poly_clip
|
||||||
verttext
|
verttext
|
||||||
|
|
||||||
|
#reed
|
||||||
|
modecolorfilters
|
||||||
|
@ -2377,6 +2377,18 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// return true if the filter exists, and may affect alpha
|
||||||
|
static bool affects_alpha(const SkColorFilter* cf) {
|
||||||
|
return cf && !(cf->getFlags() & SkColorFilter::kAlphaUnchanged_Flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return true if the filter exists, and may affect alpha
|
||||||
|
static bool affects_alpha(const SkImageFilter* imf) {
|
||||||
|
// TODO: check if we should allow imagefilters to broadcast that they don't affect alpha
|
||||||
|
// ala colorfilters
|
||||||
|
return imf != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool SkPaint::nothingToDraw() const {
|
bool SkPaint::nothingToDraw() const {
|
||||||
if (fLooper) {
|
if (fLooper) {
|
||||||
return false;
|
return false;
|
||||||
@ -2389,7 +2401,10 @@ bool SkPaint::nothingToDraw() const {
|
|||||||
case SkXfermode::kDstOut_Mode:
|
case SkXfermode::kDstOut_Mode:
|
||||||
case SkXfermode::kDstOver_Mode:
|
case SkXfermode::kDstOver_Mode:
|
||||||
case SkXfermode::kPlus_Mode:
|
case SkXfermode::kPlus_Mode:
|
||||||
return 0 == this->getAlpha();
|
if (0 == this->getAlpha()) {
|
||||||
|
return !affects_alpha(fColorFilter) && !affects_alpha(fImageFilter);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SkXfermode::kDst_Mode:
|
case SkXfermode::kDst_Mode:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -344,3 +344,30 @@ DEF_TEST(Paint_getHash, r) {
|
|||||||
paint.setHinting(SkPaint::kNormal_Hinting);
|
paint.setHinting(SkPaint::kNormal_Hinting);
|
||||||
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
|
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "SkColorMatrixFilter.h"
|
||||||
|
|
||||||
|
DEF_TEST(Paint_nothingToDraw, r) {
|
||||||
|
SkPaint paint;
|
||||||
|
|
||||||
|
REPORTER_ASSERT(r, !paint.nothingToDraw());
|
||||||
|
paint.setAlpha(0);
|
||||||
|
REPORTER_ASSERT(r, paint.nothingToDraw());
|
||||||
|
|
||||||
|
paint.setAlpha(0xFF);
|
||||||
|
paint.setXfermodeMode(SkXfermode::kDst_Mode);
|
||||||
|
REPORTER_ASSERT(r, paint.nothingToDraw());
|
||||||
|
|
||||||
|
paint.setAlpha(0);
|
||||||
|
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||||
|
|
||||||
|
SkColorMatrix cm;
|
||||||
|
cm.setIdentity(); // does not change alpha
|
||||||
|
paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
|
||||||
|
REPORTER_ASSERT(r, paint.nothingToDraw());
|
||||||
|
|
||||||
|
cm.postTranslate(0, 0, 0, 1); // wacks alpha
|
||||||
|
paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
|
||||||
|
REPORTER_ASSERT(r, !paint.nothingToDraw());
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user