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 11 matching lines...) Expand all Loading... |
22 // and render targets to GrSurface all work as expected. | 22 // and render targets to GrSurface all work as expected. |
23 DEF_GPUTEST(GrTextureMipMapInvalidationTest, reporter, factory) { | 23 DEF_GPUTEST(GrTextureMipMapInvalidationTest, reporter, factory) { |
24 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); | 24 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); |
25 if (context) { | 25 if (context) { |
26 GrSurfaceDesc desc; | 26 GrSurfaceDesc desc; |
27 desc.fConfig = kSkia8888_GrPixelConfig; | 27 desc.fConfig = kSkia8888_GrPixelConfig; |
28 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 28 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
29 desc.fWidth = 256; | 29 desc.fWidth = 256; |
30 desc.fHeight = 256; | 30 desc.fHeight = 256; |
31 desc.fSampleCnt = 0; | 31 desc.fSampleCnt = 0; |
32 GrSurface* texRT1 = context->textureProvider()->createTexture(desc, fals
e, NULL, 0); | 32 GrSurface* texRT1 = context->textureProvider()->createTexture(desc, fals
e, nullptr, 0); |
33 GrSurface* texRT2 = context->textureProvider()->createTexture(desc, fals
e, NULL, 0); | 33 GrSurface* texRT2 = context->textureProvider()->createTexture(desc, fals
e, nullptr, 0); |
34 REPORTER_ASSERT(reporter, NULL != texRT1); | 34 REPORTER_ASSERT(reporter, nullptr != texRT1); |
35 REPORTER_ASSERT(reporter, NULL != texRT2); | 35 REPORTER_ASSERT(reporter, nullptr != texRT2); |
36 GrTexture* tex = texRT1->asTexture(); | 36 GrTexture* tex = texRT1->asTexture(); |
37 REPORTER_ASSERT(reporter, NULL != tex); | 37 REPORTER_ASSERT(reporter, nullptr != tex); |
38 SkBitmap bitmap; | 38 SkBitmap bitmap; |
39 GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); | 39 GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); |
40 | 40 |
41 // No mipmaps initially | 41 // No mipmaps initially |
42 REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); | 42 REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); |
43 | 43 |
44 // Painting with downscale and medium filter quality should result in mi
pmap creation | 44 // Painting with downscale and medium filter quality should result in mi
pmap creation |
45 SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTa
rget()); | 45 SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTa
rget()); |
46 SkPaint paint; | 46 SkPaint paint; |
47 paint.setFilterQuality(kMedium_SkFilterQuality); | 47 paint.setFilterQuality(kMedium_SkFilterQuality); |
48 surface->getCanvas()->scale(0.2f, 0.2f); | 48 surface->getCanvas()->scale(0.2f, 0.2f); |
49 surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); | 49 surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); |
50 context->flush(); | 50 context->flush(); |
51 | 51 |
52 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); | 52 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); |
53 REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty())
; | 53 REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty())
; |
54 | 54 |
55 // Invalidating the contents of the bitmap should invalidate the mipmap,
but not de-allocate | 55 // Invalidating the contents of the bitmap should invalidate the mipmap,
but not de-allocate |
56 bitmap.notifyPixelsChanged(); | 56 bitmap.notifyPixelsChanged(); |
57 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); | 57 REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); |
58 REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); | 58 REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); |
59 | 59 |
60 surface->unref(); | 60 surface->unref(); |
61 texRT1->unref(); | 61 texRT1->unref(); |
62 texRT2->unref(); | 62 texRT2->unref(); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 #endif | 66 #endif |
OLD | NEW |