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

Side by Side Diff: src/core/SkBitmap.cpp

Issue 471473002: Optimize CSS box-shadow performance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: store SkMask and SkCachedData in cache Created 6 years, 2 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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 srcM.fBounds.set(0, 0, this->width(), this->height()); 1099 srcM.fBounds.set(0, 0, this->width(), this->height());
1100 srcM.fRowBytes = SkAlign4(this->width()); 1100 srcM.fRowBytes = SkAlign4(this->width());
1101 srcM.fFormat = SkMask::kA8_Format; 1101 srcM.fFormat = SkMask::kA8_Format;
1102 1102
1103 SkMaskFilter* filter = paint ? paint->getMaskFilter() : NULL; 1103 SkMaskFilter* filter = paint ? paint->getMaskFilter() : NULL;
1104 1104
1105 // compute our (larger?) dst bounds if we have a filter 1105 // compute our (larger?) dst bounds if we have a filter
1106 if (filter) { 1106 if (filter) {
1107 identity.reset(); 1107 identity.reset();
1108 srcM.fImage = NULL; 1108 srcM.fImage = NULL;
1109 if (!filter->filterMask(&dstM, srcM, identity, NULL)) { 1109 if (!filter->filterMask(&dstM, srcM, identity, NULL, NULL)) {
1110 goto NO_FILTER_CASE; 1110 goto NO_FILTER_CASE;
1111 } 1111 }
1112 dstM.fRowBytes = SkAlign4(dstM.fBounds.width()); 1112 dstM.fRowBytes = SkAlign4(dstM.fBounds.width());
1113 } else { 1113 } else {
1114 NO_FILTER_CASE: 1114 NO_FILTER_CASE:
1115 tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), sr cM.fRowBytes); 1115 tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), sr cM.fRowBytes);
1116 if (!tmpBitmap.tryAllocPixels(allocator, NULL)) { 1116 if (!tmpBitmap.tryAllocPixels(allocator, NULL)) {
1117 // Allocation of pixels for alpha bitmap failed. 1117 // Allocation of pixels for alpha bitmap failed.
1118 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n", 1118 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
1119 tmpBitmap.width(), tmpBitmap.height()); 1119 tmpBitmap.width(), tmpBitmap.height());
1120 return false; 1120 return false;
1121 } 1121 }
1122 GetBitmapAlpha(*this, tmpBitmap.getAddr8(0, 0), srcM.fRowBytes); 1122 GetBitmapAlpha(*this, tmpBitmap.getAddr8(0, 0), srcM.fRowBytes);
1123 if (offset) { 1123 if (offset) {
1124 offset->set(0, 0); 1124 offset->set(0, 0);
1125 } 1125 }
1126 tmpBitmap.swap(*dst); 1126 tmpBitmap.swap(*dst);
1127 return true; 1127 return true;
1128 } 1128 }
1129 srcM.fImage = SkMask::AllocImage(srcM.computeImageSize()); 1129 srcM.fImage = SkMask::AllocImage(srcM.computeImageSize());
1130 SkAutoMaskFreeImage srcCleanup(srcM.fImage); 1130 SkAutoMaskFreeImage srcCleanup(srcM.fImage);
1131 1131
1132 GetBitmapAlpha(*this, srcM.fImage, srcM.fRowBytes); 1132 GetBitmapAlpha(*this, srcM.fImage, srcM.fRowBytes);
1133 if (!filter->filterMask(&dstM, srcM, identity, NULL)) { 1133 if (!filter->filterMask(&dstM, srcM, identity, NULL, NULL)) {
1134 goto NO_FILTER_CASE; 1134 goto NO_FILTER_CASE;
1135 } 1135 }
1136 SkAutoMaskFreeImage dstCleanup(dstM.fImage); 1136 SkAutoMaskFreeImage dstCleanup(dstM.fImage);
1137 1137
1138 tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.hei ght()), 1138 tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.hei ght()),
1139 dstM.fRowBytes); 1139 dstM.fRowBytes);
1140 if (!tmpBitmap.tryAllocPixels(allocator, NULL)) { 1140 if (!tmpBitmap.tryAllocPixels(allocator, NULL)) {
1141 // Allocation of pixels for alpha bitmap failed. 1141 // Allocation of pixels for alpha bitmap failed.
1142 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n", 1142 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
1143 tmpBitmap.width(), tmpBitmap.height()); 1143 tmpBitmap.width(), tmpBitmap.height());
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 /////////////////////////////////////////////////////////////////////////////// 1380 ///////////////////////////////////////////////////////////////////////////////
1381 1381
1382 #ifdef SK_DEBUG 1382 #ifdef SK_DEBUG
1383 void SkImageInfo::validate() const { 1383 void SkImageInfo::validate() const {
1384 SkASSERT(fWidth >= 0); 1384 SkASSERT(fWidth >= 0);
1385 SkASSERT(fHeight >= 0); 1385 SkASSERT(fHeight >= 0);
1386 SkASSERT(SkColorTypeIsValid(fColorType)); 1386 SkASSERT(SkColorTypeIsValid(fColorType));
1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1388 } 1388 }
1389 #endif 1389 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698