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

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

Issue 1155443004: change internals over to SkPixmap and stop using accessBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 SkImageInfo SkCanvas::imageInfo() const { 1126 SkImageInfo SkCanvas::imageInfo() const {
1127 SkBaseDevice* dev = this->getDevice(); 1127 SkBaseDevice* dev = this->getDevice();
1128 if (dev) { 1128 if (dev) {
1129 return dev->imageInfo(); 1129 return dev->imageInfo();
1130 } else { 1130 } else {
1131 return SkImageInfo::MakeUnknown(0, 0); 1131 return SkImageInfo::MakeUnknown(0, 0);
1132 } 1132 }
1133 } 1133 }
1134 1134
1135 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) { 1135 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) {
1136 return this->onPeekPixels(info, rowBytes); 1136 SkPixmap pmap;
1137 if (!this->onPeekPixels(&pmap)) {
1138 return NULL;
1139 }
1140 if (info) {
1141 *info = pmap.info();
1142 }
1143 if (rowBytes) {
1144 *rowBytes = pmap.rowBytes();
1145 }
1146 return pmap.addr();
1137 } 1147 }
1138 1148
1139 const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) { 1149 bool SkCanvas::onPeekPixels(SkPixmap* pmap) {
1140 SkBaseDevice* dev = this->getDevice(); 1150 SkBaseDevice* dev = this->getDevice();
1141 return dev ? dev->peekPixels(info, rowBytes) : NULL; 1151 return dev && dev->peekPixels(pmap);
1142 } 1152 }
1143 1153
1144 void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoi nt* origin) { 1154 void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoi nt* origin) {
1145 void* pixels = this->onAccessTopLayerPixels(info, rowBytes); 1155 SkPixmap pmap;
1146 if (pixels && origin) { 1156 if (!this->onAccessTopLayerPixels(&pmap)) {
1157 return NULL;
1158 }
1159 if (info) {
1160 *info = pmap.info();
1161 }
1162 if (rowBytes) {
1163 *rowBytes = pmap.rowBytes();
1164 }
1165 if (origin) {
1147 *origin = this->getTopDevice(false)->getOrigin(); 1166 *origin = this->getTopDevice(false)->getOrigin();
1148 } 1167 }
1149 return pixels; 1168 return pmap.writable_addr();
1150 } 1169 }
1151 1170
1152 void* SkCanvas::onAccessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) { 1171 bool SkCanvas::onAccessTopLayerPixels(SkPixmap* pmap) {
1153 SkBaseDevice* dev = this->getTopDevice(); 1172 SkBaseDevice* dev = this->getTopDevice();
1154 return dev ? dev->accessPixels(info, rowBytes) : NULL; 1173 return dev && dev->accessPixels(pmap);
1155 } 1174 }
1156 1175
1157 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) { 1176 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) {
1158 fAddr = canvas->peekPixels(&fInfo, &fRowBytes); 1177 fAddr = canvas->peekPixels(&fInfo, &fRowBytes);
1159 if (NULL == fAddr) { 1178 if (NULL == fAddr) {
1160 fInfo = canvas->imageInfo(); 1179 fInfo = canvas->imageInfo();
1161 if (kUnknown_SkColorType == fInfo.colorType() || !fBitmap.tryAllocPixels (fInfo)) { 1180 if (kUnknown_SkColorType == fInfo.colorType() || !fBitmap.tryAllocPixels (fInfo)) {
1162 return; // failure, fAddr is NULL 1181 return; // failure, fAddr is NULL
1163 } 1182 }
1164 if (!canvas->readPixels(&fBitmap, 0, 0)) { 1183 if (!canvas->readPixels(&fBitmap, 0, 0)) {
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 } 2709 }
2691 2710
2692 if (matrix) { 2711 if (matrix) {
2693 canvas->concat(*matrix); 2712 canvas->concat(*matrix);
2694 } 2713 }
2695 } 2714 }
2696 2715
2697 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2716 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2698 fCanvas->restoreToCount(fSaveCount); 2717 fCanvas->restoreToCount(fSaveCount);
2699 } 2718 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDevice.cpp » ('j') | src/core/SkPixmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698