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

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

Issue 457333004: Consider index8 a compressed config. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 6 years, 4 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
« no previous file with comments | « src/gpu/GrTexture.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 srcPI.fColorType = kN32_SkColorType; 58 srcPI.fColorType = kN32_SkColorType;
59 srcPI.fAlphaType = kPremul_SkAlphaType; 59 srcPI.fAlphaType = kPremul_SkAlphaType;
60 srcPI.fPixels = ctable->lockColors(); 60 srcPI.fPixels = ctable->lockColors();
61 srcPI.fRowBytes = count * sizeof(SkPMColor); 61 srcPI.fRowBytes = count * sizeof(SkPMColor);
62 62
63 srcPI.convertPixelsTo(&dstPI, count, 1); 63 srcPI.convertPixelsTo(&dstPI, count, 1);
64 64
65 ctable->unlockColors(); 65 ctable->unlockColors();
66 66
67 // always skip a full 256 number of entries, even if we memcpy'd fewer 67 // always skip a full 256 number of entries, even if we memcpy'd fewer
68 dst += kGrColorTableSize; 68 dst += 256 * sizeof(GrColor);
69 69
70 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { 70 if ((unsigned)bitmap.width() == bitmap.rowBytes()) {
71 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); 71 memcpy(dst, bitmap.getPixels(), bitmap.getSize());
72 } else { 72 } else {
73 // need to trim off the extra bytes per row 73 // need to trim off the extra bytes per row
74 size_t width = bitmap.width(); 74 size_t width = bitmap.width();
75 size_t rowBytes = bitmap.rowBytes(); 75 size_t rowBytes = bitmap.rowBytes();
76 const char* src = (const char*)bitmap.getPixels(); 76 const char* src = (const char*)bitmap.getPixels();
77 for (int y = 0; y < bitmap.height(); y++) { 77 for (int y = 0; y < bitmap.height(); y++) {
78 memcpy(dst, src, width); 78 memcpy(dst, src, width);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 const SkBitmap* bitmap = &origBitmap; 279 const SkBitmap* bitmap = &origBitmap;
280 280
281 GrTextureDesc desc; 281 GrTextureDesc desc;
282 generate_bitmap_texture_desc(*bitmap, &desc); 282 generate_bitmap_texture_desc(*bitmap, &desc);
283 283
284 if (kIndex_8_SkColorType == bitmap->colorType()) { 284 if (kIndex_8_SkColorType == bitmap->colorType()) {
285 // build_compressed_data doesn't do npot->pot expansion 285 // build_compressed_data doesn't do npot->pot expansion
286 // and paletted textures can't be sub-updated 286 // and paletted textures can't be sub-updated
287 if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->heig ht())) { 287 if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->heig ht())) {
288 size_t imagesize = bitmap->width() * bitmap->height() + kGrColorTabl eSize; 288 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig ,
289 SkAutoMalloc storage(imagesize); 289 bitmap->width(), bitma p->height());
290 SkAutoMalloc storage(imageSize);
290 291
291 build_compressed_data(storage.get(), origBitmap); 292 build_compressed_data(storage.get(), origBitmap);
292 293
293 // our compressed data will be trimmed, so pass width() for its 294 // our compressed data will be trimmed, so pass width() for its
294 // "rowBytes", since they are the same now. 295 // "rowBytes", since they are the same now.
295 296
296 if (cache) { 297 if (cache) {
297 GrCacheID cacheID; 298 GrCacheID cacheID;
298 generate_bitmap_cache_id(origBitmap, &cacheID); 299 generate_bitmap_cache_id(origBitmap, &cacheID);
299 300
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && NULL != effect) { 618 if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && NULL != effect) {
618 grPaint->addColorEffect(effect)->unref(); 619 grPaint->addColorEffect(effect)->unref();
619 constantColor = false; 620 constantColor = false;
620 } 621 }
621 } 622 }
622 623
623 // The grcolor is automatically set when calling asneweffect. 624 // The grcolor is automatically set when calling asneweffect.
624 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 625 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
625 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 626 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
626 } 627 }
OLDNEW
« no previous file with comments | « src/gpu/GrTexture.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698