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

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

Issue 1156003002: deprecate calling lockPixels (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
« no previous file with comments | « no previous file | src/core/SkMipMap.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 * 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 706
707 bool weAllocated = false; 707 bool weAllocated = false;
708 if (NULL == bitmap->pixelRef()) { 708 if (NULL == bitmap->pixelRef()) {
709 if (!bitmap->tryAllocPixels()) { 709 if (!bitmap->tryAllocPixels()) {
710 return false; 710 return false;
711 } 711 }
712 weAllocated = true; 712 weAllocated = true;
713 } 713 }
714 714
715 SkBitmap bm(*bitmap); 715 SkAutoPixmapUnlock unlocker;
716 bm.lockPixels(); 716 if (bitmap->requestLock(&unlocker)) {
717 if (bm.getPixels() && this->readPixels(bm.info(), bm.getPixels(), bm.rowByte s(), x, y)) { 717 const SkPixmap& pm = unlocker.pixmap();
718 return true; 718 if (this->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), x, y) ) {
719 return true;
720 }
719 } 721 }
720 722
721 if (weAllocated) { 723 if (weAllocated) {
722 bitmap->setPixelRef(NULL); 724 bitmap->setPixelRef(NULL);
723 } 725 }
724 return false; 726 return false;
725 } 727 }
726 728
727 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { 729 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
728 SkIRect r = srcRect; 730 SkIRect r = srcRect;
(...skipping 27 matching lines...) Expand all
756 } 758 }
757 759
758 // The device can assert that the requested area is always contained in its bounds 760 // The device can assert that the requested area is always contained in its bounds
759 return device->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec .fY); 761 return device->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec .fY);
760 } 762 }
761 763
762 bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) { 764 bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
763 if (bitmap.getTexture()) { 765 if (bitmap.getTexture()) {
764 return false; 766 return false;
765 } 767 }
766 SkBitmap bm(bitmap); 768
767 bm.lockPixels(); 769 SkAutoPixmapUnlock unlocker;
768 if (bm.getPixels()) { 770 if (bitmap.requestLock(&unlocker)) {
769 return this->writePixels(bm.info(), bm.getPixels(), bm.rowBytes(), x, y) ; 771 const SkPixmap& pm = unlocker.pixmap();
772 return this->writePixels(pm.info(), pm.addr(), pm.rowBytes(), x, y);
770 } 773 }
771 return false; 774 return false;
772 } 775 }
773 776
774 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size _t rowBytes, 777 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size _t rowBytes,
775 int x, int y) { 778 int x, int y) {
776 switch (origInfo.colorType()) { 779 switch (origInfo.colorType()) {
777 case kUnknown_SkColorType: 780 case kUnknown_SkColorType:
778 case kIndex_8_SkColorType: 781 case kIndex_8_SkColorType:
779 return false; 782 return false;
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 } 2690 }
2688 2691
2689 if (matrix) { 2692 if (matrix) {
2690 canvas->concat(*matrix); 2693 canvas->concat(*matrix);
2691 } 2694 }
2692 } 2695 }
2693 2696
2694 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2697 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2695 fCanvas->restoreToCount(fSaveCount); 2698 fCanvas->restoreToCount(fSaveCount);
2696 } 2699 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698