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/effects/gradients/SkGradientShader.cpp

Issue 129423002: add SkBitmap::installPixelRef() (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->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1); 586 bitmap->installPixelRef(fCache32PixelRef);
587 bitmap->setPixelRef(fCache32PixelRef);
588 return; 587 return;
589 } 588 }
590 589
591 // build our key: [numColors + colors[] + {positions[]} + flags ] 590 // build our key: [numColors + colors[] + {positions[]} + flags ]
592 int count = 1 + fColorCount + 1; 591 int count = 1 + fColorCount + 1;
593 if (fColorCount > 2) { 592 if (fColorCount > 2) {
594 count += fColorCount - 1; // fRecs[].fPos 593 count += fColorCount - 1; // fRecs[].fPos
595 } 594 }
596 595
597 SkAutoSTMalloc<16, int32_t> storage(count); 596 SkAutoSTMalloc<16, int32_t> storage(count);
(...skipping 19 matching lines...) Expand all
617 SkAutoMutexAcquire ama(gMutex); 616 SkAutoMutexAcquire ama(gMutex);
618 617
619 if (NULL == gCache) { 618 if (NULL == gCache) {
620 gCache = SkNEW_ARGS(SkBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS)); 619 gCache = SkNEW_ARGS(SkBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS));
621 } 620 }
622 size_t size = count * sizeof(int32_t); 621 size_t size = count * sizeof(int32_t);
623 622
624 if (!gCache->find(storage.get(), size, bitmap)) { 623 if (!gCache->find(storage.get(), size, bitmap)) {
625 // force our cahce32pixelref to be built 624 // force our cahce32pixelref to be built
626 (void)this->getCache32(); 625 (void)this->getCache32();
627 bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1); 626 bitmap->installPixelRef(fCache32PixelRef);
628 bitmap->setPixelRef(fCache32PixelRef);
629 627
630 gCache->add(storage.get(), size, *bitmap); 628 gCache->add(storage.get(), size, *bitmap);
631 } 629 }
632 } 630 }
633 631
634 void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const { 632 void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const {
635 if (info) { 633 if (info) {
636 if (info->fColorCount >= fColorCount) { 634 if (info->fColorCount >= fColorCount) {
637 if (info->fColors) { 635 if (info->fColors) {
638 memcpy(info->fColors, fOrigColors, fColorCount * sizeof(SkColor) ); 636 memcpy(info->fColors, fOrigColors, fColorCount * sizeof(SkColor) );
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 (*stops)[i] = stop; 1136 (*stops)[i] = stop;
1139 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1137 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1140 } 1138 }
1141 } 1139 }
1142 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1140 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1143 1141
1144 return outColors; 1142 return outColors;
1145 } 1143 }
1146 1144
1147 #endif 1145 #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