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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // SkImage. | 541 // SkImage. |
542 canvas.clear(SK_ColorWHITE); | 542 canvas.clear(SK_ColorWHITE); |
543 canvas.flush(); | 543 canvas.flush(); |
544 PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); | 544 PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); |
545 canvas.drawPaint(paint); | 545 canvas.drawPaint(paint); |
546 canvas.flush(); | 546 canvas.flush(); |
547 PixelPtr pixels5 = getSurfacePixelPtr(surface, useGpu); | 547 PixelPtr pixels5 = getSurfacePixelPtr(surface, useGpu); |
548 REPORTER_ASSERT(reporter, pixels4 == pixels5); | 548 REPORTER_ASSERT(reporter, pixels4 == pixels5); |
549 } | 549 } |
550 | 550 |
| 551 static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
r) { |
| 552 SkBitmap store; |
| 553 store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 554 store.allocPixels(); |
| 555 SkDevice device(store); |
| 556 NotificationCounter notificationCounter; |
| 557 SkDeferredCanvas canvas(&device); |
| 558 canvas.setNotificationClient(¬ificationCounter); |
| 559 SkAutoTUnref<SkDevice> secondaryDevice(canvas.createCompatibleDevice( |
| 560 SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque())); |
| 561 SkCanvas secondaryCanvas(secondaryDevice.get()); |
| 562 SkRect rect = SkRect::MakeWH(5, 5); |
| 563 SkPaint paint; |
| 564 // After spawning a compatible canvas: |
| 565 // 1) Verify that secondary canvas is usable and does not report to the noti
fication client. |
| 566 secondaryCanvas.drawRect(rect, paint); |
| 567 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); |
| 568 // 2) Verify that original canvas is usable and still reports to the notific
ation client. |
| 569 canvas.drawRect(rect, paint); |
| 570 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); |
| 571 } |
| 572 |
551 static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
actory) { | 573 static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
actory) { |
552 TestDeferredCanvasBitmapAccess(reporter); | 574 TestDeferredCanvasBitmapAccess(reporter); |
553 TestDeferredCanvasFlush(reporter); | 575 TestDeferredCanvasFlush(reporter); |
554 TestDeferredCanvasFreshFrame(reporter); | 576 TestDeferredCanvasFreshFrame(reporter); |
555 TestDeferredCanvasMemoryLimit(reporter); | 577 TestDeferredCanvasMemoryLimit(reporter); |
556 TestDeferredCanvasBitmapCaching(reporter); | 578 TestDeferredCanvasBitmapCaching(reporter); |
557 TestDeferredCanvasSkip(reporter); | 579 TestDeferredCanvasSkip(reporter); |
558 TestDeferredCanvasBitmapShaderNoLeak(reporter); | 580 TestDeferredCanvasBitmapShaderNoLeak(reporter); |
559 TestDeferredCanvasBitmapSizeThreshold(reporter); | 581 TestDeferredCanvasBitmapSizeThreshold(reporter); |
| 582 TestDeferredCanvasCreateCompatibleDevice(reporter); |
560 TestDeferredCanvasSurface(reporter, NULL); | 583 TestDeferredCanvasSurface(reporter, NULL); |
561 if (NULL != factory) { | 584 if (NULL != factory) { |
562 TestDeferredCanvasSurface(reporter, factory); | 585 TestDeferredCanvasSurface(reporter, factory); |
563 } | 586 } |
564 } | 587 } |
565 | 588 |
566 #include "TestClassDef.h" | 589 #include "TestClassDef.h" |
567 DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanva
s) | 590 DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanva
s) |
OLD | NEW |