Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: src/gpu/SkGr.cpp

Issue 673883002: When bmp is not cached don't upload as index8 format. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 based bitmap. [palette (colortable) + indices]. 27 based bitmap. [palette (colortable) + indices].
28 28
29 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others 29 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others
30 we could detect that the colortable.count is <= 16, and then repack the 30 we could detect that the colortable.count is <= 16, and then repack the
31 indices as nibbles to save RAM, but it would take more time (i.e. a lot 31 indices as nibbles to save RAM, but it would take more time (i.e. a lot
32 slower than memcpy), so skipping that for now. 32 slower than memcpy), so skipping that for now.
33 33
34 Ganesh wants a full 256 palette entry, even though Skia's ctable is only as big 34 Ganesh wants a full 256 palette entry, even though Skia's ctable is only as big
35 as the colortable.count says it is. 35 as the colortable.count says it is.
36 */ 36 */
37 static void build_compressed_data(void* buffer, const SkBitmap& bitmap) { 37 static void build_index8_data(void* buffer, const SkBitmap& bitmap) {
38 SkASSERT(kIndex_8_SkColorType == bitmap.colorType()); 38 SkASSERT(kIndex_8_SkColorType == bitmap.colorType());
39 39
40 SkAutoLockPixels alp(bitmap); 40 SkAutoLockPixels alp(bitmap);
41 if (!bitmap.readyToDraw()) { 41 if (!bitmap.readyToDraw()) {
42 SkDEBUGFAIL("bitmap not ready to draw!"); 42 SkDEBUGFAIL("bitmap not ready to draw!");
43 return; 43 return;
44 } 44 }
45 45
46 SkColorTable* ctable = bitmap.getColorTable(); 46 SkColorTable* ctable = bitmap.getColorTable();
47 char* dst = (char*)buffer; 47 char* dst = (char*)buffer;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 SkBitmap tmpBitmap; 301 SkBitmap tmpBitmap;
302 302
303 const SkBitmap* bitmap = &origBitmap; 303 const SkBitmap* bitmap = &origBitmap;
304 304
305 GrTextureDesc desc; 305 GrTextureDesc desc;
306 generate_bitmap_texture_desc(*bitmap, &desc); 306 generate_bitmap_texture_desc(*bitmap, &desc);
307 307
308 if (kIndex_8_SkColorType == bitmap->colorType()) { 308 if (kIndex_8_SkColorType == bitmap->colorType()) {
309 // build_compressed_data doesn't do npot->pot expansion 309 // build_compressed_data doesn't do npot->pot expansion
310 // and paletted textures can't be sub-updated 310 // and paletted textures can't be sub-updated
311 if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->heig ht())) { 311 if (cache && ctx->supportsIndex8PixelConfig(params, bitmap->width(), bit map->height())) {
312 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig , 312 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig ,
313 bitmap->width(), bitma p->height()); 313 bitmap->width(), bitma p->height());
314 SkAutoMalloc storage(imageSize); 314 SkAutoMalloc storage(imageSize);
robertphillips 2014/10/24 12:15:47 Is this memset necessary?
bsalomon 2014/10/24 13:46:07 Oops, no, leftover from debugging something.
315 315 memset(storage.get(), 0xff, imageSize);
316 build_compressed_data(storage.get(), origBitmap); 316 build_index8_data(storage.get(), origBitmap);
317 317
318 // our compressed data will be trimmed, so pass width() for its 318 // our compressed data will be trimmed, so pass width() for its
319 // "rowBytes", since they are the same now. 319 // "rowBytes", since they are the same now.
320 return sk_gr_allocate_texture(ctx, cache, params, origBitmap, 320 return sk_gr_allocate_texture(ctx, cache, params, origBitmap,
321 desc, storage.get(), bitmap->width()); 321 desc, storage.get(), bitmap->width());
322 } else { 322 } else {
323 origBitmap.copyTo(&tmpBitmap, kN32_SkColorType); 323 origBitmap.copyTo(&tmpBitmap, kN32_SkColorType);
324 // now bitmap points to our temp, which has been promoted to 32bits 324 // now bitmap points to our temp, which has been promoted to 32bits
325 bitmap = &tmpBitmap; 325 bitmap = &tmpBitmap;
326 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info()); 326 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info());
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 575 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
576 grPaint->addColorProcessor(fp)->unref(); 576 grPaint->addColorProcessor(fp)->unref();
577 constantColor = false; 577 constantColor = false;
578 } 578 }
579 } 579 }
580 580
581 // The grcolor is automatically set when calling asFragmentProcessor. 581 // The grcolor is automatically set when calling asFragmentProcessor.
582 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 582 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
583 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 583 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
584 } 584 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698