| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); | 224 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); |
| 225 test_access_pixels(reporter, surface); | 225 test_access_pixels(reporter, surface); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 #endif | 228 #endif |
| 229 | 229 |
| 230 static void test_snapshot_alphatype(skiatest::Reporter* reporter, SkSurface* sur
face, | 230 static void test_snapshot_alphatype(skiatest::Reporter* reporter, SkSurface* sur
face, |
| 231 bool expectOpaque) { | 231 bool expectOpaque) { |
| 232 REPORTER_ASSERT(reporter, surface); | 232 REPORTER_ASSERT(reporter, surface); |
| 233 if (surface) { | 233 if (surface) { |
| 234 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 234 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 235 REPORTER_ASSERT(reporter, image); | 235 REPORTER_ASSERT(reporter, image); |
| 236 if (image) { | 236 if (image) { |
| 237 REPORTER_ASSERT(reporter, image->isOpaque() == SkToBool(expectOpaque
)); | 237 REPORTER_ASSERT(reporter, image->isOpaque() == SkToBool(expectOpaque
)); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 DEF_TEST(SurfaceSnapshotAlphaType, reporter) { | 241 DEF_TEST(SurfaceSnapshotAlphaType, reporter) { |
| 242 for (auto& surface_func : { &create_surface, &create_direct_surface }) { | 242 for (auto& surface_func : { &create_surface, &create_direct_surface }) { |
| 243 for (auto& isOpaque : { true, false }) { | 243 for (auto& isOpaque : { true, false }) { |
| 244 SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkA
lphaType; | 244 SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkA
lphaType; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 269 if (!s->getRenderTargetHandle(&result, a)) { | 269 if (!s->getRenderTargetHandle(&result, a)) { |
| 270 return 0; | 270 return 0; |
| 271 } | 271 } |
| 272 return result; | 272 return result; |
| 273 } | 273 } |
| 274 | 274 |
| 275 static void test_backend_handle_access_copy_on_write( | 275 static void test_backend_handle_access_copy_on_write( |
| 276 skiatest::Reporter* reporter, SkSurface* surface, SkSurface::BackendHandleAc
cess mode, | 276 skiatest::Reporter* reporter, SkSurface* surface, SkSurface::BackendHandleAc
cess mode, |
| 277 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { | 277 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { |
| 278 GrBackendObject obj1 = func(surface, mode); | 278 GrBackendObject obj1 = func(surface, mode); |
| 279 SkAutoTUnref<SkImage> snap1(surface->newImageSnapshot()); | 279 sk_sp<SkImage> snap1(surface->makeImageSnapshot()); |
| 280 | 280 |
| 281 GrBackendObject obj2 = func(surface, mode); | 281 GrBackendObject obj2 = func(surface, mode); |
| 282 SkAutoTUnref<SkImage> snap2(surface->newImageSnapshot()); | 282 sk_sp<SkImage> snap2(surface->makeImageSnapshot()); |
| 283 | 283 |
| 284 // If the access mode triggers CoW, then the backend objects should reflect
it. | 284 // If the access mode triggers CoW, then the backend objects should reflect
it. |
| 285 REPORTER_ASSERT(reporter, (obj1 == obj2) == (snap1 == snap2)); | 285 REPORTER_ASSERT(reporter, (obj1 == obj2) == (snap1 == snap2)); |
| 286 } | 286 } |
| 287 DEF_TEST(SurfaceBackendHandleAccessCopyOnWrite, reporter) { | 287 DEF_TEST(SurfaceBackendHandleAccessCopyOnWrite, reporter) { |
| 288 const SkSurface::BackendHandleAccess accessModes[] = { | 288 const SkSurface::BackendHandleAccess accessModes[] = { |
| 289 SkSurface::kFlushRead_BackendHandleAccess, | 289 SkSurface::kFlushRead_BackendHandleAccess, |
| 290 SkSurface::kFlushWrite_BackendHandleAccess, | 290 SkSurface::kFlushWrite_BackendHandleAccess, |
| 291 SkSurface::kDiscardWrite_BackendHandleAccess, | 291 SkSurface::kDiscardWrite_BackendHandleAccess, |
| 292 }; | 292 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 332 } |
| 333 | 333 |
| 334 static void test_unique_image_snap(skiatest::Reporter* reporter, SkSurface* surf
ace, | 334 static void test_unique_image_snap(skiatest::Reporter* reporter, SkSurface* surf
ace, |
| 335 bool surfaceIsDirect, | 335 bool surfaceIsDirect, |
| 336 std::function<intptr_t(SkImage*)> imageBackin
gStore, | 336 std::function<intptr_t(SkImage*)> imageBackin
gStore, |
| 337 std::function<intptr_t(SkSurface*)> surfaceBa
ckingStore) { | 337 std::function<intptr_t(SkSurface*)> surfaceBa
ckingStore) { |
| 338 std::function<intptr_t(SkImage*)> ibs = imageBackingStore; | 338 std::function<intptr_t(SkImage*)> ibs = imageBackingStore; |
| 339 std::function<intptr_t(SkSurface*)> sbs = surfaceBackingStore; | 339 std::function<intptr_t(SkSurface*)> sbs = surfaceBackingStore; |
| 340 static const SkBudgeted kB = SkBudgeted::kNo; | 340 static const SkBudgeted kB = SkBudgeted::kNo; |
| 341 { | 341 { |
| 342 SkAutoTUnref<SkImage> image(surface->newImageSnapshot(kB, SkSurface::kYe
s_ForceUnique)); | 342 sk_sp<SkImage> image(surface->makeImageSnapshot(kB, SkSurface::kYes_Forc
eUnique)); |
| 343 REPORTER_ASSERT(reporter, !same_image_surf(image, surface, ibs, sbs)); | 343 REPORTER_ASSERT(reporter, !same_image_surf(image.get(), surface, ibs, sb
s)); |
| 344 REPORTER_ASSERT(reporter, image->unique()); | 344 REPORTER_ASSERT(reporter, image->unique()); |
| 345 } | 345 } |
| 346 { | 346 { |
| 347 SkAutoTUnref<SkImage> image1(surface->newImageSnapshot(kB, SkSurface::kY
es_ForceUnique)); | 347 sk_sp<SkImage> image1(surface->makeImageSnapshot(kB, SkSurface::kYes_For
ceUnique)); |
| 348 REPORTER_ASSERT(reporter, !same_image_surf(image1, surface, ibs, sbs)); | 348 REPORTER_ASSERT(reporter, !same_image_surf(image1.get(), surface, ibs, s
bs)); |
| 349 REPORTER_ASSERT(reporter, image1->unique()); | 349 REPORTER_ASSERT(reporter, image1->unique()); |
| 350 SkAutoTUnref<SkImage> image2(surface->newImageSnapshot(kB, SkSurface::kY
es_ForceUnique)); | 350 sk_sp<SkImage> image2(surface->makeImageSnapshot(kB, SkSurface::kYes_For
ceUnique)); |
| 351 REPORTER_ASSERT(reporter, !same_image_surf(image2, surface, ibs, sbs)); | 351 REPORTER_ASSERT(reporter, !same_image_surf(image2.get(), surface, ibs, s
bs)); |
| 352 REPORTER_ASSERT(reporter, !same_image(image1, image2, ibs)); | 352 REPORTER_ASSERT(reporter, !same_image(image1.get(), image2.get(), ibs)); |
| 353 REPORTER_ASSERT(reporter, image2->unique()); | 353 REPORTER_ASSERT(reporter, image2->unique()); |
| 354 } | 354 } |
| 355 { | 355 { |
| 356 SkAutoTUnref<SkImage> image1(surface->newImageSnapshot(kB, SkSurface::kN
o_ForceUnique)); | 356 sk_sp<SkImage> image1(surface->makeImageSnapshot(kB, SkSurface::kNo_Forc
eUnique)); |
| 357 SkAutoTUnref<SkImage> image2(surface->newImageSnapshot(kB, SkSurface::kY
es_ForceUnique)); | 357 sk_sp<SkImage> image2(surface->makeImageSnapshot(kB, SkSurface::kYes_For
ceUnique)); |
| 358 SkAutoTUnref<SkImage> image3(surface->newImageSnapshot(kB, SkSurface::kN
o_ForceUnique)); | 358 sk_sp<SkImage> image3(surface->makeImageSnapshot(kB, SkSurface::kNo_Forc
eUnique)); |
| 359 SkAutoTUnref<SkImage> image4(surface->newImageSnapshot(kB, SkSurface::kY
es_ForceUnique)); | 359 sk_sp<SkImage> image4(surface->makeImageSnapshot(kB, SkSurface::kYes_For
ceUnique)); |
| 360 // Image 1 and 3 ought to be the same (or we're missing an optimization)
. | 360 // Image 1 and 3 ought to be the same (or we're missing an optimization)
. |
| 361 REPORTER_ASSERT(reporter, same_image(image1, image3, ibs)); | 361 REPORTER_ASSERT(reporter, same_image(image1.get(), image3.get(), ibs)); |
| 362 // If the surface is not direct then images 1 and 3 should alias the sur
face's | 362 // If the surface is not direct then images 1 and 3 should alias the sur
face's |
| 363 // store. | 363 // store. |
| 364 REPORTER_ASSERT(reporter, !surfaceIsDirect == same_image_surf(image1, su
rface, ibs, sbs)); | 364 REPORTER_ASSERT(reporter, !surfaceIsDirect == same_image_surf(image1.get
(), surface, ibs, sbs)); |
| 365 // Image 2 should not be shared with any other image. | 365 // Image 2 should not be shared with any other image. |
| 366 REPORTER_ASSERT(reporter, !same_image(image1, image2, ibs) && | 366 REPORTER_ASSERT(reporter, !same_image(image1.get(), image2.get(), ibs) &
& |
| 367 !same_image(image3, image2, ibs) && | 367 !same_image(image3.get(), image2.get(), ibs) &
& |
| 368 !same_image(image4, image2, ibs)); | 368 !same_image(image4.get(), image2.get(), ibs)); |
| 369 REPORTER_ASSERT(reporter, image2->unique()); | 369 REPORTER_ASSERT(reporter, image2->unique()); |
| 370 REPORTER_ASSERT(reporter, !same_image_surf(image2, surface, ibs, sbs)); | 370 REPORTER_ASSERT(reporter, !same_image_surf(image2.get(), surface, ibs, s
bs)); |
| 371 // Image 4 should not be shared with any other image. | 371 // Image 4 should not be shared with any other image. |
| 372 REPORTER_ASSERT(reporter, !same_image(image1, image4, ibs) && | 372 REPORTER_ASSERT(reporter, !same_image(image1.get(), image4.get(), ibs) &
& |
| 373 !same_image(image3, image4, ibs)); | 373 !same_image(image3.get(), image4.get(), ibs)); |
| 374 REPORTER_ASSERT(reporter, !same_image_surf(image4, surface, ibs, sbs)); | 374 REPORTER_ASSERT(reporter, !same_image_surf(image4.get(), surface, ibs, s
bs)); |
| 375 REPORTER_ASSERT(reporter, image4->unique()); | 375 REPORTER_ASSERT(reporter, image4->unique()); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 DEF_TEST(UniqueImageSnapshot, reporter) { | 379 DEF_TEST(UniqueImageSnapshot, reporter) { |
| 380 auto getImageBackingStore = [reporter](SkImage* image) { | 380 auto getImageBackingStore = [reporter](SkImage* image) { |
| 381 SkPixmap pm; | 381 SkPixmap pm; |
| 382 bool success = image->peekPixels(&pm); | 382 bool success = image->peekPixels(&pm); |
| 383 REPORTER_ASSERT(reporter, success); | 383 REPORTER_ASSERT(reporter, success); |
| 384 return reinterpret_cast<intptr_t>(pm.addr()); | 384 return reinterpret_cast<intptr_t>(pm.addr()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // May we (soon) eliminate the need to keep testing this, by hiding the bloody d
evice! | 448 // May we (soon) eliminate the need to keep testing this, by hiding the bloody d
evice! |
| 449 static uint32_t get_legacy_gen_id(SkSurface* surface) { | 449 static uint32_t get_legacy_gen_id(SkSurface* surface) { |
| 450 SkBaseDevice* device = | 450 SkBaseDevice* device = |
| 451 surface->getCanvas()->getDevice_just_for_deprecated_compatibility_te
sting(); | 451 surface->getCanvas()->getDevice_just_for_deprecated_compatibility_te
sting(); |
| 452 return device->accessBitmap(false).getGenerationID(); | 452 return device->accessBitmap(false).getGenerationID(); |
| 453 } | 453 } |
| 454 /* | 454 /* |
| 455 * Test legacy behavor of bumping the surface's device's bitmap's genID when we
access its | 455 * Test legacy behavor of bumping the surface's device's bitmap's genID when we
access its |
| 456 * texture handle for writing. | 456 * texture handle for writing. |
| 457 * | 457 * |
| 458 * Note: this needs to be tested separately from checking newImageSnapshot, as
calling that | 458 * Note: this needs to be tested separately from checking makeImageSnapshot, as
calling that |
| 459 * can also incidentally bump the genID (when a new backing surface is created)
. | 459 * can also incidentally bump the genID (when a new backing surface is created)
. |
| 460 */ | 460 */ |
| 461 static void test_backend_handle_gen_id( | 461 static void test_backend_handle_gen_id( |
| 462 skiatest::Reporter* reporter, SkSurface* surface, | 462 skiatest::Reporter* reporter, SkSurface* surface, |
| 463 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { | 463 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { |
| 464 const uint32_t gen0 = get_legacy_gen_id(surface); | 464 const uint32_t gen0 = get_legacy_gen_id(surface); |
| 465 func(surface, SkSurface::kFlushRead_BackendHandleAccess); | 465 func(surface, SkSurface::kFlushRead_BackendHandleAccess); |
| 466 const uint32_t gen1 = get_legacy_gen_id(surface); | 466 const uint32_t gen1 = get_legacy_gen_id(surface); |
| 467 REPORTER_ASSERT(reporter, gen0 == gen1); | 467 REPORTER_ASSERT(reporter, gen0 == gen1); |
| 468 | 468 |
| 469 func(surface, SkSurface::kFlushWrite_BackendHandleAccess); | 469 func(surface, SkSurface::kFlushWrite_BackendHandleAccess); |
| 470 const uint32_t gen2 = get_legacy_gen_id(surface); | 470 const uint32_t gen2 = get_legacy_gen_id(surface); |
| 471 REPORTER_ASSERT(reporter, gen0 != gen2); | 471 REPORTER_ASSERT(reporter, gen0 != gen2); |
| 472 | 472 |
| 473 func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); | 473 func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); |
| 474 const uint32_t gen3 = get_legacy_gen_id(surface); | 474 const uint32_t gen3 = get_legacy_gen_id(surface); |
| 475 REPORTER_ASSERT(reporter, gen0 != gen3); | 475 REPORTER_ASSERT(reporter, gen0 != gen3); |
| 476 REPORTER_ASSERT(reporter, gen2 != gen3); | 476 REPORTER_ASSERT(reporter, gen2 != gen3); |
| 477 } | 477 } |
| 478 static void test_backend_handle_unique_id( | 478 static void test_backend_handle_unique_id( |
| 479 skiatest::Reporter* reporter, SkSurface* surface, | 479 skiatest::Reporter* reporter, SkSurface* surface, |
| 480 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { | 480 GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { |
| 481 SkAutoTUnref<SkImage> image0(surface->newImageSnapshot()); | 481 sk_sp<SkImage> image0(surface->makeImageSnapshot()); |
| 482 GrBackendObject obj = func(surface, SkSurface::kFlushRead_BackendHandleAcces
s); | 482 GrBackendObject obj = func(surface, SkSurface::kFlushRead_BackendHandleAcces
s); |
| 483 REPORTER_ASSERT(reporter, obj != 0); | 483 REPORTER_ASSERT(reporter, obj != 0); |
| 484 SkAutoTUnref<SkImage> image1(surface->newImageSnapshot()); | 484 sk_sp<SkImage> image1(surface->makeImageSnapshot()); |
| 485 // just read access should not affect the snapshot | 485 // just read access should not affect the snapshot |
| 486 REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID()); | 486 REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID()); |
| 487 | 487 |
| 488 obj = func(surface, SkSurface::kFlushWrite_BackendHandleAccess); | 488 obj = func(surface, SkSurface::kFlushWrite_BackendHandleAccess); |
| 489 REPORTER_ASSERT(reporter, obj != 0); | 489 REPORTER_ASSERT(reporter, obj != 0); |
| 490 SkAutoTUnref<SkImage> image2(surface->newImageSnapshot()); | 490 sk_sp<SkImage> image2(surface->makeImageSnapshot()); |
| 491 // expect a new image, since we claimed we would write | 491 // expect a new image, since we claimed we would write |
| 492 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID()); | 492 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID()); |
| 493 | 493 |
| 494 obj = func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); | 494 obj = func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); |
| 495 REPORTER_ASSERT(reporter, obj != 0); | 495 REPORTER_ASSERT(reporter, obj != 0); |
| 496 SkAutoTUnref<SkImage> image3(surface->newImageSnapshot()); | 496 sk_sp<SkImage> image3(surface->makeImageSnapshot()); |
| 497 // expect a new(er) image, since we claimed we would write | 497 // expect a new(er) image, since we claimed we would write |
| 498 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID()); | 498 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID()); |
| 499 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID()); | 499 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID()); |
| 500 } | 500 } |
| 501 // No CPU test. | 501 // No CPU test. |
| 502 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter,
context) { | 502 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter,
context) { |
| 503 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { | 503 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { |
| 504 for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_h
andle_gen_id }) { | 504 for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_h
andle_gen_id }) { |
| 505 for (auto& handle_access_func : | 505 for (auto& handle_access_func : |
| 506 { &get_surface_backend_texture_handle, &get_surface_backend_rend
er_target_handle}) { | 506 { &get_surface_backend_texture_handle, &get_surface_backend_rend
er_target_handle}) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 { SkIntToScalar(5), SkIntToScalar(1) }, | 556 { SkIntToScalar(5), SkIntToScalar(1) }, |
| 557 { SkIntToScalar(6), SkIntToScalar(1) }, | 557 { SkIntToScalar(6), SkIntToScalar(1) }, |
| 558 { SkIntToScalar(7), SkIntToScalar(1) }, | 558 { SkIntToScalar(7), SkIntToScalar(1) }, |
| 559 { SkIntToScalar(8), SkIntToScalar(1) }, | 559 { SkIntToScalar(8), SkIntToScalar(1) }, |
| 560 { SkIntToScalar(9), SkIntToScalar(1) }, | 560 { SkIntToScalar(9), SkIntToScalar(1) }, |
| 561 { SkIntToScalar(10), SkIntToScalar(1) }, | 561 { SkIntToScalar(10), SkIntToScalar(1) }, |
| 562 }; | 562 }; |
| 563 | 563 |
| 564 #define EXPECT_COPY_ON_WRITE(command) \ | 564 #define EXPECT_COPY_ON_WRITE(command) \ |
| 565 { \ | 565 { \ |
| 566 SkImage* imageBefore = surface->newImageSnapshot(); \ | 566 sk_sp<SkImage> imageBefore = surface->makeImageSnapshot(); \ |
| 567 SkAutoTUnref<SkImage> aur_before(imageBefore); \ | 567 sk_sp<SkImage> aur_before(imageBefore); \ |
| 568 canvas-> command ; \ | 568 canvas-> command ; \ |
| 569 SkImage* imageAfter = surface->newImageSnapshot(); \ | 569 sk_sp<SkImage> imageAfter = surface->makeImageSnapshot(); \ |
| 570 SkAutoTUnref<SkImage> aur_after(imageAfter); \ | 570 sk_sp<SkImage> aur_after(imageAfter); \ |
| 571 REPORTER_ASSERT(reporter, imageBefore != imageAfter); \ | 571 REPORTER_ASSERT(reporter, imageBefore != imageAfter); \ |
| 572 } | 572 } |
| 573 | 573 |
| 574 EXPECT_COPY_ON_WRITE(clear(testColor)) | 574 EXPECT_COPY_ON_WRITE(clear(testColor)) |
| 575 EXPECT_COPY_ON_WRITE(drawPaint(testPaint)) | 575 EXPECT_COPY_ON_WRITE(drawPaint(testPaint)) |
| 576 EXPECT_COPY_ON_WRITE(drawPoints(SkCanvas::kPoints_PointMode, testPointCount,
testPoints, \ | 576 EXPECT_COPY_ON_WRITE(drawPoints(SkCanvas::kPoints_PointMode, testPointCount,
testPoints, \ |
| 577 testPaint)) | 577 testPaint)) |
| 578 EXPECT_COPY_ON_WRITE(drawOval(testRect, testPaint)) | 578 EXPECT_COPY_ON_WRITE(drawOval(testRect, testPaint)) |
| 579 EXPECT_COPY_ON_WRITE(drawRect(testRect, testPaint)) | 579 EXPECT_COPY_ON_WRITE(drawRect(testRect, testPaint)) |
| 580 EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint)) | 580 EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint)) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 601 } | 601 } |
| 602 #endif | 602 #endif |
| 603 | 603 |
| 604 static void test_writable_after_snapshot_release(skiatest::Reporter* reporter, | 604 static void test_writable_after_snapshot_release(skiatest::Reporter* reporter, |
| 605 SkSurface* surface) { | 605 SkSurface* surface) { |
| 606 // This test succeeds by not triggering an assertion. | 606 // This test succeeds by not triggering an assertion. |
| 607 // The test verifies that the surface remains writable (usable) after | 607 // The test verifies that the surface remains writable (usable) after |
| 608 // acquiring and releasing a snapshot without triggering a copy on write. | 608 // acquiring and releasing a snapshot without triggering a copy on write. |
| 609 SkCanvas* canvas = surface->getCanvas(); | 609 SkCanvas* canvas = surface->getCanvas(); |
| 610 canvas->clear(1); | 610 canvas->clear(1); |
| 611 surface->newImageSnapshot()->unref(); // Create and destroy SkImage | 611 surface->makeImageSnapshot(); // Create and destroy SkImage |
| 612 canvas->clear(2); // Must not assert internally | 612 canvas->clear(2); // Must not assert internally |
| 613 } | 613 } |
| 614 DEF_TEST(SurfaceWriteableAfterSnapshotRelease, reporter) { | 614 DEF_TEST(SurfaceWriteableAfterSnapshotRelease, reporter) { |
| 615 SkAutoTUnref<SkSurface> surface(create_surface()); | 615 SkAutoTUnref<SkSurface> surface(create_surface()); |
| 616 test_writable_after_snapshot_release(reporter, surface); | 616 test_writable_after_snapshot_release(reporter, surface); |
| 617 } | 617 } |
| 618 #if SK_SUPPORT_GPU | 618 #if SK_SUPPORT_GPU |
| 619 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWriteableAfterSnapshotRelease_Gpu, rep
orter, context) { | 619 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWriteableAfterSnapshotRelease_Gpu, rep
orter, context) { |
| 620 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { | 620 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { |
| 621 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); | 621 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); |
| 622 test_writable_after_snapshot_release(reporter, surface); | 622 test_writable_after_snapshot_release(reporter, surface); |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 #endif | 625 #endif |
| 626 | 626 |
| 627 #if SK_SUPPORT_GPU | 627 #if SK_SUPPORT_GPU |
| 628 static void test_crbug263329(skiatest::Reporter* reporter, | 628 static void test_crbug263329(skiatest::Reporter* reporter, |
| 629 SkSurface* surface1, | 629 SkSurface* surface1, |
| 630 SkSurface* surface2) { | 630 SkSurface* surface2) { |
| 631 // This is a regression test for crbug.com/263329 | 631 // This is a regression test for crbug.com/263329 |
| 632 // Bug was caused by onCopyOnWrite releasing the old surface texture | 632 // Bug was caused by onCopyOnWrite releasing the old surface texture |
| 633 // back to the scratch texture pool even though the texture is used | 633 // back to the scratch texture pool even though the texture is used |
| 634 // by and active SkImage_Gpu. | 634 // by and active SkImage_Gpu. |
| 635 SkCanvas* canvas1 = surface1->getCanvas(); | 635 SkCanvas* canvas1 = surface1->getCanvas(); |
| 636 SkCanvas* canvas2 = surface2->getCanvas(); | 636 SkCanvas* canvas2 = surface2->getCanvas(); |
| 637 canvas1->clear(1); | 637 canvas1->clear(1); |
| 638 SkAutoTUnref<SkImage> image1(surface1->newImageSnapshot()); | 638 sk_sp<SkImage> image1(surface1->makeImageSnapshot()); |
| 639 // Trigger copy on write, new backing is a scratch texture | 639 // Trigger copy on write, new backing is a scratch texture |
| 640 canvas1->clear(2); | 640 canvas1->clear(2); |
| 641 SkAutoTUnref<SkImage> image2(surface1->newImageSnapshot()); | 641 sk_sp<SkImage> image2(surface1->makeImageSnapshot()); |
| 642 // Trigger copy on write, old backing should not be returned to scratch | 642 // Trigger copy on write, old backing should not be returned to scratch |
| 643 // pool because it is held by image2 | 643 // pool because it is held by image2 |
| 644 canvas1->clear(3); | 644 canvas1->clear(3); |
| 645 | 645 |
| 646 canvas2->clear(4); | 646 canvas2->clear(4); |
| 647 SkAutoTUnref<SkImage> image3(surface2->newImageSnapshot()); | 647 sk_sp<SkImage> image3(surface2->makeImageSnapshot()); |
| 648 // Trigger copy on write on surface2. The new backing store should not | 648 // Trigger copy on write on surface2. The new backing store should not |
| 649 // be recycling a texture that is held by an existing image. | 649 // be recycling a texture that is held by an existing image. |
| 650 canvas2->clear(5); | 650 canvas2->clear(5); |
| 651 SkAutoTUnref<SkImage> image4(surface2->newImageSnapshot()); | 651 sk_sp<SkImage> image4(surface2->makeImageSnapshot()); |
| 652 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image3)->pee
kTexture()); | 652 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image3)->pee
kTexture()); |
| 653 // The following assertion checks crbug.com/263329 | 653 // The following assertion checks crbug.com/263329 |
| 654 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image2)->pee
kTexture()); | 654 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image2)->pee
kTexture()); |
| 655 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image1)->pee
kTexture()); | 655 REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image1)->pee
kTexture()); |
| 656 REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image2)->pee
kTexture()); | 656 REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image2)->pee
kTexture()); |
| 657 REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image1)->pee
kTexture()); | 657 REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image1)->pee
kTexture()); |
| 658 REPORTER_ASSERT(reporter, as_IB(image2)->peekTexture() != as_IB(image1)->pee
kTexture()); | 658 REPORTER_ASSERT(reporter, as_IB(image2)->peekTexture() != as_IB(image1)->pee
kTexture()); |
| 659 } | 659 } |
| 660 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, context) { | 660 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, context) { |
| 661 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { | 661 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { |
| 662 SkAutoTUnref<SkSurface> surface1(surface_func(context, kPremul_SkAlphaTy
pe, nullptr)); | 662 SkAutoTUnref<SkSurface> surface1(surface_func(context, kPremul_SkAlphaTy
pe, nullptr)); |
| 663 SkAutoTUnref<SkSurface> surface2(surface_func(context, kPremul_SkAlphaTy
pe, nullptr)); | 663 SkAutoTUnref<SkSurface> surface2(surface_func(context, kPremul_SkAlphaTy
pe, nullptr)); |
| 664 test_crbug263329(reporter, surface1, surface2); | 664 test_crbug263329(reporter, surface1, surface2); |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 #endif | 667 #endif |
| 668 | 668 |
| 669 DEF_TEST(SurfaceGetTexture, reporter) { | 669 DEF_TEST(SurfaceGetTexture, reporter) { |
| 670 SkAutoTUnref<SkSurface> surface(create_surface()); | 670 SkAutoTUnref<SkSurface> surface(create_surface()); |
| 671 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 671 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 672 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); | 672 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); |
| 673 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); | 673 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); |
| 674 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); | 674 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); |
| 675 } | 675 } |
| 676 #if SK_SUPPORT_GPU | 676 #if SK_SUPPORT_GPU |
| 677 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, context) { | 677 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, context) { |
| 678 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { | 678 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface
}) { |
| 679 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); | 679 SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaTyp
e, nullptr)); |
| 680 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 680 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 681 GrTexture* texture = as_IB(image)->peekTexture(); | 681 GrTexture* texture = as_IB(image)->peekTexture(); |
| 682 REPORTER_ASSERT(reporter, texture); | 682 REPORTER_ASSERT(reporter, texture); |
| 683 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); | 683 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); |
| 684 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); | 684 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); |
| 685 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture); | 685 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture); |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 #endif | 688 #endif |
| 689 | 689 |
| 690 #if SK_SUPPORT_GPU | 690 #if SK_SUPPORT_GPU |
| 691 #include "GrGpuResourcePriv.h" | 691 #include "GrGpuResourcePriv.h" |
| 692 #include "SkGpuDevice.h" | 692 #include "SkGpuDevice.h" |
| 693 #include "SkImage_Gpu.h" | 693 #include "SkImage_Gpu.h" |
| 694 #include "SkSurface_Gpu.h" | 694 #include "SkSurface_Gpu.h" |
| 695 | 695 |
| 696 static SkBudgeted is_budgeted(SkSurface* surf) { | 696 static SkBudgeted is_budgeted(SkSurface* surf) { |
| 697 return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePr
iv().isBudgeted(); | 697 return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePr
iv().isBudgeted(); |
| 698 } | 698 } |
| 699 | 699 |
| 700 static SkBudgeted is_budgeted(SkImage* image) { | 700 static SkBudgeted is_budgeted(SkImage* image) { |
| 701 return ((SkImage_Gpu*)image)->peekTexture()->resourcePriv().isBudgeted(); | 701 return ((SkImage_Gpu*)image)->peekTexture()->resourcePriv().isBudgeted(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 static SkBudgeted is_budgeted(const sk_sp<SkImage> image) { |
| 705 return is_budgeted(image.get()); |
| 706 } |
| 707 |
| 704 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, context) { | 708 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, context) { |
| 705 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); | 709 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); |
| 706 for (auto sbudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { | 710 for (auto sbudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { |
| 707 for (auto ibudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { | 711 for (auto ibudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { |
| 708 SkAutoTUnref<SkSurface> | 712 SkAutoTUnref<SkSurface> |
| 709 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0))
; | 713 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0))
; |
| 710 SkASSERT(surface); | 714 SkASSERT(surface); |
| 711 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); | 715 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 712 | 716 |
| 713 SkAutoTUnref<SkImage> image(surface->newImageSnapshot(ibudgeted)); | 717 sk_sp<SkImage> image(surface->makeImageSnapshot(ibudgeted)); |
| 714 | 718 |
| 715 // Initially the image shares a texture with the surface, and the su
rface decides | 719 // Initially the image shares a texture with the surface, and the su
rface decides |
| 716 // whether it is budgeted or not. | 720 // whether it is budgeted or not. |
| 717 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); | 721 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 718 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); | 722 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); |
| 719 | 723 |
| 720 // Now trigger copy-on-write | 724 // Now trigger copy-on-write |
| 721 surface->getCanvas()->clear(SK_ColorBLUE); | 725 surface->getCanvas()->clear(SK_ColorBLUE); |
| 722 | 726 |
| 723 // They don't share a texture anymore. They should each have made th
eir own budget | 727 // They don't share a texture anymore. They should each have made th
eir own budget |
| (...skipping 10 matching lines...) Expand all Loading... |
| 734 SkSurface::ContentChangeMode mode) { | 738 SkSurface::ContentChangeMode mode) { |
| 735 // Test passes by not asserting | 739 // Test passes by not asserting |
| 736 surface->notifyContentWillChange(mode); | 740 surface->notifyContentWillChange(mode); |
| 737 SkDEBUGCODE(surface->validate();) | 741 SkDEBUGCODE(surface->validate();) |
| 738 } | 742 } |
| 739 static void test_no_canvas2(skiatest::Reporter* reporter, | 743 static void test_no_canvas2(skiatest::Reporter* reporter, |
| 740 SkSurface* surface, | 744 SkSurface* surface, |
| 741 SkSurface::ContentChangeMode mode) { | 745 SkSurface::ContentChangeMode mode) { |
| 742 // Verifies the robustness of SkSurface for handling use cases where calls | 746 // Verifies the robustness of SkSurface for handling use cases where calls |
| 743 // are made before a canvas is created. | 747 // are made before a canvas is created. |
| 744 SkImage* image1 = surface->newImageSnapshot(); | 748 sk_sp<SkImage> image1 = surface->makeImageSnapshot(); |
| 745 SkAutoTUnref<SkImage> aur_image1(image1); | 749 sk_sp<SkImage> aur_image1(image1); |
| 746 SkDEBUGCODE(image1->validate();) | 750 SkDEBUGCODE(image1->validate();) |
| 747 SkDEBUGCODE(surface->validate();) | 751 SkDEBUGCODE(surface->validate();) |
| 748 surface->notifyContentWillChange(mode); | 752 surface->notifyContentWillChange(mode); |
| 749 SkDEBUGCODE(image1->validate();) | 753 SkDEBUGCODE(image1->validate();) |
| 750 SkDEBUGCODE(surface->validate();) | 754 SkDEBUGCODE(surface->validate();) |
| 751 SkImage* image2 = surface->newImageSnapshot(); | 755 sk_sp<SkImage> image2 = surface->makeImageSnapshot(); |
| 752 SkAutoTUnref<SkImage> aur_image2(image2); | 756 sk_sp<SkImage> aur_image2(image2); |
| 753 SkDEBUGCODE(image2->validate();) | 757 SkDEBUGCODE(image2->validate();) |
| 754 SkDEBUGCODE(surface->validate();) | 758 SkDEBUGCODE(surface->validate();) |
| 755 REPORTER_ASSERT(reporter, image1 != image2); | 759 REPORTER_ASSERT(reporter, image1 != image2); |
| 756 } | 760 } |
| 757 DEF_TEST(SurfaceNoCanvas, reporter) { | 761 DEF_TEST(SurfaceNoCanvas, reporter) { |
| 758 SkSurface::ContentChangeMode modes[] = | 762 SkSurface::ContentChangeMode modes[] = |
| 759 { SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentC
hangeMode}; | 763 { SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentC
hangeMode}; |
| 760 for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) { | 764 for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) { |
| 761 for (auto& mode : modes) { | 765 for (auto& mode : modes) { |
| 762 SkAutoTUnref<SkSurface> surface(create_surface()); | 766 SkAutoTUnref<SkSurface> surface(create_surface()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 777 } | 781 } |
| 778 } | 782 } |
| 779 } | 783 } |
| 780 } | 784 } |
| 781 #endif | 785 #endif |
| 782 | 786 |
| 783 static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Repor
ter* reporter) { | 787 static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Repor
ter* reporter) { |
| 784 SkPixmap surfacePM; | 788 SkPixmap surfacePM; |
| 785 REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM)); | 789 REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM)); |
| 786 | 790 |
| 787 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 791 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 788 SkPixmap pm; | 792 SkPixmap pm; |
| 789 REPORTER_ASSERT(reporter, image->peekPixels(&pm)); | 793 REPORTER_ASSERT(reporter, image->peekPixels(&pm)); |
| 790 | 794 |
| 791 REPORTER_ASSERT(reporter, surfacePM.rowBytes() == pm.rowBytes()); | 795 REPORTER_ASSERT(reporter, surfacePM.rowBytes() == pm.rowBytes()); |
| 792 | 796 |
| 793 // trigger a copy-on-write | 797 // trigger a copy-on-write |
| 794 surface->getCanvas()->drawPaint(SkPaint()); | 798 surface->getCanvas()->drawPaint(SkPaint()); |
| 795 SkAutoTUnref<SkImage> image2(surface->newImageSnapshot()); | 799 sk_sp<SkImage> image2(surface->makeImageSnapshot()); |
| 796 REPORTER_ASSERT(reporter, image->uniqueID() != image2->uniqueID()); | 800 REPORTER_ASSERT(reporter, image->uniqueID() != image2->uniqueID()); |
| 797 | 801 |
| 798 SkPixmap pm2; | 802 SkPixmap pm2; |
| 799 REPORTER_ASSERT(reporter, image2->peekPixels(&pm2)); | 803 REPORTER_ASSERT(reporter, image2->peekPixels(&pm2)); |
| 800 REPORTER_ASSERT(reporter, pm2.rowBytes() == pm.rowBytes()); | 804 REPORTER_ASSERT(reporter, pm2.rowBytes() == pm.rowBytes()); |
| 801 } | 805 } |
| 802 | 806 |
| 803 DEF_TEST(surface_rowbytes, reporter) { | 807 DEF_TEST(surface_rowbytes, reporter) { |
| 804 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 808 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
| 805 | 809 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } | 863 } |
| 860 } | 864 } |
| 861 | 865 |
| 862 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, context) { | 866 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, context) { |
| 863 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { | 867 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { |
| 864 [] (SkSurface* s){ return s->getCanvas()->internal_private_accessTopLaye
rRenderTarget(); }, | 868 [] (SkSurface* s){ return s->getCanvas()->internal_private_accessTopLaye
rRenderTarget(); }, |
| 865 [] (SkSurface* s){ | 869 [] (SkSurface* s){ |
| 866 SkBaseDevice* d = | 870 SkBaseDevice* d = |
| 867 s->getCanvas()->getDevice_just_for_deprecated_compatibility_test
ing(); | 871 s->getCanvas()->getDevice_just_for_deprecated_compatibility_test
ing(); |
| 868 return d->accessRenderTarget(); }, | 872 return d->accessRenderTarget(); }, |
| 869 [] (SkSurface* s){ SkAutoTUnref<SkImage> i(s->newImageSnapshot()); | 873 [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); |
| 870 return as_IB(i)->peekTexture(); }, | 874 return as_IB(i)->peekTexture(); }, |
| 871 }; | 875 }; |
| 872 for (auto grSurfaceGetter : grSurfaceGetters) { | 876 for (auto grSurfaceGetter : grSurfaceGetters) { |
| 873 for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surf
ace}) { | 877 for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surf
ace}) { |
| 874 SkSurface* surface = surface_func(context, kPremul_SkAlphaType, null
ptr); | 878 SkSurface* surface = surface_func(context, kPremul_SkAlphaType, null
ptr); |
| 875 test_surface_clear(reporter, surface, grSurfaceGetter, 0x0); | 879 test_surface_clear(reporter, surface, grSurfaceGetter, 0x0); |
| 876 } | 880 } |
| 877 // Wrapped RTs are *not* supposed to clear (to allow client to partially
update a surface). | 881 // Wrapped RTs are *not* supposed to clear (to allow client to partially
update a surface). |
| 878 static const int kWidth = 10; | 882 static const int kWidth = 10; |
| 879 static const int kHeight = 10; | 883 static const int kHeight = 10; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 890 desc.fHeight = kHeight; | 894 desc.fHeight = kHeight; |
| 891 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 895 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 892 desc.fTextureHandle = textureObject; | 896 desc.fTextureHandle = textureObject; |
| 893 | 897 |
| 894 SkSurface* surface = SkSurface::NewFromBackendTexture(context, desc, nul
lptr); | 898 SkSurface* surface = SkSurface::NewFromBackendTexture(context, desc, nul
lptr); |
| 895 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); | 899 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); |
| 896 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); | 900 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); |
| 897 } | 901 } |
| 898 } | 902 } |
| 899 #endif | 903 #endif |
| OLD | NEW |