OLD | NEW |
---|---|
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 void* SkROLockPixelsPixelRef::onLockPixels(SkImageInfo* info, size_t* rowBytes, |
28 if (ctable) { | 28 SkColorTable** ctable) { |
29 *ctable = NULL; | |
30 } | |
31 fBitmap.reset(); | 29 fBitmap.reset(); |
32 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); | 30 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); |
33 if (!this->onReadPixels(&fBitmap, NULL)) { | 31 if (!this->onReadPixels(&fBitmap, NULL)) { |
34 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); | 32 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); |
35 return NULL; | 33 return NULL; |
36 } | 34 } |
37 fBitmap.lockPixels(); | 35 fBitmap.lockPixels(); |
36 | |
37 fBitmap.asImageInfo(info); | |
38 *rowBytes = fBitmap.rowBytes(); | |
39 *ctable = NULL; | |
scroggo
2013/11/19 18:17:09
Why did you remove the check for NULL here, but pr
reed1
2013/11/20 20:56:56
no good reason. I'll remove it from imageref too.
| |
38 return fBitmap.getPixels(); | 40 return fBitmap.getPixels(); |
39 } | 41 } |
40 | 42 |
41 void SkROLockPixelsPixelRef::onUnlockPixels() { | 43 void SkROLockPixelsPixelRef::onUnlockPixels() { |
42 fBitmap.unlockPixels(); | 44 fBitmap.unlockPixels(); |
43 } | 45 } |
44 | 46 |
45 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { | 47 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { |
46 return false; | 48 return false; |
47 } | 49 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 if (!dst->allocPixels()) { | 172 if (!dst->allocPixels()) { |
171 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); | 173 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); |
172 return false; | 174 return false; |
173 } | 175 } |
174 SkAutoLockPixels al(*dst); | 176 SkAutoLockPixels al(*dst); |
175 void* buffer = dst->getPixels(); | 177 void* buffer = dst->getPixels(); |
176 return fSurface->readPixels(left, top, width, height, | 178 return fSurface->readPixels(left, top, width, height, |
177 kSkia8888_GrPixelConfig, | 179 kSkia8888_GrPixelConfig, |
178 buffer, dst->rowBytes()); | 180 buffer, dst->rowBytes()); |
179 } | 181 } |
OLD | NEW |