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

Unified Diff: tests/DeferredCanvasTest.cpp

Issue 939103002: Do not playback existing commands for full deferred canvas writePixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 9 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 | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DeferredCanvasTest.cpp
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 6756f864674f258b9eb88f4a21bd52433b4e96b3..e83bc8106bbf74385e9d131713480155d9b82b0f 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -70,18 +70,25 @@ public:
void onCopyOnWrite(ContentChangeMode mode) SK_OVERRIDE {
if (mode == SkSurface::kDiscard_ContentChangeMode) {
- fDiscardCount++;
+ fCOWDiscardCount++;
} else {
- fRetainCount++;
+ fCOWRetainCount++;
}
}
+ void onDiscard() SK_OVERRIDE {
+ fDiscardCount++;
+ }
+
void clearCounts() {
+ fCOWDiscardCount = 0;
+ fCOWRetainCount = 0;
fDiscardCount = 0;
- fRetainCount = 0;
}
- int fDiscardCount, fRetainCount;
+ int fCOWDiscardCount;
+ int fCOWRetainCount;
+ int fDiscardCount;
SkBitmap fBitmap;
};
@@ -95,146 +102,173 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
// Tests below depend on this bitmap being recognized as opaque
// Preliminary sanity check: no copy on write if no active snapshot
+ // Discard notification happens on SkSurface::onDiscard, since no
+ // active snapshot.
surface->clearCounts();
canvas->clear(SK_ColorWHITE);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->flush();
- REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
// Case 1: Discard notification happens upon flushing
// with an Image attached.
surface->clearCounts();
SkAutoTUnref<SkImage> image1(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->clear(SK_ColorWHITE);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->flush();
- REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
// Case 2: Opaque writePixels
surface->clearCounts();
SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 3: writePixels that partially covers the canvas
surface->clearCounts();
SkAutoTUnref<SkImage> image3(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 4: unpremultiplied opaque writePixels that entirely
// covers the canvas
surface->clearCounts();
SkAutoTUnref<SkImage> image4(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->writePixels(srcBitmap, 0, 0);
- REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
surface->clearCounts();
canvas->flush();
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 5: unpremultiplied opaque writePixels that partially
// covers the canvas
surface->clearCounts();
SkAutoTUnref<SkImage> image5(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->writePixels(srcBitmap, 5, 0);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
surface->clearCounts();
canvas->flush();
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 6: unpremultiplied opaque writePixels that entirely
// covers the canvas, preceded by clear
surface->clearCounts();
SkAutoTUnref<SkImage> image6(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->clear(SK_ColorWHITE);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->writePixels(srcBitmap, 0, 0);
- REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
surface->clearCounts();
canvas->flush();
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 7: unpremultiplied opaque writePixels that partially
// covers the canvas, preceeded by a clear
surface->clearCounts();
SkAutoTUnref<SkImage> image7(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->clear(SK_ColorWHITE);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->writePixels(srcBitmap, 5, 0);
- REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); // because of the clear
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWDiscardCount); // because of the clear
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
surface->clearCounts();
canvas->flush();
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
// Case 8: unpremultiplied opaque writePixels that partially
// covers the canvas, preceeded by a drawREct that partially
// covers the canvas
surface->clearCounts();
SkAutoTUnref<SkImage> image8(canvas->newImageSnapshot());
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
SkPaint paint;
canvas->drawRect(SkRect::MakeLTRB(0, 0, 5, 5), paint);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
canvas->writePixels(srcBitmap, 5, 0);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 1 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
surface->clearCounts();
canvas->flush();
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWDiscardCount);
+ REPORTER_ASSERT(reporter, 0 == surface->fCOWRetainCount);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
- REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
}
static void TestDeferredCanvasFlush(skiatest::Reporter* reporter) {
« no previous file with comments | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698