remove dead code from sample
TBR= Author: reed@google.com Review URL: https://codereview.chromium.org/393063002
This commit is contained in:
parent
0847059fcf
commit
285d375508
@ -63,74 +63,6 @@ static void test_breakText() {
|
||||
SkASSERT(mm == width);
|
||||
}
|
||||
|
||||
static SkRandom gRand;
|
||||
|
||||
class SkPowerMode : public SkXfermode {
|
||||
public:
|
||||
SkPowerMode(SkScalar exponent) { this->init(exponent); }
|
||||
|
||||
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const SK_OVERRIDE;
|
||||
|
||||
typedef SkFlattenable* (*Factory)(SkReadBuffer&);
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPowerMode)
|
||||
|
||||
private:
|
||||
SkScalar fExp; // user's value
|
||||
uint8_t fTable[256]; // cache
|
||||
|
||||
void init(SkScalar exponent);
|
||||
SkPowerMode(SkReadBuffer& b) : INHERITED(b) {
|
||||
// read the exponent
|
||||
this->init(SkFixedToScalar(b.readFixed()));
|
||||
}
|
||||
virtual void flatten(SkWriteBuffer& b) const SK_OVERRIDE {
|
||||
this->INHERITED::flatten(b);
|
||||
b.writeFixed(SkScalarToFixed(fExp));
|
||||
}
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
};
|
||||
|
||||
void SkPowerMode::init(SkScalar e) {
|
||||
fExp = e;
|
||||
float ee = SkScalarToFloat(e);
|
||||
|
||||
printf("------ %g\n", ee);
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float x = i / 255.f;
|
||||
// printf(" %d %g", i, x);
|
||||
x = powf(x, ee);
|
||||
// printf(" %g", x);
|
||||
int xx = SkScalarRoundToInt(x * 255);
|
||||
// printf(" %d\n", xx);
|
||||
fTable[i] = SkToU8(xx);
|
||||
}
|
||||
}
|
||||
|
||||
void SkPowerMode::xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const {
|
||||
for (int i = 0; i < count; i++) {
|
||||
SkPMColor c = src[i];
|
||||
int r = SkGetPackedR32(c);
|
||||
int g = SkGetPackedG32(c);
|
||||
int b = SkGetPackedB32(c);
|
||||
r = fTable[r];
|
||||
g = fTable[g];
|
||||
b = fTable[b];
|
||||
dst[i] = SkPack888ToRGB16(r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkPowerMode::toString(SkString* str) const {
|
||||
str->append("SkPowerMode: exponent ");
|
||||
str->appendScalar(fExp);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct {
|
||||
const char* fName;
|
||||
uint32_t fFlags;
|
||||
|
Loading…
Reference in New Issue
Block a user