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 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #else | 110 #else |
111 fSurface = NULL; | 111 fSurface = NULL; |
112 #endif | 112 #endif |
113 if (NULL == fSurface) { | 113 if (NULL == fSurface) { |
114 fSurface = surface; | 114 fSurface = surface; |
115 } | 115 } |
116 fUnlock = transferCacheLock; | 116 fUnlock = transferCacheLock; |
117 SkSafeRef(surface); | 117 SkSafeRef(surface); |
118 } | 118 } |
119 | 119 |
| 120 SkGrPixelRef::SkGrPixelRef(const SkImageInfo&, GrSurface* surface, bool transfer
CacheLock) { |
| 121 // TODO: figure out if this is responsible for Chrome canvas errors |
| 122 #if 0 |
| 123 // The GrTexture has a ref to the GrRenderTarget but not vice versa. |
| 124 // If the GrTexture exists take a ref to that (rather than the render |
| 125 // target) |
| 126 fSurface = surface->asTexture(); |
| 127 #else |
| 128 fSurface = NULL; |
| 129 #endif |
| 130 if (NULL == fSurface) { |
| 131 fSurface = surface; |
| 132 } |
| 133 fUnlock = transferCacheLock; |
| 134 SkSafeRef(surface); |
| 135 } |
| 136 |
120 SkGrPixelRef::~SkGrPixelRef() { | 137 SkGrPixelRef::~SkGrPixelRef() { |
121 if (fUnlock) { | 138 if (fUnlock) { |
122 GrContext* context = fSurface->getContext(); | 139 GrContext* context = fSurface->getContext(); |
123 GrTexture* texture = fSurface->asTexture(); | 140 GrTexture* texture = fSurface->asTexture(); |
124 if (NULL != context && NULL != texture) { | 141 if (NULL != context && NULL != texture) { |
125 context->unlockScratchTexture(texture); | 142 context->unlockScratchTexture(texture); |
126 } | 143 } |
127 } | 144 } |
128 SkSafeUnref(fSurface); | 145 SkSafeUnref(fSurface); |
129 } | 146 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (!dst->allocPixels()) { | 187 if (!dst->allocPixels()) { |
171 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 188 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
172 return false; | 189 return false; |
173 } | 190 } |
174 SkAutoLockPixels al(*dst); | 191 SkAutoLockPixels al(*dst); |
175 void* buffer = dst->getPixels(); | 192 void* buffer = dst->getPixels(); |
176 return fSurface->readPixels(left, top, width, height, | 193 return fSurface->readPixels(left, top, width, height, |
177 kSkia8888_GrPixelConfig, | 194 kSkia8888_GrPixelConfig, |
178 buffer, dst->rowBytes()); | 195 buffer, dst->rowBytes()); |
179 } | 196 } |
OLD | NEW |