| 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 REPORTER_ASSERT(reporter, nullptr != texRT2); | 34 REPORTER_ASSERT(reporter, nullptr != texRT2); |
| 35 GrTexture* tex = texRT1->asTexture(); | 35 GrTexture* tex = texRT1->asTexture(); |
| 36 REPORTER_ASSERT(reporter, nullptr != tex); | 36 REPORTER_ASSERT(reporter, nullptr != tex); |
| 37 SkBitmap bitmap; | 37 SkBitmap bitmap; |
| 38 GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); | 38 GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); |
| 39 | 39 |
| 40 // No mipmaps initially | 40 // No mipmaps initially |
| 41 REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); | 41 REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); |
| 42 | 42 |
| 43 // Painting with downscale and medium filter quality should result in mipmap
creation | 43 // Painting with downscale and medium filter quality should result in mipmap
creation |
| 44 SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTarget
()); | 44 auto surface = SkSurface::MakeRenderTargetDirect(texRT2->asRenderTarget()); |
| 45 SkPaint paint; | 45 SkPaint paint; |
| 46 paint.setFilterQuality(kMedium_SkFilterQuality); | 46 paint.setFilterQuality(kMedium_SkFilterQuality); |
| 47 surface->getCanvas()->scale(0.2f, 0.2f); | 47 surface->getCanvas()->scale(0.2f, 0.2f); |
| 48 surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); | 48 surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); |
| 49 context->flush(); | 49 context->flush(); |
| 50 | 50 |
| 51 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); | 51 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); |
| 52 REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty()); | 52 REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty()); |
| 53 | 53 |
| 54 // Invalidating the contents of the bitmap should invalidate the mipmap, but
not de-allocate | 54 // Invalidating the contents of the bitmap should invalidate the mipmap, but
not de-allocate |
| 55 bitmap.notifyPixelsChanged(); | 55 bitmap.notifyPixelsChanged(); |
| 56 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); | 56 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); |
| 57 REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); | 57 REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); |
| 58 | 58 |
| 59 surface->unref(); | |
| 60 texRT1->unref(); | 59 texRT1->unref(); |
| 61 texRT2->unref(); | 60 texRT2->unref(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 #endif | 63 #endif |
| OLD | NEW |