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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 } | 849 } |
850 | 850 |
851 SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { | 851 SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { |
852 if (updateMatrixClip) { | 852 if (updateMatrixClip) { |
853 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); | 853 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); |
854 } | 854 } |
855 return fMCRec->fTopLayer->fDevice; | 855 return fMCRec->fTopLayer->fDevice; |
856 } | 856 } |
857 | 857 |
858 bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) { | 858 bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) { |
859 if (kUnknown_SkColorType == bitmap->colorType() || bitmap->getTexture()) { | 859 if (kUnknown_SkColorType == bitmap->colorType()) { |
860 return false; | 860 return false; |
861 } | 861 } |
862 | 862 |
863 bool weAllocated = false; | 863 bool weAllocated = false; |
864 if (nullptr == bitmap->pixelRef()) { | 864 if (nullptr == bitmap->pixelRef()) { |
865 if (!bitmap->tryAllocPixels()) { | 865 if (!bitmap->tryAllocPixels()) { |
866 return false; | 866 return false; |
867 } | 867 } |
868 weAllocated = true; | 868 weAllocated = true; |
869 } | 869 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 SkReadPixelsRec rec(dstInfo, dstP, rowBytes, x, y); | 911 SkReadPixelsRec rec(dstInfo, dstP, rowBytes, x, y); |
912 if (!rec.trim(size.width(), size.height())) { | 912 if (!rec.trim(size.width(), size.height())) { |
913 return false; | 913 return false; |
914 } | 914 } |
915 | 915 |
916 // The device can assert that the requested area is always contained in its
bounds | 916 // The device can assert that the requested area is always contained in its
bounds |
917 return device->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec
.fY); | 917 return device->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec
.fY); |
918 } | 918 } |
919 | 919 |
920 bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) { | 920 bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) { |
921 if (bitmap.getTexture()) { | |
922 return false; | |
923 } | |
924 | |
925 SkAutoPixmapUnlock unlocker; | 921 SkAutoPixmapUnlock unlocker; |
926 if (bitmap.requestLock(&unlocker)) { | 922 if (bitmap.requestLock(&unlocker)) { |
927 const SkPixmap& pm = unlocker.pixmap(); | 923 const SkPixmap& pm = unlocker.pixmap(); |
928 return this->writePixels(pm.info(), pm.addr(), pm.rowBytes(), x, y); | 924 return this->writePixels(pm.info(), pm.addr(), pm.rowBytes(), x, y); |
929 } | 925 } |
930 return false; | 926 return false; |
931 } | 927 } |
932 | 928 |
933 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size
_t rowBytes, | 929 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size
_t rowBytes, |
934 int x, int y) { | 930 int x, int y) { |
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3134 | 3130 |
3135 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3131 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3136 fCanvas->restoreToCount(fSaveCount); | 3132 fCanvas->restoreToCount(fSaveCount); |
3137 } | 3133 } |
3138 | 3134 |
3139 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3135 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3140 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3136 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3141 return this->makeSurface(info, props).release(); | 3137 return this->makeSurface(info, props).release(); |
3142 } | 3138 } |
3143 #endif | 3139 #endif |
OLD | NEW |