aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-02-21 09:03:20 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-21 09:03:21 -0800
commitf7f79d2a6e669058ee9bb9fc4f0a9e998bfc5da6 (patch)
tree2d44005a24c4d23d578bff15a6e410b67f6cd2c6
parent7a048690d3cb6b3c1bdef594c3bd4b66f6b400c1 (diff)
remove dead code from sampleapp, trim bad asserts
BUG=skia: TBR= Review URL: https://codereview.chromium.org/948693002
-rw-r--r--samplecode/SampleApp.cpp146
-rw-r--r--samplecode/SampleApp.h1
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp4
3 files changed, 30 insertions, 121 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 2cad753817..17e8623d4f 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -77,8 +77,6 @@ public:
SkTCPServer gServer;
#endif
-#define USE_ARROWS_FOR_ZOOM true
-
#if SK_ANGLE
//#define DEFAULT_TO_ANGLE 1
#else
@@ -795,7 +793,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
#endif
fUseClip = false;
- fNClip = false;
fAnimating = false;
fRotate = false;
fPerspAnim = false;
@@ -904,7 +901,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
fSlideMenu = new SkOSMenu;
this->addMenu(fSlideMenu);
- this->setColorType(kN32_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
@@ -965,30 +961,11 @@ static SkBitmap capture_bitmap(SkCanvas* canvas) {
return bm;
}
-static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig,
- SkBitmap* diff) {
- SkBitmap src = capture_bitmap(canvas);
-
- SkAutoLockPixels alp0(src);
- SkAutoLockPixels alp1(orig);
- for (int y = 0; y < src.height(); y++) {
- const void* srcP = src.getAddr(0, y);
- const void* origP = orig.getAddr(0, y);
- size_t bytes = src.width() * src.bytesPerPixel();
- if (memcmp(srcP, origP, bytes)) {
- SkDebugf("---------- difference on line %d\n", y);
- return true;
- }
- }
- return false;
-}
-
-static void drawText(SkCanvas* canvas, SkString string, SkScalar left, SkScalar top, SkPaint& paint)
-{
+static void drawText(SkCanvas* canvas, SkString str, SkScalar left, SkScalar top, SkPaint& paint) {
SkColor desiredColor = paint.getColor();
paint.setColor(SK_ColorWHITE);
- const char* c_str = string.c_str();
- size_t size = string.size();
+ const char* c_str = str.c_str();
+ size_t size = str.size();
SkRect bounds;
paint.measureText(c_str, size, &bounds);
bounds.offset(left, top);
@@ -1017,70 +994,39 @@ void SampleWindow::draw(SkCanvas* canvas) {
fMeasureFPS_Time = 0;
}
- if (fNClip) {
- this->INHERITED::draw(canvas);
- SkBitmap orig = capture_bitmap(canvas);
+ SkSize tile = this->tileSize();
- const SkScalar w = this->width();
- const SkScalar h = this->height();
- const SkScalar cw = w / XCLIP_N;
- const SkScalar ch = h / YCLIP_N;
- for (int y = 0; y < YCLIP_N; y++) {
- SkRect r;
- r.fTop = y * ch;
- r.fBottom = (y + 1) * ch;
- if (y == YCLIP_N - 1) {
- r.fBottom = h;
- }
- for (int x = 0; x < XCLIP_N; x++) {
- SkAutoCanvasRestore acr(canvas, true);
- r.fLeft = x * cw;
- r.fRight = (x + 1) * cw;
- if (x == XCLIP_N - 1) {
- r.fRight = w;
- }
- canvas->clipRect(r);
- this->INHERITED::draw(canvas);
- }
- }
-
- SkBitmap diff;
- if (bitmap_diff(canvas, orig, &diff)) {
- }
+ if (kNo_Tiling == fTilingMode) {
+ this->INHERITED::draw(canvas); // no looping or surfaces needed
} else {
- SkSize tile = this->tileSize();
-
- if (kNo_Tiling == fTilingMode) {
- this->INHERITED::draw(canvas); // no looping or surfaces needed
- } else {
- const int w = SkScalarRoundToInt(tile.width());
- const int h = SkScalarRoundToInt(tile.height());
- SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
- SkCanvas* tileCanvas = surface->getCanvas();
-
- for (SkScalar y = 0; y < height(); y += tile.height()) {
- for (SkScalar x = 0; x < width(); x += tile.width()) {
- SkAutoCanvasRestore acr(tileCanvas, true);
- tileCanvas->translate(-x, -y);
- tileCanvas->clear(0);
- this->INHERITED::draw(tileCanvas);
- surface->draw(canvas, x, y, NULL);
- }
+ const int w = SkScalarRoundToInt(tile.width());
+ const int h = SkScalarRoundToInt(tile.height());
+ SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
+ SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ SkCanvas* tileCanvas = surface->getCanvas();
+
+ for (SkScalar y = 0; y < height(); y += tile.height()) {
+ for (SkScalar x = 0; x < width(); x += tile.width()) {
+ SkAutoCanvasRestore acr(tileCanvas, true);
+ tileCanvas->translate(-x, -y);
+ tileCanvas->clear(0);
+ this->INHERITED::draw(tileCanvas);
+ surface->draw(canvas, x, y, NULL);
}
+ }
- // for drawing the borders between tiles
- SkPaint paint;
- paint.setColor(0x60FF00FF);
- paint.setStyle(SkPaint::kStroke_Style);
+ // for drawing the borders between tiles
+ SkPaint paint;
+ paint.setColor(0x60FF00FF);
+ paint.setStyle(SkPaint::kStroke_Style);
- for (SkScalar y = 0; y < height(); y += tile.height()) {
- for (SkScalar x = 0; x < width(); x += tile.width()) {
- canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.height()), paint);
- }
+ for (SkScalar y = 0; y < height(); y += tile.height()) {
+ for (SkScalar x = 0; x < width(); x += tile.width()) {
+ canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.height()), paint);
}
}
}
+
if (fShowZoomer && !fSaveToPdf) {
showZoomer(canvas);
}
@@ -1396,20 +1342,6 @@ void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) {
canvas->setDrawFilter(NULL);
}
-static SkColorType gColorTypeCycle[] = {
- kUnknown_SkColorType, // none -> none
- kUnknown_SkColorType, // a8 -> none
- kN32_SkColorType, // 565 -> 8888
- kN32_SkColorType, // 4444 -> 8888
- kRGB_565_SkColorType, // 8888 -> 565
- kRGB_565_SkColorType, // 8888 -> 565
- kUnknown_SkColorType, // index8 -> none
-};
-
-static SkColorType cycle_colortypes(SkColorType c) {
- return gColorTypeCycle[c];
-}
-
void SampleWindow::changeZoomLevel(float delta) {
fZoomLevel += delta;
if (fZoomLevel > 0) {
@@ -1512,10 +1444,6 @@ bool SampleWindow::onEvent(const SkEvent& evt) {
}
return true;
}
- if (evt.isType("replace-transition-view")) {
- this->loadView((SkView*)SkEventSink::FindSink(evt.getFast32()));
- return true;
- }
if (evt.isType("set-curr-index")) {
this->goToSample(evt.getFast32());
return true;
@@ -1798,21 +1726,10 @@ bool SampleWindow::onHandleKey(SkKey key) {
}
return true;
case kUp_SkKey:
- if (USE_ARROWS_FOR_ZOOM) {
- this->changeZoomLevel(1.f / 32.f);
- } else {
- fNClip = !fNClip;
- this->inval(NULL);
- this->updateTitle();
- }
+ this->changeZoomLevel(1.f / 32.f);
return true;
case kDown_SkKey:
- if (USE_ARROWS_FOR_ZOOM) {
- this->changeZoomLevel(-1.f / 32.f);
- } else {
- this->setColorType(cycle_colortypes(this->getBitmap().colorType()));
- this->updateTitle();
- }
+ this->changeZoomLevel(-1.f / 32.f);
return true;
case kOK_SkKey: {
SkString title;
@@ -1979,9 +1896,6 @@ void SampleWindow::updateTitle() {
if (fRotate) {
title.prepend("<R> ");
}
- if (fNClip) {
- title.prepend("<C> ");
- }
if (fPerspAnim) {
title.prepend("<K> ");
}
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 4e2cb6fe48..2385fc010b 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -174,7 +174,6 @@ private:
SkAutoTUnref<SkDocument> fPDFDocument;
bool fUseClip;
- bool fNClip;
bool fAnimating;
bool fRotate;
bool fPerspAnim;
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 4b34755a85..eaac30cac3 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -291,10 +291,6 @@ void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
const Context&, SkBitmap* dst,
SkIPoint* offset) const {
- SkASSERT(src.colorType() == kN32_SkColorType);
- SkASSERT(fSrcRect.width() < src.width());
- SkASSERT(fSrcRect.height() < src.height());
-
if ((src.colorType() != kN32_SkColorType) ||
(fSrcRect.width() >= src.width()) ||
(fSrcRect.height() >= src.height())) {