| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2015 Google Inc. | 2  * Copyright 2015 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 <initializer_list> | 9 #include <initializer_list> | 
| 10 #include "DMGpuSupport.h" | 10 #include "DMGpuSupport.h" | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 169     decoded = SkImage::MakeFromEncoded(origEncoded, &ir); | 169     decoded = SkImage::MakeFromEncoded(origEncoded, &ir); | 
| 170     REPORTER_ASSERT(reporter, decoded); | 170     REPORTER_ASSERT(reporter, decoded); | 
| 171     assert_equal(reporter, image, &ir, decoded.get()); | 171     assert_equal(reporter, image, &ir, decoded.get()); | 
| 172 } | 172 } | 
| 173 | 173 | 
| 174 DEF_TEST(ImageEncode, reporter) { | 174 DEF_TEST(ImageEncode, reporter) { | 
| 175     test_encode(reporter, create_image().get()); | 175     test_encode(reporter, create_image().get()); | 
| 176 } | 176 } | 
| 177 | 177 | 
| 178 #if SK_SUPPORT_GPU | 178 #if SK_SUPPORT_GPU | 
| 179 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) { | 179 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) { | 
| 180     test_encode(reporter, create_gpu_image(ctxInfo.fGrContext).get()); | 180     test_encode(reporter, create_gpu_image(ctxInfo.fGrContext).get()); | 
| 181 } | 181 } | 
| 182 #endif | 182 #endif | 
| 183 | 183 | 
| 184 namespace { | 184 namespace { | 
| 185 | 185 | 
| 186 const char* kSerializedData = "serialized"; | 186 const char* kSerializedData = "serialized"; | 
| 187 | 187 | 
| 188 class MockSerializer : public SkPixelSerializer { | 188 class MockSerializer : public SkPixelSerializer { | 
| 189 public: | 189 public: | 
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 362 #include "SkBitmapCache.h" | 362 #include "SkBitmapCache.h" | 
| 363 | 363 | 
| 364 /* | 364 /* | 
| 365  *  This tests the caching (and preemptive purge) of the raster equivalent of a 
     gpu-image. | 365  *  This tests the caching (and preemptive purge) of the raster equivalent of a 
     gpu-image. | 
| 366  *  We cache it for performance when drawing into a raster surface. | 366  *  We cache it for performance when drawing into a raster surface. | 
| 367  * | 367  * | 
| 368  *  A cleaner test would know if each drawImage call triggered a read-back from 
     the gpu, | 368  *  A cleaner test would know if each drawImage call triggered a read-back from 
     the gpu, | 
| 369  *  but we don't have that facility (at the moment) so we use a little internal 
     knowledge | 369  *  but we don't have that facility (at the moment) so we use a little internal 
     knowledge | 
| 370  *  of *how* the raster version is cached, and look for that. | 370  *  of *how* the raster version is cached, and look for that. | 
| 371  */ | 371  */ | 
| 372 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_Gpu2Cpu, reporter, ctxInfo) { | 372 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) { | 
| 373     SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); | 373     SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); | 
| 374     sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); | 374     sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); | 
| 375     const uint32_t uniqueID = image->uniqueID(); | 375     const uint32_t uniqueID = image->uniqueID(); | 
| 376 | 376 | 
| 377     auto surface(SkSurface::MakeRaster(info)); | 377     auto surface(SkSurface::MakeRaster(info)); | 
| 378 | 378 | 
| 379     // now we can test drawing a gpu-backed image into a cpu-backed surface | 379     // now we can test drawing a gpu-backed image into a cpu-backed surface | 
| 380 | 380 | 
| 381     { | 381     { | 
| 382         SkBitmap cachedBitmap; | 382         SkBitmap cachedBitmap; | 
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 633         image = create_rasterproc_image(&dataHolder); | 633         image = create_rasterproc_image(&dataHolder); | 
| 634         test_legacy_bitmap(reporter, image.get(), mode); | 634         test_legacy_bitmap(reporter, image.get(), mode); | 
| 635         image.reset(); | 635         image.reset(); | 
| 636         REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount); | 636         REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount); | 
| 637 | 637 | 
| 638         image = create_codec_image(); | 638         image = create_codec_image(); | 
| 639         test_legacy_bitmap(reporter, image.get(), mode); | 639         test_legacy_bitmap(reporter, image.get(), mode); | 
| 640     } | 640     } | 
| 641 } | 641 } | 
| 642 #if SK_SUPPORT_GPU | 642 #if SK_SUPPORT_GPU | 
| 643 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) 
     { | 643 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) { | 
| 644     const SkImage::LegacyBitmapMode modes[] = { | 644     const SkImage::LegacyBitmapMode modes[] = { | 
| 645         SkImage::kRO_LegacyBitmapMode, | 645         SkImage::kRO_LegacyBitmapMode, | 
| 646         SkImage::kRW_LegacyBitmapMode, | 646         SkImage::kRW_LegacyBitmapMode, | 
| 647     }; | 647     }; | 
| 648     for (auto& mode : modes) { | 648     for (auto& mode : modes) { | 
| 649         sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); | 649         sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); | 
| 650         test_legacy_bitmap(reporter, image.get(), mode); | 650         test_legacy_bitmap(reporter, image.get(), mode); | 
| 651     } | 651     } | 
| 652 } | 652 } | 
| 653 #endif | 653 #endif | 
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 891                         otherContextInfo.fGrContext, buffer, budgeted)); | 891                         otherContextInfo.fGrContext, buffer, budgeted)); | 
| 892                     REPORTER_ASSERT(reporter, !newImage2); | 892                     REPORTER_ASSERT(reporter, !newImage2); | 
| 893                     glContext->makeCurrent(); | 893                     glContext->makeCurrent(); | 
| 894                 } | 894                 } | 
| 895             } | 895             } | 
| 896             sk_free(buffer); | 896             sk_free(buffer); | 
| 897         } | 897         } | 
| 898     } | 898     } | 
| 899 } | 899 } | 
| 900 #endif | 900 #endif | 
| OLD | NEW | 
|---|