| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 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 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 SkASSERT(result); | 1354 SkASSERT(result); |
| 1355 | 1355 |
| 1356 SkPixelRef* pr = fPixelRef; | 1356 SkPixelRef* pr = fPixelRef; |
| 1357 if (NULL == pr) { | 1357 if (NULL == pr) { |
| 1358 return false; | 1358 return false; |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 SkPixelRef::LockRequest req = { fInfo.dimensions(), kNone_SkFilterQuality }; | 1361 SkPixelRef::LockRequest req = { fInfo.dimensions(), kNone_SkFilterQuality }; |
| 1362 SkPixelRef::LockResult res; | 1362 SkPixelRef::LockResult res; |
| 1363 if (pr->requestLock(req, &res)) { | 1363 if (pr->requestLock(req, &res)) { |
| 1364 SkASSERT(res.fPixels); |
| 1364 // The bitmap may be a subset of the pixelref's dimensions | 1365 // The bitmap may be a subset of the pixelref's dimensions |
| 1365 SkASSERT(fPixelRefOrigin.x() + fInfo.width() <= res.fSize.width()); | 1366 SkASSERT(fPixelRefOrigin.x() + fInfo.width() <= res.fSize.width()); |
| 1366 SkASSERT(fPixelRefOrigin.y() + fInfo.height() <= res.fSize.height()); | 1367 SkASSERT(fPixelRefOrigin.y() + fInfo.height() <= res.fSize.height()); |
| 1367 const void* addr = (const char*)res.fPixels + SkColorTypeComputeOffset(f
Info.colorType(), | 1368 const void* addr = (const char*)res.fPixels + SkColorTypeComputeOffset(f
Info.colorType(), |
| 1368 f
PixelRefOrigin.x(), | 1369 f
PixelRefOrigin.x(), |
| 1369 f
PixelRefOrigin.y(), | 1370 f
PixelRefOrigin.y(), |
| 1370 r
es.fRowBytes); | 1371 r
es.fRowBytes); |
| 1371 | 1372 |
| 1372 result->reset(SkPixmap(this->info(), addr, res.fRowBytes, res.fCTable), | 1373 result->reset(SkPixmap(this->info(), addr, res.fRowBytes, res.fCTable), |
| 1373 res.fUnlockProc, res.fUnlockContext); | 1374 res.fUnlockProc, res.fUnlockContext); |
| 1374 return true; | 1375 return true; |
| 1375 } | 1376 } |
| 1376 return false; | 1377 return false; |
| 1377 } | 1378 } |
| 1378 | 1379 |
| 1379 /////////////////////////////////////////////////////////////////////////////// | 1380 /////////////////////////////////////////////////////////////////////////////// |
| 1380 | 1381 |
| 1381 #ifdef SK_DEBUG | 1382 #ifdef SK_DEBUG |
| 1382 void SkImageInfo::validate() const { | 1383 void SkImageInfo::validate() const { |
| 1383 SkASSERT(fWidth >= 0); | 1384 SkASSERT(fWidth >= 0); |
| 1384 SkASSERT(fHeight >= 0); | 1385 SkASSERT(fHeight >= 0); |
| 1385 SkASSERT(SkColorTypeIsValid(fColorType)); | 1386 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1386 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1387 } | 1388 } |
| 1388 #endif | 1389 #endif |
| OLD | NEW |