Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Unified Diff: samplecode/SampleApp.cpp

Issue 355193006: stop calling SkCanvas::getDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard gpu code in no-gpu build Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | samplecode/SampleTextAlpha.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index df10b1e70bec2b31e31ed9d3fb6a8568a400ae37..8825f53e72d40fb02264dc40fdcf7ec528fe8a1c 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;
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | samplecode/SampleTextAlpha.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698