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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Note that when copying a render-target-backed pixel ref, we | 160 // Note that when copying a render-target-backed pixel ref, we |
161 // return a texture-backed pixel ref instead. This is because | 161 // return a texture-backed pixel ref instead. This is because |
162 // render-target pixel refs are usually created in conjunction with | 162 // render-target pixel refs are usually created in conjunction with |
163 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live | 163 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live |
164 // independently of that texture. Texture-backed pixel refs, on the other | 164 // independently of that texture. Texture-backed pixel refs, on the other |
165 // hand, own their GrTextures, and are thus self-contained. | 165 // hand, own their GrTextures, and are thus self-contained. |
166 return copyToTexturePixelRef(fSurface->asTexture(), dstConfig, subset); | 166 return copyToTexturePixelRef(fSurface->asTexture(), dstConfig, subset); |
167 } | 167 } |
168 | 168 |
169 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { | 169 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { |
170 if (NULL == fSurface || !fSurface->isValid()) { | 170 if (NULL == fSurface || fSurface->wasDestroyed()) { |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 int left, top, width, height; | 174 int left, top, width, height; |
175 if (NULL != subset) { | 175 if (NULL != subset) { |
176 left = subset->fLeft; | 176 left = subset->fLeft; |
177 width = subset->width(); | 177 width = subset->width(); |
178 top = subset->fTop; | 178 top = subset->fTop; |
179 height = subset->height(); | 179 height = subset->height(); |
180 } else { | 180 } else { |
181 left = 0; | 181 left = 0; |
182 width = this->info().fWidth; | 182 width = this->info().fWidth; |
183 top = 0; | 183 top = 0; |
184 height = this->info().fHeight; | 184 height = this->info().fHeight; |
185 } | 185 } |
186 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { | 186 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { |
187 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 187 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
188 return false; | 188 return false; |
189 } | 189 } |
190 SkAutoLockPixels al(*dst); | 190 SkAutoLockPixels al(*dst); |
191 void* buffer = dst->getPixels(); | 191 void* buffer = dst->getPixels(); |
192 return fSurface->readPixels(left, top, width, height, | 192 return fSurface->readPixels(left, top, width, height, |
193 kSkia8888_GrPixelConfig, | 193 kSkia8888_GrPixelConfig, |
194 buffer, dst->rowBytes()); | 194 buffer, dst->rowBytes()); |
195 } | 195 } |
OLD | NEW |