| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // For surfaces that are both textures and render targets, the texture owns
the | 109 // For surfaces that are both textures and render targets, the texture owns
the |
| 110 // render target but not vice versa. So we ref the texture to keep both aliv
e for | 110 // render target but not vice versa. So we ref the texture to keep both aliv
e for |
| 111 // the lifetime of this pixel ref. | 111 // the lifetime of this pixel ref. |
| 112 fSurface = SkSafeRef(surface->asTexture()); | 112 fSurface = SkSafeRef(surface->asTexture()); |
| 113 if (NULL == fSurface) { | 113 if (NULL == fSurface) { |
| 114 fSurface = SkSafeRef(surface); | 114 fSurface = SkSafeRef(surface); |
| 115 } | 115 } |
| 116 fUnlock = transferCacheLock; | 116 fUnlock = transferCacheLock; |
| 117 | 117 |
| 118 if (fSurface) { | 118 if (fSurface) { |
| 119 SkASSERT(info.fWidth <= fSurface->width()); | 119 SkASSERT(info.width() <= fSurface->width()); |
| 120 SkASSERT(info.fHeight <= fSurface->height()); | 120 SkASSERT(info.height() <= fSurface->height()); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 SkGrPixelRef::~SkGrPixelRef() { | 124 SkGrPixelRef::~SkGrPixelRef() { |
| 125 if (fUnlock) { | 125 if (fUnlock) { |
| 126 GrContext* context = fSurface->getContext(); | 126 GrContext* context = fSurface->getContext(); |
| 127 GrTexture* texture = fSurface->asTexture(); | 127 GrTexture* texture = fSurface->asTexture(); |
| 128 if (NULL != context && NULL != texture) { | 128 if (NULL != context && NULL != texture) { |
| 129 context->unlockScratchTexture(texture); | 129 context->unlockScratchTexture(texture); |
| 130 } | 130 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 int left, top, width, height; | 161 int left, top, width, height; |
| 162 if (NULL != subset) { | 162 if (NULL != subset) { |
| 163 left = subset->fLeft; | 163 left = subset->fLeft; |
| 164 width = subset->width(); | 164 width = subset->width(); |
| 165 top = subset->fTop; | 165 top = subset->fTop; |
| 166 height = subset->height(); | 166 height = subset->height(); |
| 167 } else { | 167 } else { |
| 168 left = 0; | 168 left = 0; |
| 169 width = this->info().fWidth; | 169 width = this->info().width(); |
| 170 top = 0; | 170 top = 0; |
| 171 height = this->info().fHeight; | 171 height = this->info().height(); |
| 172 } | 172 } |
| 173 if (!dst->tryAllocN32Pixels(width, height)) { | 173 if (!dst->tryAllocN32Pixels(width, height)) { |
| 174 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 174 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
| 175 return false; | 175 return false; |
| 176 } | 176 } |
| 177 SkAutoLockPixels al(*dst); | 177 SkAutoLockPixels al(*dst); |
| 178 void* buffer = dst->getPixels(); | 178 void* buffer = dst->getPixels(); |
| 179 return fSurface->readPixels(left, top, width, height, | 179 return fSurface->readPixels(left, top, width, height, |
| 180 kSkia8888_GrPixelConfig, | 180 kSkia8888_GrPixelConfig, |
| 181 buffer, dst->rowBytes()); | 181 buffer, dst->rowBytes()); |
| 182 } | 182 } |
| OLD | NEW |