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

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 134843008: Revert of Revert "Revert of https://codereview.chromium.org/129423002/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | src/image/SkImagePriv.h » ('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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkGradientShaderPriv.h" 8 #include "SkGradientShaderPriv.h"
9 #include "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 #include "SkRadialGradient.h" 10 #include "SkRadialGradient.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 */ 576 */
577 void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const { 577 void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
578 // our caller assumes no external alpha, so we ensure that our cache is 578 // our caller assumes no external alpha, so we ensure that our cache is
579 // built with 0xFF 579 // built with 0xFF
580 this->setCacheAlpha(0xFF); 580 this->setCacheAlpha(0xFF);
581 581
582 // don't have a way to put the mapper into our cache-key yet 582 // don't have a way to put the mapper into our cache-key yet
583 if (fMapper) { 583 if (fMapper) {
584 // force our cahce32pixelref to be built 584 // force our cahce32pixelref to be built
585 (void)this->getCache32(); 585 (void)this->getCache32();
586 bitmap->installPixelRef(fCache32PixelRef); 586 bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
587 bitmap->setPixelRef(fCache32PixelRef);
587 return; 588 return;
588 } 589 }
589 590
590 // build our key: [numColors + colors[] + {positions[]} + flags ] 591 // build our key: [numColors + colors[] + {positions[]} + flags ]
591 int count = 1 + fColorCount + 1; 592 int count = 1 + fColorCount + 1;
592 if (fColorCount > 2) { 593 if (fColorCount > 2) {
593 count += fColorCount - 1; // fRecs[].fPos 594 count += fColorCount - 1; // fRecs[].fPos
594 } 595 }
595 596
596 SkAutoSTMalloc<16, int32_t> storage(count); 597 SkAutoSTMalloc<16, int32_t> storage(count);
(...skipping 19 matching lines...) Expand all
616 SkAutoMutexAcquire ama(gMutex); 617 SkAutoMutexAcquire ama(gMutex);
617 618
618 if (NULL == gCache) { 619 if (NULL == gCache) {
619 gCache = SkNEW_ARGS(SkBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS)); 620 gCache = SkNEW_ARGS(SkBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS));
620 } 621 }
621 size_t size = count * sizeof(int32_t); 622 size_t size = count * sizeof(int32_t);
622 623
623 if (!gCache->find(storage.get(), size, bitmap)) { 624 if (!gCache->find(storage.get(), size, bitmap)) {
624 // force our cahce32pixelref to be built 625 // force our cahce32pixelref to be built
625 (void)this->getCache32(); 626 (void)this->getCache32();
626 bitmap->installPixelRef(fCache32PixelRef); 627 bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
628 bitmap->setPixelRef(fCache32PixelRef);
627 629
628 gCache->add(storage.get(), size, *bitmap); 630 gCache->add(storage.get(), size, *bitmap);
629 } 631 }
630 } 632 }
631 633
632 void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const { 634 void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const {
633 if (info) { 635 if (info) {
634 if (info->fColorCount >= fColorCount) { 636 if (info->fColorCount >= fColorCount) {
635 if (info->fColors) { 637 if (info->fColors) {
636 memcpy(info->fColors, fOrigColors, fColorCount * sizeof(SkColor) ); 638 memcpy(info->fColors, fOrigColors, fColorCount * sizeof(SkColor) );
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 (*stops)[i] = stop; 1138 (*stops)[i] = stop;
1137 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1139 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1138 } 1140 }
1139 } 1141 }
1140 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1142 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1141 1143
1142 return outColors; 1144 return outColors;
1143 } 1145 }
1144 1146
1145 #endif 1147 #endif
OLDNEW
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | src/image/SkImagePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698