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

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

Issue 163823002: Revert of add peekPixels to SkCanvas and SkSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('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 /* 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 985
986 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) { 986 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) {
987 return this->onNewSurface(info); 987 return this->onNewSurface(info);
988 } 988 }
989 989
990 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) { 990 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) {
991 SkBaseDevice* dev = this->getDevice(); 991 SkBaseDevice* dev = this->getDevice();
992 return dev ? dev->newSurface(info) : NULL; 992 return dev ? dev->newSurface(info) : NULL;
993 } 993 }
994 994
995 SkImageInfo SkCanvas::imageInfo() const {
996 SkBaseDevice* dev = this->getDevice();
997 if (dev) {
998 return dev->imageInfo();
999 } else {
1000 // TODO: need a real unknown for alphatype it seems.
1001 SkAlphaType unknownAlphaType = kIgnore_SkAlphaType;
1002 return SkImageInfo::Make(0, 0, kUnknown_SkColorType, unknownAlphaType);
1003 }
1004 }
1005
1006 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) {
1007 return this->onPeekPixels(info, rowBytes);
1008 }
1009
1010 const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) {
1011 SkBaseDevice* dev = this->getDevice();
1012 return dev ? dev->peekPixels(info, rowBytes) : NULL;
1013 }
1014
1015 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) {
1016 fAddr = canvas->peekPixels(&fInfo, &fRowBytes);
1017 if (NULL == fAddr) {
1018 fInfo = canvas->imageInfo();
1019 if (kUnknown_SkColorType == fInfo.colorType() ||
1020 !fBitmap.allocPixels(fInfo))
1021 {
1022 return; // failure, fAddr is NULL
1023 }
1024 fBitmap.lockPixels();
1025 if (!canvas->readPixels(&fBitmap, 0, 0)) {
1026 return; // failure, fAddr is NULL
1027 }
1028 fAddr = fBitmap.getPixels();
1029 fRowBytes = fBitmap.rowBytes();
1030 }
1031 SkASSERT(fAddr); // success
1032 }
1033
1034 bool SkAutoROCanvasPixels::asROBitmap(SkBitmap* bitmap) const {
1035 if (fAddr) {
1036 return bitmap->installPixels(fInfo, const_cast<void*>(fAddr), fRowBytes,
1037 NULL, NULL);
1038 } else {
1039 bitmap->reset();
1040 return false;
1041 }
1042 }
1043
1044 ///////////////////////////////////////////////////////////////////////////// 995 /////////////////////////////////////////////////////////////////////////////
1045 996
1046 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, 997 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
1047 const SkMatrix& matrix, const SkPaint* paint) { 998 const SkMatrix& matrix, const SkPaint* paint) {
1048 if (bitmap.drawsNothing()) { 999 if (bitmap.drawsNothing()) {
1049 return; 1000 return;
1050 } 1001 }
1051 1002
1052 SkLazyPaint lazy; 1003 SkLazyPaint lazy;
1053 if (NULL == paint) { 1004 if (NULL == paint) {
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 return *paint; 2232 return *paint;
2282 } 2233 }
2283 2234
2284 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2235 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2285 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2236 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2286 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2237 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2287 2238
2288 /////////////////////////////////////////////////////////////////////////////// 2239 ///////////////////////////////////////////////////////////////////////////////
2289 2240
2290 SkCanvas::ClipVisitor::~ClipVisitor() { } 2241 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698