| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 569 |
| 570 SkBitmap bitmap; | 570 SkBitmap bitmap; |
| 571 make_ringed_bitmap(&bitmap, 6, 6); | 571 make_ringed_bitmap(&bitmap, 6, 6); |
| 572 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); | 572 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); |
| 573 | 573 |
| 574 // make two textures... | 574 // make two textures... |
| 575 SkBitmap bm_subset, tx_subset; | 575 SkBitmap bm_subset, tx_subset; |
| 576 | 576 |
| 577 // ... one from a texture-subset | 577 // ... one from a texture-subset |
| 578 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctx, bitmap, | 578 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctx, bitmap, |
| 579 kUntiled_SkImageUsag
eType)); | 579 GrTextureParams::Cla
mpNoFilter())); |
| 580 SkBitmap tx_full; | 580 SkBitmap tx_full; |
| 581 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful
l); | 581 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful
l); |
| 582 tx_full.extractSubset(&tx_subset, subset); | 582 tx_full.extractSubset(&tx_subset, subset); |
| 583 | 583 |
| 584 // ... one from a bitmap-subset | 584 // ... one from a bitmap-subset |
| 585 SkBitmap tmp_subset; | 585 SkBitmap tmp_subset; |
| 586 bitmap.extractSubset(&tmp_subset, subset); | 586 bitmap.extractSubset(&tmp_subset, subset); |
| 587 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctx, tmp_subset, | 587 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctx, tmp_subset, |
| 588 kUntiled_SkImageUs
ageType)); | 588 GrTextureParams::C
lampNoFilter())); |
| 589 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); | 589 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); |
| 590 | 590 |
| 591 // did we get the same subset? | 591 // did we get the same subset? |
| 592 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); | 592 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); |
| 593 | 593 |
| 594 // do they draw the same? | 594 // do they draw the same? |
| 595 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); | 595 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); |
| 596 SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(ctx, SkSurface::kNo
_Budgeted, info, 0)); | 596 SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(ctx, SkSurface::kNo
_Budgeted, info, 0)); |
| 597 SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(ctx, SkSurface::kNo
_Budgeted, info, 0)); | 597 SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(ctx, SkSurface::kNo
_Budgeted, info, 0)); |
| 598 | 598 |
| 599 if (false) { | 599 if (false) { |
| 600 // | 600 // |
| 601 // BUG: depending on the driver, if we calls this with various quality
settings, it | 601 // BUG: depending on the driver, if we calls this with various quality
settings, it |
| 602 // may fail. | 602 // may fail. |
| 603 // | 603 // |
| 604 SkFilterQuality quality = kLow_SkFilterQuality; | 604 SkFilterQuality quality = kLow_SkFilterQuality; |
| 605 | 605 |
| 606 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA, bm_subset, quality))
; | 606 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA, bm_subset, quality))
; |
| 607 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; | 607 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; |
| 608 | 608 |
| 609 REPORTER_ASSERT(reporter, dataA->equals(dataB)); | 609 REPORTER_ASSERT(reporter, dataA->equals(dataB)); |
| 610 if (false) { | 610 if (false) { |
| 611 dump_to_file("test_image_A.png", dataA); | 611 dump_to_file("test_image_A.png", dataA); |
| 612 dump_to_file("test_image_B.png", dataB); | 612 dump_to_file("test_image_B.png", dataB); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 #endif | 616 #endif |
| OLD | NEW |