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

Unified Diff: src/effects/gradients/SkGradientShader.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: src/effects/gradients/SkGradientShader.cpp
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 27761993461ba7761a8afc57c36eac9ec2754cc4..e8fbb98ca1d0255d393f46c04e848f2f587c7c95 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -513,13 +513,17 @@ const uint16_t* SkGradientShaderBase::getCache16() const {
const SkPMColor* SkGradientShaderBase::getCache32() const {
if (fCache32 == NULL) {
- // double the count for dither entries
- const int entryCount = kCache32Count * 4;
- const size_t allocSize = sizeof(SkPMColor) * entryCount;
+ const size_t rowBytes = kCache32Count * sizeof(SkPMColor);
+
+ SkImageInfo info;
+ info.fWidth = kCache32Count;
+ info.fHeight = 4; // for our 4 dither rows
+ info.fAlphaType = kPremul_SkAlphaType;
+ info.fColorType = kPMColor_SkColorType;
if (NULL == fCache32PixelRef) {
scroggo 2013/11/19 18:17:09 If fCache32PixelRef exists, should we get info fro
reed1 2013/11/20 20:56:56 not sure it matters, since it is always the same.
fCache32PixelRef = SkNEW_ARGS(SkMallocPixelRef,
- (NULL, allocSize, NULL));
+ (info, NULL, rowBytes, NULL, true));
}
fCache32 = (SkPMColor*)fCache32PixelRef->getAddr();
if (fColorCount == 2) {
@@ -542,7 +546,7 @@ const SkPMColor* SkGradientShaderBase::getCache32() const {
if (fMapper) {
SkMallocPixelRef* newPR = SkNEW_ARGS(SkMallocPixelRef,
- (NULL, allocSize, NULL));
+ (info, NULL, rowBytes, NULL, true));
SkPMColor* linear = fCache32; // just computed linear data
SkPMColor* mapped = (SkPMColor*)newPR->getAddr(); // storage for mapped data
SkUnitMapper* map = fMapper;

Powered by Google App Engine
This is Rietveld 408576698