aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gammatext.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-13 12:46:24 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 12:46:24 -0800
commit04f7e14b385118b8caa3ad7fcb30d64f4c32e677 (patch)
treead0797bfb42bb126d2d0ed91fc0b44abb16200d4 /gm/gammatext.cpp
parentf2950b1c4538fa638a594af6beacd3d1434eb74d (diff)
clean up dead code
Diffstat (limited to 'gm/gammatext.cpp')
-rw-r--r--gm/gammatext.cpp123
1 files changed, 9 insertions, 114 deletions
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp
index 54b0765783..b10bd1a111 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -12,12 +12,6 @@
#include "SkTypeface.h"
static SkShader* make_heatGradient(const SkPoint pts[2]) {
-#if 0 // UNUSED
- const SkColor colors[] = {
- SK_ColorBLACK, SK_ColorBLUE, SK_ColorCYAN, SK_ColorGREEN,
- SK_ColorYELLOW, SK_ColorRED, SK_ColorWHITE
- };
-#endif
const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };
return SkGradientShader::CreateLinear(pts, bw, NULL,
@@ -34,71 +28,6 @@ static bool setFont(SkPaint* paint, const char name[]) {
return false;
}
-#ifdef SK_BUILD_FOR_MAC
-#import <ApplicationServices/ApplicationServices.h>
-#define BITMAP_INFO_RGB (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host)
-
-static CGContextRef makeCG(const SkImageInfo& info, const void* addr,
- size_t rowBytes) {
- if (kN32_SkColorType != info.colorType() || NULL == addr) {
- return NULL;
- }
- CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
- CGContextRef cg = CGBitmapContextCreate((void*)addr, info.width(), info.height(),
- 8, rowBytes, space, BITMAP_INFO_RGB);
- CFRelease(space);
-
- CGContextSetAllowsFontSubpixelQuantization(cg, false);
- CGContextSetShouldSubpixelQuantizeFonts(cg, false);
-
- return cg;
-}
-
-extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face);
-
-static CGFontRef typefaceToCGFont(const SkTypeface* face) {
- if (NULL == face) {
- return 0;
- }
-
- CTFontRef ct = SkTypeface_GetCTFontRef(face);
- return CTFontCopyGraphicsFont(ct, NULL);
-}
-
-static void cgSetPaintForText(CGContextRef cg, const SkPaint& paint) {
- SkColor c = paint.getColor();
- CGFloat rgba[] = {
- SkColorGetB(c) / 255.0f,
- SkColorGetG(c) / 255.0f,
- SkColorGetR(c) / 255.0f,
- SkColorGetA(c) / 255.0f,
- };
- CGContextSetRGBFillColor(cg, rgba[0], rgba[1], rgba[2], rgba[3]);
-
- CGContextSetTextDrawingMode(cg, kCGTextFill);
- CGContextSetFont(cg, typefaceToCGFont(paint.getTypeface()));
- CGContextSetFontSize(cg, SkScalarToFloat(paint.getTextSize()));
-
- CGContextSetAllowsFontSubpixelPositioning(cg, paint.isSubpixelText());
- CGContextSetShouldSubpixelPositionFonts(cg, paint.isSubpixelText());
-
- CGContextSetShouldAntialias(cg, paint.isAntiAlias());
- CGContextSetShouldSmoothFonts(cg, paint.isLCDRenderText());
-}
-
-static void cgDrawText(CGContextRef cg, const void* text, size_t len,
- float x, float y, const SkPaint& paint) {
- if (cg) {
- cgSetPaintForText(cg, paint);
-
- uint16_t glyphs[200];
- int count = paint.textToGlyphs(text, len, glyphs);
-
- CGContextShowGlyphsAtPoint(cg, x, y, glyphs, count);
- }
-}
-#endif
-
/**
Test a set of clipping problems discovered while writing blitAntiRect,
and test all the code paths through the clipping blitters.
@@ -109,28 +38,18 @@ static void cgDrawText(CGContextRef cg, const void* text, size_t len,
#define HEIGHT 480
class GammaTextGM : public skiagm::GM {
-public:
- GammaTextGM() {
-
- }
-
protected:
- virtual SkString onShortName() {
+ SkString onShortName() SK_OVERRIDE {
return SkString("gammatext");
}
- virtual SkISize onISize() {
+ SkISize onISize() SK_OVERRIDE {
return SkISize::Make(1024, HEIGHT);
}
static void drawGrad(SkCanvas* canvas) {
SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } };
-#if 0
- const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
-#else
SkShader* s = make_heatGradient(pts);
-#endif
canvas->clear(SK_ColorRED);
SkPaint paint;
@@ -139,19 +58,7 @@ protected:
canvas->drawRect(r, paint);
}
- virtual void onDraw(SkCanvas* canvas) {
-#ifdef SK_BUILD_FOR_MAC
- CGContextRef cg = 0;
- {
- SkImageInfo info;
- size_t rowBytes;
- const void* addr = canvas->peekPixels(&info, &rowBytes);
- if (addr) {
- cg = makeCG(info, addr, rowBytes);
- }
- }
-#endif
-
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
drawGrad(canvas);
const SkColor fg[] = {
@@ -177,23 +84,11 @@ protected:
SkScalar y = SkIntToScalar(40);
SkScalar stopy = SkIntToScalar(HEIGHT);
while (y < stopy) {
- if (true) {
- canvas->drawText(text, len, x, y, paint);
- }
-#ifdef SK_BUILD_FOR_MAC
- else {
- cgDrawText(cg, text, len, SkScalarToFloat(x),
- static_cast<float>(HEIGHT) - SkScalarToFloat(y),
- paint);
- }
-#endif
+ canvas->drawText(text, len, x, y, paint);
y += paint.getTextSize() * 2;
}
x += SkIntToScalar(1024) / SK_ARRAY_COUNT(fg);
}
-#ifdef SK_BUILD_FOR_MAC
- CGContextRelease(cg);
-#endif
}
private:
@@ -242,28 +137,28 @@ public:
}
}
- virtual ~GammaShaderTextGM() {
+ virtual ~GammaShaderTextGM() SK_OVERRIDE {
for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) {
SkSafeUnref(fShaders[i]);
}
}
protected:
- virtual SkString onShortName() {
+ SkString onShortName() SK_OVERRIDE {
return SkString("gammagradienttext");
}
- virtual SkISize onISize() {
+ SkISize onISize() SK_OVERRIDE {
return SkISize::Make(300, 300);
}
- virtual void onOnceBeforeDraw() {
+ void onOnceBeforeDraw() SK_OVERRIDE {
for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) {
fShaders[i] = make_gradient(fColors[i]);
}
}
- virtual void onDraw(SkCanvas* canvas) {
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setAntiAlias(true);
paint.setLCDRenderText(true);