| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 | 1033 |
| 1034 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) { | 1034 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) { |
| 1035 return this->onPeekPixels(info, rowBytes); | 1035 return this->onPeekPixels(info, rowBytes); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) { | 1038 const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) { |
| 1039 SkBaseDevice* dev = this->getDevice(); | 1039 SkBaseDevice* dev = this->getDevice(); |
| 1040 return dev ? dev->peekPixels(info, rowBytes) : NULL; | 1040 return dev ? dev->peekPixels(info, rowBytes) : NULL; |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) { |
| 1044 return this->onAccessTopLayerPixels(info, rowBytes); |
| 1045 } |
| 1046 |
| 1047 void* SkCanvas::onAccessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) { |
| 1048 SkBaseDevice* dev = this->getTopDevice(); |
| 1049 return dev ? dev->accessPixels(info, rowBytes) : NULL; |
| 1050 } |
| 1051 |
| 1043 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) { | 1052 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) { |
| 1044 fAddr = canvas->peekPixels(&fInfo, &fRowBytes); | 1053 fAddr = canvas->peekPixels(&fInfo, &fRowBytes); |
| 1045 if (NULL == fAddr) { | 1054 if (NULL == fAddr) { |
| 1046 fInfo = canvas->imageInfo(); | 1055 fInfo = canvas->imageInfo(); |
| 1047 if (kUnknown_SkColorType == fInfo.colorType() || | 1056 if (kUnknown_SkColorType == fInfo.colorType() || |
| 1048 !fBitmap.allocPixels(fInfo)) | 1057 !fBitmap.allocPixels(fInfo)) |
| 1049 { | 1058 { |
| 1050 return; // failure, fAddr is NULL | 1059 return; // failure, fAddr is NULL |
| 1051 } | 1060 } |
| 1052 fBitmap.lockPixels(); | 1061 fBitmap.lockPixels(); |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const { | 1715 void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const { |
| 1707 path->reset(); | 1716 path->reset(); |
| 1708 | 1717 |
| 1709 const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW(); | 1718 const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW(); |
| 1710 if (rgn.isEmpty()) { | 1719 if (rgn.isEmpty()) { |
| 1711 return; | 1720 return; |
| 1712 } | 1721 } |
| 1713 (void)rgn.getBoundaryPath(path); | 1722 (void)rgn.getBoundaryPath(path); |
| 1714 } | 1723 } |
| 1715 | 1724 |
| 1725 GrRenderTarget* SkCanvas::internal_private_accessTopLayerRenderTarget() { |
| 1726 SkBaseDevice* dev = this->getTopDevice(); |
| 1727 return dev ? dev->accessRenderTarget() : NULL; |
| 1728 } |
| 1729 |
| 1716 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) { | 1730 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) { |
| 1717 SkBaseDevice* device = this->getTopDevice(); | 1731 SkBaseDevice* device = this->getTopDevice(); |
| 1718 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL; | 1732 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL; |
| 1719 } | 1733 } |
| 1720 | 1734 |
| 1721 GrContext* SkCanvas::getGrContext() { | 1735 GrContext* SkCanvas::getGrContext() { |
| 1722 #if SK_SUPPORT_GPU | 1736 #if SK_SUPPORT_GPU |
| 1723 SkBaseDevice* device = this->getTopDevice(); | 1737 SkBaseDevice* device = this->getTopDevice(); |
| 1724 if (NULL != device) { | 1738 if (NULL != device) { |
| 1725 GrRenderTarget* renderTarget = device->accessRenderTarget(); | 1739 GrRenderTarget* renderTarget = device->accessRenderTarget(); |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 if (!bitmap.allocPixels(info)) { | 2477 if (!bitmap.allocPixels(info)) { |
| 2464 return NULL; | 2478 return NULL; |
| 2465 } | 2479 } |
| 2466 | 2480 |
| 2467 // should this functionality be moved into allocPixels()? | 2481 // should this functionality be moved into allocPixels()? |
| 2468 if (!bitmap.info().isOpaque()) { | 2482 if (!bitmap.info().isOpaque()) { |
| 2469 bitmap.eraseColor(0); | 2483 bitmap.eraseColor(0); |
| 2470 } | 2484 } |
| 2471 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2485 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2472 } | 2486 } |
| OLD | NEW |