Remove (now-dead) SK_LEGACY_SWEEP_GRADIENT code

Reland of https://skia-review.googlesource.com/c/17982

TBR=

Change-Id: If29d60d60a45562715fddfaff56b1e694be13034
Reviewed-on: https://skia-review.googlesource.com/24042
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2017-07-17 13:46:48 -04:00 committed by Skia Commit-Bot
parent ce5ee602ed
commit c2bd631c43
2 changed files with 1 additions and 77 deletions

View File

@ -8,9 +8,6 @@
#include "SkColorSpaceXformer.h"
#include "SkSweepGradient.h"
#include <algorithm>
#include <cmath>
#include "SkPM4fPriv.h"
#include "SkRasterPipeline.h"
@ -52,68 +49,6 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
buffer.writePoint(fCenter);
}
SkShaderBase::Context* SkSweepGradient::onMakeContext(
const ContextRec& rec, SkArenaAlloc* alloc) const
{
return CheckedMakeContext<SweepGradientContext>(alloc, *this, rec);
}
SkSweepGradient::SweepGradientContext::SweepGradientContext(
const SkSweepGradient& shader, const ContextRec& rec)
: INHERITED(shader, rec) {}
bool SkSweepGradient::onIsRasterPipelineOnly() const {
#ifdef SK_LEGACY_SWEEP_GRADIENT
return false;
#else
return true;
#endif
}
// returns angle in a circle [0..2PI) -> [0..255]
static unsigned SkATan2_255(float y, float x) {
// static const float g255Over2PI = 255 / (2 * SK_ScalarPI);
static const float g255Over2PI = 40.584510488433314f;
float result = sk_float_atan2(y, x);
if (!SkScalarIsFinite(result)) {
return 0;
}
if (result < 0) {
result += 2 * SK_ScalarPI;
}
SkASSERT(result >= 0);
// since our value is always >= 0, we can cast to int, which is faster than
// calling floorf()
int ir = (int)(result * g255Over2PI);
SkASSERT(ir >= 0 && ir <= 255);
return ir;
}
void SkSweepGradient::SweepGradientContext::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC,
int count) {
SkMatrix::MapXYProc proc = fDstToIndexProc;
const SkMatrix& matrix = fDstToIndex;
const SkPMColor* SK_RESTRICT cache = fCache->getCache32();
int toggle = init_dither_toggle(x, y);
SkPoint srcPt;
proc(matrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
SkScalar fx = srcPt.fX,
fy = srcPt.fY;
SkScalar dx = matrix.getScaleX(),
dy = matrix.getSkewY();
for (; count > 0; --count) {
*dstC++ = cache[toggle + SkATan2_255(fy, fx)];
fx += dx;
fy += dy;
toggle = next_dither_toggle(toggle);
}
}
/////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU

View File

@ -14,16 +14,6 @@ class SkSweepGradient final : public SkGradientShaderBase {
public:
SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor&);
class SweepGradientContext : public SkGradientShaderBase::GradientShaderBaseContext {
public:
SweepGradientContext(const SkSweepGradient& shader, const ContextRec&);
void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
private:
typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED;
};
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
@ -35,7 +25,6 @@ public:
protected:
void flatten(SkWriteBuffer& buffer) const override;
Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
bool adjustMatrixAndAppendStages(SkArenaAlloc* alloc,
@ -43,7 +32,7 @@ protected:
SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const override;
bool onIsRasterPipelineOnly() const override;
bool onIsRasterPipelineOnly() const override { return true; }
private:
const SkPoint fCenter;