Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 fDeviceClipBounds = qr_clip_bounds(device->getGlobalBounds()); | 689 fDeviceClipBounds = qr_clip_bounds(device->getGlobalBounds()); |
| 690 } | 690 } |
| 691 | 691 |
| 692 return device; | 692 return device; |
| 693 } | 693 } |
| 694 | 694 |
| 695 SkCanvas::SkCanvas() | 695 SkCanvas::SkCanvas() |
| 696 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 696 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 697 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 697 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 698 , fConservativeRasterClip(false) | 698 , fConservativeRasterClip(false) |
| 699 , fLayerAllocator(nullptr) | |
|
reed1
2016/09/16 13:15:00
Are any of these (nullptr) initializers needed, gi
tomhudson
2016/09/28 21:23:57
Done.
| |
| 699 { | 700 { |
| 700 inc_canvas(); | 701 inc_canvas(); |
| 701 | 702 |
| 702 this->init(nullptr, kDefault_InitFlags); | 703 this->init(nullptr, kDefault_InitFlags); |
| 703 } | 704 } |
| 704 | 705 |
| 705 static SkBitmap make_nopixels(int width, int height) { | 706 static SkBitmap make_nopixels(int width, int height) { |
| 706 SkBitmap bitmap; | 707 SkBitmap bitmap; |
| 707 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); | 708 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); |
| 708 return bitmap; | 709 return bitmap; |
| 709 } | 710 } |
| 710 | 711 |
| 711 class SkNoPixelsBitmapDevice : public SkBitmapDevice { | 712 class SkNoPixelsBitmapDevice : public SkBitmapDevice { |
| 712 public: | 713 public: |
| 713 SkNoPixelsBitmapDevice(const SkIRect& bounds, const SkSurfaceProps& surfaceP rops) | 714 SkNoPixelsBitmapDevice(const SkIRect& bounds, const SkSurfaceProps& surfaceP rops) |
| 714 : INHERITED(make_nopixels(bounds.width(), bounds.height()), surfaceProps ) | 715 : INHERITED(make_nopixels(bounds.width(), bounds.height()), surfaceProps ) |
| 715 { | 716 { |
| 716 this->setOrigin(bounds.x(), bounds.y()); | 717 this->setOrigin(bounds.x(), bounds.y()); |
| 717 } | 718 } |
| 718 | 719 |
| 719 private: | 720 private: |
| 720 | 721 |
| 721 typedef SkBitmapDevice INHERITED; | 722 typedef SkBitmapDevice INHERITED; |
| 722 }; | 723 }; |
| 723 | 724 |
| 724 SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props) | 725 SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props) |
| 725 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 726 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 726 , fProps(SkSurfacePropsCopyOrDefault(props)) | 727 , fProps(SkSurfacePropsCopyOrDefault(props)) |
| 727 , fConservativeRasterClip(false) | 728 , fConservativeRasterClip(false) |
| 729 , fLayerAllocator(nullptr) | |
| 728 { | 730 { |
| 729 inc_canvas(); | 731 inc_canvas(); |
| 730 | 732 |
| 731 this->init(new SkNoPixelsBitmapDevice(SkIRect::MakeWH(width, height), fProps ), | 733 this->init(new SkNoPixelsBitmapDevice(SkIRect::MakeWH(width, height), fProps ), |
| 732 kDefault_InitFlags)->unref(); | 734 kDefault_InitFlags)->unref(); |
| 733 } | 735 } |
| 734 | 736 |
| 735 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags) | 737 SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags) |
| 736 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 738 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 737 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 739 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 738 , fConservativeRasterClip(false) | 740 , fConservativeRasterClip(false) |
| 741 , fLayerAllocator(nullptr) | |
| 739 { | 742 { |
| 740 inc_canvas(); | 743 inc_canvas(); |
| 741 | 744 |
| 742 this->init(new SkNoPixelsBitmapDevice(bounds, fProps), flags)->unref(); | 745 this->init(new SkNoPixelsBitmapDevice(bounds, fProps), flags)->unref(); |
| 743 } | 746 } |
| 744 | 747 |
| 745 SkCanvas::SkCanvas(SkBaseDevice* device) | 748 SkCanvas::SkCanvas(SkBaseDevice* device) |
| 746 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 749 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 747 , fProps(device->surfaceProps()) | 750 , fProps(device->surfaceProps()) |
| 748 , fConservativeRasterClip(false) | 751 , fConservativeRasterClip(false) |
| 752 , fLayerAllocator(nullptr) | |
| 749 { | 753 { |
| 750 inc_canvas(); | 754 inc_canvas(); |
| 751 | 755 |
| 752 this->init(device, kDefault_InitFlags); | 756 this->init(device, kDefault_InitFlags); |
| 753 } | 757 } |
| 754 | 758 |
| 755 SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags) | 759 SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags) |
| 756 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 760 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 757 , fProps(device->surfaceProps()) | 761 , fProps(device->surfaceProps()) |
| 758 , fConservativeRasterClip(false) | 762 , fConservativeRasterClip(false) |
| 763 , fLayerAllocator(nullptr) | |
| 759 { | 764 { |
| 760 inc_canvas(); | 765 inc_canvas(); |
| 761 | 766 |
| 762 this->init(device, flags); | 767 this->init(device, flags); |
| 763 } | 768 } |
| 764 | 769 |
| 765 SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props) | 770 SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props) |
| 766 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 771 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 767 , fProps(props) | 772 , fProps(props) |
| 768 , fConservativeRasterClip(false) | 773 , fConservativeRasterClip(false) |
| 774 , fLayerAllocator(nullptr) | |
| 769 { | 775 { |
| 770 inc_canvas(); | 776 inc_canvas(); |
| 771 | 777 |
| 772 SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps)); | 778 SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps)); |
| 773 this->init(device, kDefault_InitFlags); | 779 this->init(device, kDefault_InitFlags); |
| 774 } | 780 } |
| 775 | 781 |
| 776 SkCanvas::SkCanvas(const SkBitmap& bitmap) | 782 SkCanvas::SkCanvas(const SkBitmap& bitmap) |
| 777 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 783 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 778 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 784 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 779 , fConservativeRasterClip(false) | 785 , fConservativeRasterClip(false) |
| 786 , fLayerAllocator(nullptr) | |
| 780 { | 787 { |
| 781 inc_canvas(); | 788 inc_canvas(); |
| 782 | 789 |
| 790 SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps)); | |
| 791 this->init(device, kDefault_InitFlags); | |
| 792 } | |
| 793 | |
| 794 SkCanvas::SkCanvas(const SkBitmap& bitmap, | |
| 795 SkRasterCanvasLayerAllocator* allocator) | |
| 796 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | |
| 797 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | |
| 798 , fConservativeRasterClip(false) | |
| 799 , fLayerAllocator(allocator) | |
| 800 { | |
| 801 inc_canvas(); | |
| 802 | |
|
tomhudson
2016/09/16 12:48:28
Should probably put an SkASSERT() here to guarante
| |
| 783 SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps)); | 803 SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps)); |
| 784 this->init(device, kDefault_InitFlags); | 804 this->init(device, kDefault_InitFlags); |
| 785 } | 805 } |
| 786 | 806 |
| 787 SkCanvas::~SkCanvas() { | 807 SkCanvas::~SkCanvas() { |
| 788 // free up the contents of our deque | 808 // free up the contents of our deque |
| 789 this->restoreToCount(1); // restore everything but the last | 809 this->restoreToCount(1); // restore everything but the last |
| 790 | 810 |
| 791 this->internalRestore(); // restore the last, since we're going away | 811 this->internalRestore(); // restore the last, since we're going away |
| 792 | 812 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1259 SkImageInfo info = make_layer_info(priorDevice->imageInfo(), ir.width(), ir. height(), isOpaque, | 1279 SkImageInfo info = make_layer_info(priorDevice->imageInfo(), ir.width(), ir. height(), isOpaque, |
| 1260 paint); | 1280 paint); |
| 1261 | 1281 |
| 1262 SkAutoTUnref<SkBaseDevice> newDevice; | 1282 SkAutoTUnref<SkBaseDevice> newDevice; |
| 1263 { | 1283 { |
| 1264 const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() || | 1284 const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() || |
| 1265 (saveLayerFlags & kPreserveLCDText_SaveLaye rFlag); | 1285 (saveLayerFlags & kPreserveLCDText_SaveLaye rFlag); |
| 1266 const SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; | 1286 const SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; |
| 1267 const SkBaseDevice::CreateInfo createInfo = SkBaseDevice::CreateInfo(inf o, usage, geo, | 1287 const SkBaseDevice::CreateInfo createInfo = SkBaseDevice::CreateInfo(inf o, usage, geo, |
| 1268 pre serveLCDText); | 1288 pre serveLCDText); |
| 1269 newDevice.reset(priorDevice->onCreateDevice(createInfo, paint)); | 1289 newDevice.reset(priorDevice->onCreateDevice(createInfo, paint, fLayerAll ocator.get())); |
| 1270 if (!newDevice) { | 1290 if (!newDevice) { |
| 1271 SkErrorInternals::SetError(kInternalError_SkError, | 1291 SkErrorInternals::SetError(kInternalError_SkError, |
| 1272 "Unable to create device for layer."); | 1292 "Unable to create device for layer."); |
| 1273 return; | 1293 return; |
| 1274 } | 1294 } |
| 1275 } | 1295 } |
| 1276 newDevice->setOrigin(ir.fLeft, ir.fTop); | 1296 newDevice->setOrigin(ir.fLeft, ir.fTop); |
| 1277 | 1297 |
| 1278 DeviceCM* layer = new DeviceCM(newDevice, paint, this, fConservativeRasterCl ip, stashedMatrix); | 1298 DeviceCM* layer = new DeviceCM(newDevice, paint, this, fConservativeRasterCl ip, stashedMatrix); |
| 1279 | 1299 |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3504 | 3524 |
| 3505 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3525 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3506 fCanvas->restoreToCount(fSaveCount); | 3526 fCanvas->restoreToCount(fSaveCount); |
| 3507 } | 3527 } |
| 3508 | 3528 |
| 3509 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3529 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
| 3510 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { | 3530 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { |
| 3511 return this->makeSurface(info, props).release(); | 3531 return this->makeSurface(info, props).release(); |
| 3512 } | 3532 } |
| 3513 #endif | 3533 #endif |
| OLD | NEW |