OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkMask.h" | 10 #include "SkMask.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (this->width() <= 0 || this->height() <= 0 || dst.width() <= 0 || dst.hei
ght() <= 0) { | 215 if (this->width() <= 0 || this->height() <= 0 || dst.width() <= 0 || dst.hei
ght() <= 0) { |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 // no scaling involved? | 219 // no scaling involved? |
220 if (dst.width() == this->width() && dst.height() == this->height()) { | 220 if (dst.width() == this->width() && dst.height() == this->height()) { |
221 return this->readPixels(dst); | 221 return this->readPixels(dst); |
222 } | 222 } |
223 | 223 |
224 SkBitmap bitmap; | 224 SkBitmap bitmap; |
225 // we will only ready from this pixmap, but the bitmap setting takes void*,
hence the cast | 225 if (!bitmap.installPixels(*this)) { |
226 void* readOnlyAddr = const_cast<void*>(this->addr()); | |
227 if (!bitmap.installPixels(this->info(), readOnlyAddr, this->rowBytes())) { | |
228 return false; | 226 return false; |
229 } | 227 } |
230 bitmap.setIsVolatile(true); // so we don't try to cache it | 228 bitmap.setIsVolatile(true); // so we don't try to cache it |
231 | 229 |
232 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(dst.info(), dst.w
ritable_addr(), | 230 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(dst.info(), dst.w
ritable_addr(), |
233 dst.rowBytes())); | 231 dst.rowBytes())); |
234 if (!surface) { | 232 if (!surface) { |
235 return false; | 233 return false; |
236 } | 234 } |
237 | 235 |
(...skipping 28 matching lines...) Expand all Loading... |
266 this->reset(info, pixels, rb); | 264 this->reset(info, pixels, rb); |
267 fStorage = pixels; | 265 fStorage = pixels; |
268 return true; | 266 return true; |
269 } | 267 } |
270 | 268 |
271 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { | 269 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { |
272 if (!this->tryAlloc(info)) { | 270 if (!this->tryAlloc(info)) { |
273 sk_throw(); | 271 sk_throw(); |
274 } | 272 } |
275 } | 273 } |
OLD | NEW |