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

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

Issue 1391333004: remove internalDrawBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | 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 2008 The Android Open Source Project 2 * Copyright 2008 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 bool SkAutoROCanvasPixels::asROBitmap(SkBitmap* bitmap) const { 1278 bool SkAutoROCanvasPixels::asROBitmap(SkBitmap* bitmap) const {
1279 if (fAddr) { 1279 if (fAddr) {
1280 return bitmap->installPixels(fInfo, const_cast<void*>(fAddr), fRowBytes) ; 1280 return bitmap->installPixels(fInfo, const_cast<void*>(fAddr), fRowBytes) ;
1281 } else { 1281 } else {
1282 bitmap->reset(); 1282 bitmap->reset();
1283 return false; 1283 return false;
1284 } 1284 }
1285 } 1285 }
1286 1286
1287 ///////////////////////////////////////////////////////////////////////////// 1287 /////////////////////////////////////////////////////////////////////////////
1288 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
1289 const SkMatrix& matrix, const SkPaint* paint) {
1290 if (bitmap.drawsNothing()) {
1291 return;
1292 }
1293
1294 SkLazyPaint lazy;
1295 if (nullptr == paint) {
1296 paint = lazy.init();
1297 }
1298
1299 SkDEBUGCODE(bitmap.validate();)
1300
1301 SkRect storage;
1302 const SkRect* bounds = nullptr;
1303 if (paint && paint->canComputeFastBounds()) {
1304 bitmap.getBounds(&storage);
1305 matrix.mapRect(&storage);
1306 bounds = &paint->computeFastBounds(storage, &storage);
1307 }
1308
1309 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
1310
1311 while (iter.next()) {
1312 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint());
1313 }
1314
1315 LOOPER_END
1316 }
1317 1288
1318 void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, 1289 void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
1319 const SkPaint* paint, bool deviceIsBitmapDevic e) { 1290 const SkPaint* paint, bool deviceIsBitmapDevic e) {
1320 SkPaint tmp; 1291 SkPaint tmp;
1321 if (nullptr == paint) { 1292 if (nullptr == paint) {
1322 paint = &tmp; 1293 paint = &tmp;
1323 } 1294 }
1324 1295
1325 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1296 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1326 while (iter.next()) { 1297 while (iter.next()) {
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const raint); 2160 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const raint);
2190 } 2161 }
2191 2162
2192 LOOPER_END 2163 LOOPER_END
2193 } 2164 }
2194 2165
2195 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) { 2166 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) {
2196 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); 2167 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()");
2197 SkDEBUGCODE(bitmap.validate();) 2168 SkDEBUGCODE(bitmap.validate();)
2198 2169
2199 if (nullptr == paint || paint->canComputeFastBounds()) { 2170 if (bitmap.drawsNothing()) {
2200 SkRect bounds = { 2171 return;
2201 x, y, 2172 }
2202 x + SkIntToScalar(bitmap.width()), 2173
2203 y + SkIntToScalar(bitmap.height()) 2174 SkLazyPaint lazy;
2204 }; 2175 if (nullptr == paint) {
2205 if (paint) { 2176 paint = lazy.init();
2206 (void)paint->computeFastBounds(bounds, &bounds); 2177 }
2207 } 2178
2208 if (this->quickReject(bounds)) { 2179 const SkMatrix matrix = SkMatrix::MakeTrans(x, y);
2180
2181 SkRect storage;
2182 const SkRect* bounds = nullptr;
2183 if (paint->canComputeFastBounds()) {
2184 bitmap.getBounds(&storage);
2185 matrix.mapRect(&storage);
2186 bounds = &paint->computeFastBounds(storage, &storage);
2187 if (this->quickReject(*bounds)) {
2209 return; 2188 return;
2210 } 2189 }
2211 } 2190 }
2212 2191
2213 SkMatrix matrix; 2192 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
2214 matrix.setTranslate(x, y); 2193
2215 this->internalDrawBitmap(bitmap, matrix, paint); 2194 while (iter.next()) {
2195 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint());
2196 }
2197
2198 LOOPER_END
2216 } 2199 }
2217 2200
2218 // this one is non-virtual, so it can be called safely by other canvas apis 2201 // this one is non-virtual, so it can be called safely by other canvas apis
2219 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 2202 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
2220 const SkRect& dst, const SkPaint* paint, 2203 const SkRect& dst, const SkPaint* paint,
2221 SrcRectConstraint constraint) { 2204 SrcRectConstraint constraint) {
2222 if (bitmap.drawsNothing() || dst.isEmpty()) { 2205 if (bitmap.drawsNothing() || dst.isEmpty()) {
2223 return; 2206 return;
2224 } 2207 }
2225 2208
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 } 2880 }
2898 2881
2899 if (matrix) { 2882 if (matrix) {
2900 canvas->concat(*matrix); 2883 canvas->concat(*matrix);
2901 } 2884 }
2902 } 2885 }
2903 2886
2904 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2887 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2905 fCanvas->restoreToCount(fSaveCount); 2888 fCanvas->restoreToCount(fSaveCount);
2906 } 2889 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698