diff options
-rw-r--r-- | gm/surface.cpp | 40 | ||||
-rw-r--r-- | include/core/SkSurfaceProps.h | 6 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 24 |
3 files changed, 13 insertions, 57 deletions
diff --git a/gm/surface.cpp b/gm/surface.cpp index 6846f727e2..7c0b0c9d9f 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -21,17 +21,8 @@ static sk_sp<SkShader> make_shader() { return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode); } -static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo, - int disallowAA, int disallowDither) { - uint32_t flags = 0; - if (disallowAA) { - flags |= SkSurfaceProps::kDisallowAntiAlias_Flag; - } - if (disallowDither) { - flags |= SkSurfaceProps::kDisallowDither_Flag; - } - - SkSurfaceProps props(flags, geo); +static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo) { + SkSurfaceProps props(0, geo); if (ctx) { return SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props); } else { @@ -67,7 +58,7 @@ protected: } SkISize onISize() override { - return SkISize::Make(W * 4, H * 5); + return SkISize::Make(W, H * 5); } void onDraw(SkCanvas* canvas) override { @@ -89,23 +80,16 @@ protected: }; SkScalar x = 0; - for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { - for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { - SkScalar y = 0; - for (const auto& rec : recs) { - auto surface(make_surface(ctx, info, rec.fGeo, disallowAA, disallowDither)); - if (!surface) { - SkDebugf("failed to create surface! label: %s AA: %s dither: %s\n", - rec.fLabel, (disallowAA == 1 ? "disallowed" : "allowed"), - (disallowDither == 1 ? "disallowed" : "allowed")); - continue; - } - test_draw(surface->getCanvas(), rec.fLabel); - surface->draw(canvas, x, y, nullptr); - y += H; - } - x += W; + SkScalar y = 0; + for (const auto& rec : recs) { + auto surface(make_surface(ctx, info, rec.fGeo)); + if (!surface) { + SkDebugf("failed to create surface! label: %s", rec.fLabel); + continue; } + test_draw(surface->getCanvas(), rec.fLabel); + surface->draw(canvas, x, y, nullptr); + y += H; } } diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h index 735561f1dc..da04d1fe92 100644 --- a/include/core/SkSurfaceProps.h +++ b/include/core/SkSurfaceProps.h @@ -51,9 +51,7 @@ static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) { class SK_API SkSurfaceProps { public: enum Flags { - kDisallowAntiAlias_Flag = 1 << 0, - kDisallowDither_Flag = 1 << 1, - kUseDeviceIndependentFonts_Flag = 1 << 2, + kUseDeviceIndependentFonts_Flag = 1 << 0, }; /** Deprecated alias used by Chromium. Will be removed. */ static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag; @@ -70,8 +68,6 @@ public: uint32_t flags() const { return fFlags; } SkPixelGeometry pixelGeometry() const { return fPixelGeometry; } - bool isDisallowAA() const { return SkToBool(fFlags & kDisallowAntiAlias_Flag); } - bool isDisallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); } bool isUseDeviceIndependentFonts() const { return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag); } diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 539fd36028..09c50c69b0 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -175,19 +175,6 @@ void SkCanvas::predrawNotify(const SkRect* rect, const SkPaint* paint, /////////////////////////////////////////////////////////////////////////////// -static uint32_t filter_paint_flags(const SkSurfaceProps& props, uint32_t flags) { - const uint32_t propFlags = props.flags(); - if (propFlags & SkSurfaceProps::kDisallowDither_Flag) { - flags &= ~SkPaint::kDither_Flag; - } - if (propFlags & SkSurfaceProps::kDisallowAntiAlias_Flag) { - flags &= ~SkPaint::kAntiAlias_Flag; - } - return flags; -} - -/////////////////////////////////////////////////////////////////////////////// - /* This is the record we keep for each SkBaseDevice that the user installs. The clip/matrix/proc are fields that reflect the top of the save/restore stack. Whenever the canvas changes, it marks a dirty flag, and then before @@ -507,15 +494,6 @@ public: // can we be marked as simple? fIsSimple = !fFilter && !fTempLayerForImageFilter; } - - uint32_t oldFlags = paint.getFlags(); - fNewPaintFlags = filter_paint_flags(props, oldFlags); - if (fIsSimple && (fNewPaintFlags != oldFlags)) { - SkPaint* paint = set_if_needed(&fLazyPaintInit, fOrigPaint); - paint->setFlags(fNewPaintFlags); - fPaint = paint; - // if we're not simple, doNext() will take care of calling setFlags() - } } ~AutoDrawLooper() { @@ -549,7 +527,6 @@ private: SkDrawFilter* fFilter; const SkPaint* fPaint; int fSaveCount; - uint32_t fNewPaintFlags; bool fTempLayerForImageFilter; bool fDone; bool fIsSimple; @@ -566,7 +543,6 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ? *fLazyPaintInit.get() : fOrigPaint); - paint->setFlags(fNewPaintFlags); if (fTempLayerForImageFilter) { paint->setImageFilter(nullptr); |