OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapProcShader.h" | 10 #include "SkBitmapProcShader.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 REPORTER_ASSERT(reporter, image1->uniqueID() == image2->uniqueID()); | 520 REPORTER_ASSERT(reporter, image1->uniqueID() == image2->uniqueID()); |
521 // Now we obtain a snpshot via the deferred canvas, which triggers a flush. | 521 // Now we obtain a snpshot via the deferred canvas, which triggers a flush. |
522 // Because there is a pending clear, this will generate a different image. | 522 // Because there is a pending clear, this will generate a different image. |
523 SkImage* image3 = canvas.newImageSnapshot(); | 523 SkImage* image3 = canvas.newImageSnapshot(); |
524 SkAutoTUnref<SkImage> aur_i3(image3); | 524 SkAutoTUnref<SkImage> aur_i3(image3); |
525 REPORTER_ASSERT(reporter, image1->uniqueID() != image3->uniqueID()); | 525 REPORTER_ASSERT(reporter, image1->uniqueID() != image3->uniqueID()); |
526 // Verify that backing store is now a different buffer because of copy on | 526 // Verify that backing store is now a different buffer because of copy on |
527 // write | 527 // write |
528 PixelPtr pixels2 = getSurfacePixelPtr(surface, useGpu); | 528 PixelPtr pixels2 = getSurfacePixelPtr(surface, useGpu); |
529 REPORTER_ASSERT(reporter, pixels1 != pixels2); | 529 REPORTER_ASSERT(reporter, pixels1 != pixels2); |
530 canvas.clear(SK_ColorWHITE); | 530 // Verify copy-on write with a draw operation that gets deferred by |
531 canvas.flush(); | 531 // the in order draw buffer. |
| 532 SkPaint paint; |
| 533 canvas.drawPaint(paint); |
| 534 SkImage* image4 = canvas.newImageSnapshot(); // implicit flush |
| 535 SkAutoTUnref<SkImage> aur_i4(image4); |
| 536 REPORTER_ASSERT(reporter, image4->uniqueID() != image3->uniqueID()); |
532 PixelPtr pixels3 = getSurfacePixelPtr(surface, useGpu); | 537 PixelPtr pixels3 = getSurfacePixelPtr(surface, useGpu); |
| 538 REPORTER_ASSERT(reporter, pixels2 != pixels3); |
533 // Verify that a direct canvas flush with a pending draw does not trigger | 539 // Verify that a direct canvas flush with a pending draw does not trigger |
534 // a copy on write when the surface is not sharing its buffer with an | 540 // a copy on write when the surface is not sharing its buffer with an |
535 // SkImage. | 541 // SkImage. |
536 canvas.clear(SK_ColorBLACK); | 542 canvas.clear(SK_ColorWHITE); |
537 canvas.flush(); | 543 canvas.flush(); |
538 PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); | 544 PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); |
539 REPORTER_ASSERT(reporter, pixels3 == pixels4); | 545 canvas.drawPaint(paint); |
| 546 canvas.flush(); |
| 547 PixelPtr pixels5 = getSurfacePixelPtr(surface, useGpu); |
| 548 REPORTER_ASSERT(reporter, pixels4 == pixels5); |
540 } | 549 } |
541 | 550 |
542 static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
actory) { | 551 static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
actory) { |
543 TestDeferredCanvasBitmapAccess(reporter); | 552 TestDeferredCanvasBitmapAccess(reporter); |
544 TestDeferredCanvasFlush(reporter); | 553 TestDeferredCanvasFlush(reporter); |
545 TestDeferredCanvasFreshFrame(reporter); | 554 TestDeferredCanvasFreshFrame(reporter); |
546 TestDeferredCanvasMemoryLimit(reporter); | 555 TestDeferredCanvasMemoryLimit(reporter); |
547 TestDeferredCanvasBitmapCaching(reporter); | 556 TestDeferredCanvasBitmapCaching(reporter); |
548 TestDeferredCanvasSkip(reporter); | 557 TestDeferredCanvasSkip(reporter); |
549 TestDeferredCanvasBitmapShaderNoLeak(reporter); | 558 TestDeferredCanvasBitmapShaderNoLeak(reporter); |
550 TestDeferredCanvasBitmapSizeThreshold(reporter); | 559 TestDeferredCanvasBitmapSizeThreshold(reporter); |
551 TestDeferredCanvasSurface(reporter, NULL); | 560 TestDeferredCanvasSurface(reporter, NULL); |
552 if (NULL != factory) { | 561 if (NULL != factory) { |
553 TestDeferredCanvasSurface(reporter, factory); | 562 TestDeferredCanvasSurface(reporter, factory); |
554 } | 563 } |
555 } | 564 } |
556 | 565 |
557 #include "TestClassDef.h" | 566 #include "TestClassDef.h" |
558 DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanva
s) | 567 DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanva
s) |
OLD | NEW |