OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
(...skipping 121 matching lines...) Loading... | |
132 | 132 |
133 static void add_genID_listener(GrResourceKey key, SkPixelRef* pixelRef) { | 133 static void add_genID_listener(GrResourceKey key, SkPixelRef* pixelRef) { |
134 SkASSERT(pixelRef); | 134 SkASSERT(pixelRef); |
135 pixelRef->addGenIDChangeListener(SkNEW_ARGS(GrResourceInvalidator, (key))); | 135 pixelRef->addGenIDChangeListener(SkNEW_ARGS(GrResourceInvalidator, (key))); |
136 } | 136 } |
137 | 137 |
138 static GrTexture* sk_gr_allocate_texture(GrContext* ctx, | 138 static GrTexture* sk_gr_allocate_texture(GrContext* ctx, |
139 bool cache, | 139 bool cache, |
140 const GrTextureParams* params, | 140 const GrTextureParams* params, |
141 const SkBitmap& bm, | 141 const SkBitmap& bm, |
142 GrTextureDesc desc, | 142 const GrTextureDesc& desc, |
143 const void* pixels, | 143 const void* pixels, |
144 size_t rowBytes) { | 144 size_t rowBytes) { |
145 GrTexture* result; | 145 GrTexture* result; |
146 if (cache) { | 146 if (cache) { |
147 // This texture is likely to be used again so leave it in the cache | 147 // This texture is likely to be used again so leave it in the cache |
148 GrCacheID cacheID; | 148 GrCacheID cacheID; |
149 generate_bitmap_cache_id(bm, &cacheID); | 149 generate_bitmap_cache_id(bm, &cacheID); |
150 | 150 |
151 GrResourceKey key; | 151 GrResourceKey key; |
152 result = ctx->createTexture(params, desc, cacheID, pixels, rowBytes, &ke y); | 152 result = ctx->createTexture(params, desc, cacheID, pixels, rowBytes, &ke y); |
(...skipping 162 matching lines...) Loading... | |
315 origBitmap.copyTo(&tmpBitmap, kN32_SkColorType); | 315 origBitmap.copyTo(&tmpBitmap, kN32_SkColorType); |
316 // now bitmap points to our temp, which has been promoted to 32bits | 316 // now bitmap points to our temp, which has been promoted to 32bits |
317 bitmap = &tmpBitmap; | 317 bitmap = &tmpBitmap; |
318 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info()); | 318 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info()); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 // Is this an ETC1 encoded texture? | 322 // Is this an ETC1 encoded texture? |
323 #ifndef SK_IGNORE_ETC1_SUPPORT | 323 #ifndef SK_IGNORE_ETC1_SUPPORT |
324 else if ( | 324 else if ( |
325 // We do not support scratch ETC1 textures, hence they should all be at least | |
326 // trying to go to the cache. | |
327 cache | |
sugoi1
2014/09/10 19:31:28
Missed that in the initial patch, oops. Now, it re
| |
328 // Make sure that the underlying device supports ETC1 textures before we go ahead | 325 // Make sure that the underlying device supports ETC1 textures before we go ahead |
329 // and check the data. | 326 // and check the data. |
330 && ctx->getGpu()->caps()->isConfigTexturable(kETC1_GrPixelConfig) | 327 ctx->getGpu()->caps()->isConfigTexturable(kETC1_GrPixelConfig) |
331 // If the bitmap had compressed data and was then uncompressed, it'll st ill return | 328 // If the bitmap had compressed data and was then uncompressed, it'll st ill return |
332 // compressed data on 'refEncodedData' and upload it. Probably not good, since if | 329 // compressed data on 'refEncodedData' and upload it. Probably not good, since if |
333 // the bitmap has available pixels, then they might not be what the deco mpressed | 330 // the bitmap has available pixels, then they might not be what the deco mpressed |
334 // data is. | 331 // data is. |
335 && !(bitmap->readyToDraw())) { | 332 && !(bitmap->readyToDraw())) { |
336 GrTexture *texture = load_etc1_texture(ctx, cache, params, *bitmap, desc ); | 333 GrTexture *texture = load_etc1_texture(ctx, cache, params, *bitmap, desc ); |
337 if (texture) { | 334 if (texture) { |
338 return texture; | 335 return texture; |
339 } | 336 } |
340 } | 337 } |
(...skipping 232 matching lines...) Loading... | |
573 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && effect) { | 570 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && effect) { |
574 grPaint->addColorEffect(effect)->unref(); | 571 grPaint->addColorEffect(effect)->unref(); |
575 constantColor = false; | 572 constantColor = false; |
576 } | 573 } |
577 } | 574 } |
578 | 575 |
579 // The grcolor is automatically set when calling asneweffect. | 576 // The grcolor is automatically set when calling asneweffect. |
580 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. | 577 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. |
581 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); | 578 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); |
582 } | 579 } |
OLD | NEW |