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

Side by Side Diff: src/gpu/SkGrPixelRef.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add SK_SUPPORT_LEGACY_ONLOCKPIXELS so we can land in stages for Chrome Created 7 years 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
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 10
11 #include "SkGrPixelRef.h" 11 #include "SkGrPixelRef.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrTexture.h" 13 #include "GrTexture.h"
14 #include "SkGr.h" 14 #include "SkGr.h"
15 #include "SkRect.h" 15 #include "SkRect.h"
16 16
17 // since we call lockPixels recursively on fBitmap, we need a distinct mutex, 17 // since we call lockPixels recursively on fBitmap, we need a distinct mutex,
18 // to avoid deadlock with the default one provided by SkPixelRef. 18 // to avoid deadlock with the default one provided by SkPixelRef.
19 SK_DECLARE_STATIC_MUTEX(gROLockPixelsPixelRefMutex); 19 SK_DECLARE_STATIC_MUTEX(gROLockPixelsPixelRefMutex);
20 20
21 SkROLockPixelsPixelRef::SkROLockPixelsPixelRef() : INHERITED(&gROLockPixelsPixel RefMutex) { 21 SkROLockPixelsPixelRef::SkROLockPixelsPixelRef() : INHERITED(&gROLockPixelsPixel RefMutex) {
22 } 22 }
23 23
24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() { 24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {
25 } 25 }
26 26
27 void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) { 27 bool SkROLockPixelsPixelRef::onGetInfo(SkImageInfo* info) {
28 if (ctable) { 28 return fBitmap.asImageInfo(info);
29 *ctable = NULL; 29 }
30 } 30
31 bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) {
31 fBitmap.reset(); 32 fBitmap.reset();
32 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); 33 // SkDebugf("---------- calling readpixels in support of lockpixels\n");
33 if (!this->onReadPixels(&fBitmap, NULL)) { 34 if (!this->onReadPixels(&fBitmap, NULL)) {
34 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); 35 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n");
35 return NULL; 36 return NULL;
36 } 37 }
37 fBitmap.lockPixels(); 38 fBitmap.lockPixels();
38 return fBitmap.getPixels(); 39 if (NULL == fBitmap.getPixels()) {
40 return false;
41 }
42
43 rec->fPixels = fBitmap.getPixels();
44 rec->fColorTable = NULL;
45 rec->fRowBytes = fBitmap.rowBytes();
46 return true;
39 } 47 }
40 48
41 void SkROLockPixelsPixelRef::onUnlockPixels() { 49 void SkROLockPixelsPixelRef::onUnlockPixels() {
42 fBitmap.unlockPixels(); 50 fBitmap.unlockPixels();
43 } 51 }
44 52
45 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { 53 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
46 return false; 54 return false;
47 } 55 }
48 56
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (!dst->allocPixels()) { 178 if (!dst->allocPixels()) {
171 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 179 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
172 return false; 180 return false;
173 } 181 }
174 SkAutoLockPixels al(*dst); 182 SkAutoLockPixels al(*dst);
175 void* buffer = dst->getPixels(); 183 void* buffer = dst->getPixels();
176 return fSurface->readPixels(left, top, width, height, 184 return fSurface->readPixels(left, top, width, height,
177 kSkia8888_GrPixelConfig, 185 kSkia8888_GrPixelConfig,
178 buffer, dst->rowBytes()); 186 buffer, dst->rowBytes());
179 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698