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(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 bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) { | 26 void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) { |
| 27 if (ctable) { |
| 28 *ctable = NULL; |
| 29 } |
27 fBitmap.reset(); | 30 fBitmap.reset(); |
28 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); | 31 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); |
29 if (!this->onReadPixels(&fBitmap, NULL)) { | 32 if (!this->onReadPixels(&fBitmap, NULL)) { |
30 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); | 33 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); |
31 return false; | 34 return NULL; |
32 } | 35 } |
33 fBitmap.lockPixels(); | 36 fBitmap.lockPixels(); |
34 if (NULL == fBitmap.getPixels()) { | 37 return fBitmap.getPixels(); |
35 return false; | |
36 } | |
37 | |
38 rec->fPixels = fBitmap.getPixels(); | |
39 rec->fColorTable = NULL; | |
40 rec->fRowBytes = fBitmap.rowBytes(); | |
41 return true; | |
42 } | 38 } |
43 | 39 |
44 void SkROLockPixelsPixelRef::onUnlockPixels() { | 40 void SkROLockPixelsPixelRef::onUnlockPixels() { |
45 fBitmap.unlockPixels(); | 41 fBitmap.unlockPixels(); |
46 } | 42 } |
47 | 43 |
48 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { | 44 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { |
49 return false; | 45 return false; |
50 } | 46 } |
51 | 47 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (!dst->allocPixels()) { | 178 if (!dst->allocPixels()) { |
183 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 179 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
184 return false; | 180 return false; |
185 } | 181 } |
186 SkAutoLockPixels al(*dst); | 182 SkAutoLockPixels al(*dst); |
187 void* buffer = dst->getPixels(); | 183 void* buffer = dst->getPixels(); |
188 return fSurface->readPixels(left, top, width, height, | 184 return fSurface->readPixels(left, top, width, height, |
189 kSkia8888_GrPixelConfig, | 185 kSkia8888_GrPixelConfig, |
190 buffer, dst->rowBytes()); | 186 buffer, dst->rowBytes()); |
191 } | 187 } |
OLD | NEW |