Chromium Code Reviews| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); | 475 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); |
| 476 for (int i = 0; i < 2; ++i) { | 476 for (int i = 0; i < 2; ++i) { |
| 477 SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface ::kNo_Budgeted; | 477 SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface ::kNo_Budgeted; |
| 478 for (int j = 0; j < 2; ++j) { | 478 for (int j = 0; j < 2; ++j) { |
| 479 SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSur face::kNo_Budgeted; | 479 SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSur face::kNo_Budgeted; |
| 480 SkAutoTUnref<SkSurface> | 480 SkAutoTUnref<SkSurface> |
| 481 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0)) ; | 481 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0)) ; |
| 482 SkASSERT(surface); | 482 SkASSERT(surface); |
| 483 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); | 483 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 484 | 484 |
| 485 SkImage* image = surface->newImageSnapshot(ibudgeted); | 485 SkAutoTUnref<SkImage> image(surface->newImageSnapshot(ibudgeted)); |
|
tfarina
2015/01/24 22:03:11
lgtm
| |
| 486 | 486 |
| 487 // Initially the image shares a texture with the surface, and the su rface decides | 487 // Initially the image shares a texture with the surface, and the su rface decides |
| 488 // whether it is budgeted or not. | 488 // whether it is budgeted or not. |
| 489 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); | 489 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 490 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); | 490 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); |
| 491 | 491 |
| 492 // Now trigger copy-on-write | 492 // Now trigger copy-on-write |
| 493 surface->getCanvas()->clear(SK_ColorBLUE); | 493 surface->getCanvas()->clear(SK_ColorBLUE); |
| 494 | 494 |
| 495 // They don't share a texture anymore. They should each have made th eir own budget | 495 // They don't share a texture anymore. They should each have made th eir own budget |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); | 570 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); |
| 571 TestGetTexture(reporter, kGpu_SurfaceType, context); | 571 TestGetTexture(reporter, kGpu_SurfaceType, context); |
| 572 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); | 572 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); |
| 573 test_empty_surface(reporter, context); | 573 test_empty_surface(reporter, context); |
| 574 test_surface_budget(reporter, context); | 574 test_surface_budget(reporter, context); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 #endif | 578 #endif |
| 579 } | 579 } |
| OLD | NEW |