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

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

Issue 1201983006: Clean up usage of SkSurfaceProps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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/effects/SkPictureImageFilter.h ('k') | src/core/SkDevice.cpp » ('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 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 SkASSERT(sizeof(DeviceCM) <= sizeof(fDeviceCMStorage)); 530 SkASSERT(sizeof(DeviceCM) <= sizeof(fDeviceCMStorage));
531 fMCRec->fLayer = (DeviceCM*)fDeviceCMStorage; 531 fMCRec->fLayer = (DeviceCM*)fDeviceCMStorage;
532 new (fDeviceCMStorage) DeviceCM(NULL, NULL, NULL, fConservativeRasterClip, f alse); 532 new (fDeviceCMStorage) DeviceCM(NULL, NULL, NULL, fConservativeRasterClip, f alse);
533 533
534 fMCRec->fTopLayer = fMCRec->fLayer; 534 fMCRec->fTopLayer = fMCRec->fLayer;
535 535
536 fSurfaceBase = NULL; 536 fSurfaceBase = NULL;
537 537
538 if (device) { 538 if (device) {
539 // TODO: remove this - the root device & canvas should always have same surfaceProps 539 // The root device and the canvas should always have the same pixel geom etry
540 device->initForRootLayer(fProps.pixelGeometry()); 540 SkASSERT(fProps.pixelGeometry() == device->surfaceProps().pixelGeometry( ));
541 if (device->forceConservativeRasterClip()) { 541 if (device->forceConservativeRasterClip()) {
542 fConservativeRasterClip = true; 542 fConservativeRasterClip = true;
543 } 543 }
544 device->onAttachToCanvas(this); 544 device->onAttachToCanvas(this);
545 fMCRec->fLayer->fDevice = SkRef(device); 545 fMCRec->fLayer->fDevice = SkRef(device);
546 fMCRec->fRasterClip.setRect(device->getGlobalBounds()); 546 fMCRec->fRasterClip.setRect(device->getGlobalBounds());
547 } 547 }
548 return device; 548 return device;
549 } 549 }
550 550
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 588
589 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags) 589 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
590 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 590 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
591 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) 591 , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
592 { 592 {
593 inc_canvas(); 593 inc_canvas();
594 594
595 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds, fProps)), flags)->unr ef(); 595 this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds, fProps)), flags)->unr ef();
596 } 596 }
597 597
598 // TODO: remove this ctor
599 SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags)
600 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
601 , fProps(SkSurfacePropsCopyOrDefault(props))
602 {
603 inc_canvas();
604
605 this->init(device, flags);
606 }
607
608 SkCanvas::SkCanvas(SkBaseDevice* device) 598 SkCanvas::SkCanvas(SkBaseDevice* device)
609 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) 599 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
610 , fProps(device->surfaceProps()) 600 , fProps(device->surfaceProps())
611 { 601 {
612 inc_canvas(); 602 inc_canvas();
613 603
614 this->init(device, kDefault_InitFlags); 604 this->init(device, kDefault_InitFlags);
615 } 605 }
616 606
617 SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags) 607 SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 paint = &tmp; 1239 paint = &tmp;
1250 } 1240 }
1251 1241
1252 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1242 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1253 while (iter.next()) { 1243 while (iter.next()) {
1254 SkBaseDevice* dstDev = iter.fDevice; 1244 SkBaseDevice* dstDev = iter.fDevice;
1255 paint = &looper.paint(); 1245 paint = &looper.paint();
1256 SkImageFilter* filter = paint->getImageFilter(); 1246 SkImageFilter* filter = paint->getImageFilter();
1257 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1247 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1258 if (filter && !dstDev->canHandleImageFilter(filter)) { 1248 if (filter && !dstDev->canHandleImageFilter(filter)) {
1259 SkImageFilter::Proxy proxy(dstDev, fProps); 1249 SkImageFilter::Proxy proxy(dstDev);
1260 SkBitmap dst; 1250 SkBitmap dst;
1261 SkIPoint offset = SkIPoint::Make(0, 0); 1251 SkIPoint offset = SkIPoint::Make(0, 0);
1262 const SkBitmap& src = srcDev->accessBitmap(false); 1252 const SkBitmap& src = srcDev->accessBitmap(false);
1263 SkMatrix matrix = *iter.fMatrix; 1253 SkMatrix matrix = *iter.fMatrix;
1264 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1254 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1265 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ()); 1255 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ());
1266 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ()); 1256 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ());
1267 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); 1257 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1268 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { 1258 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
1269 SkPaint tmpUnfiltered(*paint); 1259 SkPaint tmpUnfiltered(*paint);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 paint = &tmp; 1291 paint = &tmp;
1302 } 1292 }
1303 1293
1304 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1294 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1305 1295
1306 while (iter.next()) { 1296 while (iter.next()) {
1307 paint = &looper.paint(); 1297 paint = &looper.paint();
1308 SkImageFilter* filter = paint->getImageFilter(); 1298 SkImageFilter* filter = paint->getImageFilter();
1309 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1299 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1310 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1300 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1311 SkImageFilter::Proxy proxy(iter.fDevice, fProps); 1301 SkImageFilter::Proxy proxy(iter.fDevice);
1312 SkBitmap dst; 1302 SkBitmap dst;
1313 SkIPoint offset = SkIPoint::Make(0, 0); 1303 SkIPoint offset = SkIPoint::Make(0, 0);
1314 SkMatrix matrix = *iter.fMatrix; 1304 SkMatrix matrix = *iter.fMatrix;
1315 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1305 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1316 const SkIRect clipBounds = bitmap.bounds(); 1306 const SkIRect clipBounds = bitmap.bounds();
1317 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte rCache()); 1307 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte rCache());
1318 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); 1308 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1319 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { 1309 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
1320 SkPaint tmpUnfiltered(*paint); 1310 SkPaint tmpUnfiltered(*paint);
1321 tmpUnfiltered.setImageFilter(NULL); 1311 tmpUnfiltered.setImageFilter(NULL);
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 } 2712 }
2723 2713
2724 if (matrix) { 2714 if (matrix) {
2725 canvas->concat(*matrix); 2715 canvas->concat(*matrix);
2726 } 2716 }
2727 } 2717 }
2728 2718
2729 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2719 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2730 fCanvas->restoreToCount(fSaveCount); 2720 fCanvas->restoreToCount(fSaveCount);
2731 } 2721 }
OLDNEW
« no previous file with comments | « include/effects/SkPictureImageFilter.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698