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

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

Issue 1074983003: add SkPixmap and external locking to bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 * 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 #define __STDC_LIMIT_MACROS 7 #define __STDC_LIMIT_MACROS
8 8
9 #include "SkDraw.h" 9 #include "SkDraw.h"
10 #include "SkBlitter.h" 10 #include "SkBlitter.h"
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } 1145 }
1146 1146
1147 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, 1147 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
1148 const SkPaint& paint) const { 1148 const SkPaint& paint) const {
1149 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType); 1149 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
1150 1150
1151 if (just_translate(*fMatrix, bitmap)) { 1151 if (just_translate(*fMatrix, bitmap)) {
1152 int ix = SkScalarRoundToInt(fMatrix->getTranslateX()); 1152 int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
1153 int iy = SkScalarRoundToInt(fMatrix->getTranslateY()); 1153 int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
1154 1154
1155 SkAutoLockPixels alp(bitmap); 1155 SkAutoBitmapLockResult result;
1156 if (!bitmap.readyToDraw()) { 1156 if (!bitmap.requestLock(&result)) {
1157 return; 1157 return;
1158 } 1158 }
1159 1159 const SkPixmap& pmap = result.pixmap();
1160 SkMask mask; 1160 SkMask mask;
1161 mask.fBounds.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); 1161 mask.fBounds.set(ix, iy, ix + pmap.width(), iy + pmap.height());
1162 mask.fFormat = SkMask::kA8_Format; 1162 mask.fFormat = SkMask::kA8_Format;
1163 mask.fRowBytes = SkToU32(bitmap.rowBytes()); 1163 mask.fRowBytes = SkToU32(pmap.rowBytes());
1164 mask.fImage = bitmap.getAddr8(0, 0); 1164 // fImage is typed as writable, but in this case it is used read-only
1165 mask.fImage = (uint8_t*)pmap.addr8(0, 0);
1165 1166
1166 this->drawDevMask(mask, paint); 1167 this->drawDevMask(mask, paint);
1167 } else { // need to xform the bitmap first 1168 } else { // need to xform the bitmap first
1168 SkRect r; 1169 SkRect r;
1169 SkMask mask; 1170 SkMask mask;
1170 1171
1171 r.set(0, 0, 1172 r.set(0, 0,
1172 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); 1173 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()));
1173 fMatrix->mapRect(&r); 1174 fMatrix->mapRect(&r);
1174 r.round(&mask.fBounds); 1175 r.round(&mask.fBounds);
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 mask->fImage = SkMask::AllocImage(size); 2264 mask->fImage = SkMask::AllocImage(size);
2264 memset(mask->fImage, 0, mask->computeImageSize()); 2265 memset(mask->fImage, 0, mask->computeImageSize());
2265 } 2266 }
2266 2267
2267 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2268 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2268 draw_into_mask(*mask, devPath, style); 2269 draw_into_mask(*mask, devPath, style);
2269 } 2270 }
2270 2271
2271 return true; 2272 return true;
2272 } 2273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698