| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // target) | 120 // target) |
| 121 fSurface = surface->asTexture(); | 121 fSurface = surface->asTexture(); |
| 122 #else | 122 #else |
| 123 fSurface = NULL; | 123 fSurface = NULL; |
| 124 #endif | 124 #endif |
| 125 if (NULL == fSurface) { | 125 if (NULL == fSurface) { |
| 126 fSurface = surface; | 126 fSurface = surface; |
| 127 } | 127 } |
| 128 fUnlock = transferCacheLock; | 128 fUnlock = transferCacheLock; |
| 129 SkSafeRef(surface); | 129 SkSafeRef(surface); |
| 130 |
| 131 if (fSurface) { |
| 132 SkASSERT(info.fWidth <= fSurface->width()); |
| 133 SkASSERT(info.fHeight <= fSurface->height()); |
| 134 } |
| 130 } | 135 } |
| 131 | 136 |
| 132 SkGrPixelRef::~SkGrPixelRef() { | 137 SkGrPixelRef::~SkGrPixelRef() { |
| 133 if (fUnlock) { | 138 if (fUnlock) { |
| 134 GrContext* context = fSurface->getContext(); | 139 GrContext* context = fSurface->getContext(); |
| 135 GrTexture* texture = fSurface->asTexture(); | 140 GrTexture* texture = fSurface->asTexture(); |
| 136 if (NULL != context && NULL != texture) { | 141 if (NULL != context && NULL != texture) { |
| 137 context->unlockScratchTexture(texture); | 142 context->unlockScratchTexture(texture); |
| 138 } | 143 } |
| 139 } | 144 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 167 } | 172 } |
| 168 | 173 |
| 169 int left, top, width, height; | 174 int left, top, width, height; |
| 170 if (NULL != subset) { | 175 if (NULL != subset) { |
| 171 left = subset->fLeft; | 176 left = subset->fLeft; |
| 172 width = subset->width(); | 177 width = subset->width(); |
| 173 top = subset->fTop; | 178 top = subset->fTop; |
| 174 height = subset->height(); | 179 height = subset->height(); |
| 175 } else { | 180 } else { |
| 176 left = 0; | 181 left = 0; |
| 177 width = fSurface->width(); | 182 width = this->info().fWidth; |
| 178 top = 0; | 183 top = 0; |
| 179 height = fSurface->height(); | 184 height = this->info().fHeight; |
| 180 } | 185 } |
| 181 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { | 186 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { |
| 182 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 187 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
| 183 return false; | 188 return false; |
| 184 } | 189 } |
| 185 SkAutoLockPixels al(*dst); | 190 SkAutoLockPixels al(*dst); |
| 186 void* buffer = dst->getPixels(); | 191 void* buffer = dst->getPixels(); |
| 187 return fSurface->readPixels(left, top, width, height, | 192 return fSurface->readPixels(left, top, width, height, |
| 188 kSkia8888_GrPixelConfig, | 193 kSkia8888_GrPixelConfig, |
| 189 buffer, dst->rowBytes()); | 194 buffer, dst->rowBytes()); |
| 190 } | 195 } |
| OLD | NEW |