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

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

Issue 338493005: stop using SkBitmap::Config (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months 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
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 14 matching lines...) Expand all
25 25
26 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others 26 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others
27 we could detect that the colortable.count is <= 16, and then repack the 27 we could detect that the colortable.count is <= 16, and then repack the
28 indices as nibbles to save RAM, but it would take more time (i.e. a lot 28 indices as nibbles to save RAM, but it would take more time (i.e. a lot
29 slower than memcpy), so skipping that for now. 29 slower than memcpy), so skipping that for now.
30 30
31 Ganesh wants a full 256 palette entry, even though Skia's ctable is only as big 31 Ganesh wants a full 256 palette entry, even though Skia's ctable is only as big
32 as the colortable.count says it is. 32 as the colortable.count says it is.
33 */ 33 */
34 static void build_compressed_data(void* buffer, const SkBitmap& bitmap) { 34 static void build_compressed_data(void* buffer, const SkBitmap& bitmap) {
35 SkASSERT(SkBitmap::kIndex8_Config == bitmap.config()); 35 SkASSERT(kIndex_8_SkColorType == bitmap.colorType());
36 36
37 SkAutoLockPixels alp(bitmap); 37 SkAutoLockPixels alp(bitmap);
38 if (!bitmap.readyToDraw()) { 38 if (!bitmap.readyToDraw()) {
39 SkDEBUGFAIL("bitmap not ready to draw!"); 39 SkDEBUGFAIL("bitmap not ready to draw!");
40 return; 40 return;
41 } 41 }
42 42
43 SkColorTable* ctable = bitmap.getColorTable(); 43 SkColorTable* ctable = bitmap.getColorTable();
44 char* dst = (char*)buffer; 44 char* dst = (char*)buffer;
45 45
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 bool cache, 196 bool cache,
197 const GrTextureParams* params, 197 const GrTextureParams* params,
198 const SkBitmap& origBitmap) { 198 const SkBitmap& origBitmap) {
199 SkBitmap tmpBitmap; 199 SkBitmap tmpBitmap;
200 200
201 const SkBitmap* bitmap = &origBitmap; 201 const SkBitmap* bitmap = &origBitmap;
202 202
203 GrTextureDesc desc; 203 GrTextureDesc desc;
204 generate_bitmap_texture_desc(*bitmap, &desc); 204 generate_bitmap_texture_desc(*bitmap, &desc);
205 205
206 if (SkBitmap::kIndex8_Config == bitmap->config()) { 206 if (kIndex_8_SkColorType == bitmap->colorType()) {
207 // build_compressed_data doesn't do npot->pot expansion 207 // build_compressed_data doesn't do npot->pot expansion
208 // and paletted textures can't be sub-updated 208 // and paletted textures can't be sub-updated
209 if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->heig ht())) { 209 if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->heig ht())) {
210 size_t imagesize = bitmap->width() * bitmap->height() + kGrColorTabl eSize; 210 size_t imagesize = bitmap->width() * bitmap->height() + kGrColorTabl eSize;
211 SkAutoMalloc storage(imagesize); 211 SkAutoMalloc storage(imagesize);
212 212
213 build_compressed_data(storage.get(), origBitmap); 213 build_compressed_data(storage.get(), origBitmap);
214 214
215 // our compressed data will be trimmed, so pass width() for its 215 // our compressed data will be trimmed, so pass width() for its
216 // "rowBytes", since they are the same now. 216 // "rowBytes", since they are the same now.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 GrEffectRef* grEffect = NULL; 502 GrEffectRef* grEffect = NULL;
503 if (shader->asNewEffect(context, skPaint, NULL, &grColor, &grEffect) && NULL != grEffect) { 503 if (shader->asNewEffect(context, skPaint, NULL, &grColor, &grEffect) && NULL != grEffect) {
504 SkAutoTUnref<GrEffectRef> effect(grEffect); 504 SkAutoTUnref<GrEffectRef> effect(grEffect);
505 grPaint->addColorEffect(effect); 505 grPaint->addColorEffect(effect);
506 constantColor = false; 506 constantColor = false;
507 } 507 }
508 // The grcolor is automatically set when calling asneweffect. 508 // The grcolor is automatically set when calling asneweffect.
509 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 509 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
510 SkPaint2GrPaintNoShader(context, skPaint, grColor, constantColor, grPaint); 510 SkPaint2GrPaintNoShader(context, skPaint, grColor, constantColor, grPaint);
511 } 511 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698