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

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

Issue 110593003: Add onNewLockPixels, that returns rowbytes and relies on info in pixelref (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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/SkScaledImageCache.cpp ('k') | src/images/SkImageRef.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 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(const SkImageInfo& info) 21 SkROLockPixelsPixelRef::SkROLockPixelsPixelRef(const SkImageInfo& info)
22 : INHERITED(info, &gROLockPixelsPixelRefMutex) {} 22 : INHERITED(info, &gROLockPixelsPixelRefMutex) {}
23 23
24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {} 24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {}
25 25
26 void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) { 26 bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) {
27 if (ctable) {
28 *ctable = NULL;
29 }
30 fBitmap.reset(); 27 fBitmap.reset();
31 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); 28 // SkDebugf("---------- calling readpixels in support of lockpixels\n");
32 if (!this->onReadPixels(&fBitmap, NULL)) { 29 if (!this->onReadPixels(&fBitmap, NULL)) {
33 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); 30 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n");
34 return NULL; 31 return false;
35 } 32 }
36 fBitmap.lockPixels(); 33 fBitmap.lockPixels();
37 return fBitmap.getPixels(); 34 if (NULL == fBitmap.getPixels()) {
35 return false;
36 }
37
38 rec->fPixels = fBitmap.getPixels();
39 rec->fColorTable = NULL;
40 rec->fRowBytes = fBitmap.rowBytes();
41 return true;
38 } 42 }
39 43
40 void SkROLockPixelsPixelRef::onUnlockPixels() { 44 void SkROLockPixelsPixelRef::onUnlockPixels() {
41 fBitmap.unlockPixels(); 45 fBitmap.unlockPixels();
42 } 46 }
43 47
44 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { 48 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
45 return false; 49 return false;
46 } 50 }
47 51
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (!dst->allocPixels()) { 182 if (!dst->allocPixels()) {
179 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 183 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
180 return false; 184 return false;
181 } 185 }
182 SkAutoLockPixels al(*dst); 186 SkAutoLockPixels al(*dst);
183 void* buffer = dst->getPixels(); 187 void* buffer = dst->getPixels();
184 return fSurface->readPixels(left, top, width, height, 188 return fSurface->readPixels(left, top, width, height,
185 kSkia8888_GrPixelConfig, 189 kSkia8888_GrPixelConfig,
186 buffer, dst->rowBytes()); 190 buffer, dst->rowBytes());
187 } 191 }
OLDNEW
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | src/images/SkImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698