diff options
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 39 | ||||
-rw-r--r-- | samplecode/SampleTextAlpha.cpp | 26 |
2 files changed, 8 insertions, 57 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index df10b1e70b..8825f53e72 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1007,7 +1007,7 @@ static SkBitmap capture_bitmap(SkCanvas* canvas) { static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig, SkBitmap* diff) { - const SkBitmap& src = canvas->getDevice()->accessBitmap(false); + SkBitmap src = capture_bitmap(canvas); SkAutoLockPixels alp0(src); SkAutoLockPixels alp1(orig); @@ -1282,7 +1282,7 @@ void SampleWindow::saveToPdf() SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) { if (fSaveToPdf) { - const SkBitmap& bmp = canvas->getDevice()->accessBitmap(false); + const SkBitmap bmp = capture_bitmap(canvas); SkISize size = SkISize::Make(bmp.width(), bmp.height()); SkPDFDevice* pdfDevice = new SkPDFDevice(size, size, canvas->getTotalMatrix()); @@ -1308,15 +1308,6 @@ SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) { return canvas; } -static void paint_rgn(const SkBitmap& bm, const SkIRect& r, - const SkRegion& rgn) { - SkCanvas canvas(bm); - SkRegion inval(rgn); - - inval.translate(r.fLeft, r.fTop); - canvas.clipRegion(inval); - canvas.drawColor(0xFFFF8080); -} #include "SkData.h" void SampleWindow::afterChildren(SkCanvas* orig) { if (fSaveToPdf) { @@ -1327,7 +1318,8 @@ void SampleWindow::afterChildren(SkCanvas* orig) { SkString name; name.printf("%s.pdf", this->getTitle()); SkPDFDocument doc; - SkPDFDevice* device = static_cast<SkPDFDevice*>(fPdfCanvas->getDevice()); + SkPDFDevice* device = NULL;//static_cast<SkPDFDevice*>(fPdfCanvas->getDevice()); + SkASSERT(false); doc.appendPage(device); #ifdef SK_BUILD_FOR_ANDROID name.prepend("/sdcard/"); @@ -1357,9 +1349,8 @@ void SampleWindow::afterChildren(SkCanvas* orig) { if (fRequestGrabImage) { fRequestGrabImage = false; - SkBaseDevice* device = orig->getDevice(); - SkBitmap bmp; - if (device->accessBitmap(false).copyTo(&bmp, kN32_SkColorType)) { + SkBitmap bmp = capture_bitmap(orig); + if (!bmp.isNull()) { static int gSampleGrabCounter; SkString name; name.printf("sample_grab_%d.png", gSampleGrabCounter++); @@ -1395,19 +1386,6 @@ void SampleWindow::afterChildren(SkCanvas* orig) { if (fMeasureFPS && fMeasureFPS_StartTime) { fMeasureFPS_Time += SkTime::GetMSecs() - fMeasureFPS_StartTime; } - - // if ((fScrollTestX | fScrollTestY) != 0) - if (false) { - const SkBitmap& bm = orig->getDevice()->accessBitmap(true); - int dx = fScrollTestX * 7; - int dy = fScrollTestY * 7; - SkIRect r; - SkRegion inval; - - r.set(50, 50, 50+100, 50+100); - bm.scrollRect(&r, dx, dy, &inval); - paint_rgn(bm, r, inval); - } } void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { @@ -2257,9 +2235,8 @@ void SampleView::draw(SkCanvas* canvas) { } else { SkGPipeWriter writer; SimplePC controller(canvas); - TiledPipeController tc(canvas->getDevice()->accessBitmap(false), - &SkImageDecoder::DecodeMemory, - &canvas->getTotalMatrix()); + SkBitmap bitmap = capture_bitmap(canvas); + TiledPipeController tc(bitmap, &SkImageDecoder::DecodeMemory, &canvas->getTotalMatrix()); SkGPipeController* pc; if (SkOSMenu::kMixedState == fPipeState) { pc = &tc; diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp index fcef92f315..3f4e0dbba9 100644 --- a/samplecode/SampleTextAlpha.cpp +++ b/samplecode/SampleTextAlpha.cpp @@ -28,22 +28,6 @@ #include "SkOSFile.h" #include "SkStream.h" -static void check_for_nonwhite(const SkBitmap& bm, int alpha) { - if (bm.colorType() != kRGB_565_SkColorType) { - return; - } - - for (int y = 0; y < bm.height(); y++) { - for (int x = 0; x < bm.width(); x++) { - uint16_t c = *bm.getAddr16(x, y); - if (c != 0xFFFF) { - SkDebugf("------ nonwhite alpha=%x [%d %d] %x\n", alpha, x, y, c); - return; - } - } - } -} - class TextAlphaView : public SampleView { public: TextAlphaView() { @@ -83,16 +67,6 @@ protected: canvas->drawText(str, strlen(str), x, y, paint); y += paint.getFontMetrics(NULL); } - if (false) { // avoid bit rot, suppress warning - check_for_nonwhite(canvas->getDevice()->accessBitmap(false), fByte); - SkDebugf("------ byte %x\n", fByte); - } - - if (false) { - fByte += 1; - fByte &= 0xFF; - this->inval(NULL); - } } virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERRIDE { |