| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  * Copyright 2008 The Android Open Source Project |     2  * Copyright 2008 The Android Open Source Project | 
|     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 "SkAtomics.h" |     8 #include "SkAtomics.h" | 
|     9 #include "SkBitmap.h" |     9 #include "SkBitmap.h" | 
|    10 #include "SkColorPriv.h" |    10 #include "SkColorPriv.h" | 
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   740     srcRect.set(0, 0, this->width(), this->height()); |   740     srcRect.set(0, 0, this->width(), this->height()); | 
|   741     if (!r.intersect(srcRect, subset)) { |   741     if (!r.intersect(srcRect, subset)) { | 
|   742         return false;   // r is empty (i.e. no intersection) |   742         return false;   // r is empty (i.e. no intersection) | 
|   743     } |   743     } | 
|   744  |   744  | 
|   745     if (fPixelRef->getTexture() != nullptr) { |   745     if (fPixelRef->getTexture() != nullptr) { | 
|   746         // Do a deep copy |   746         // Do a deep copy | 
|   747         SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->prof
      ileType(), &subset); |   747         SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->prof
      ileType(), &subset); | 
|   748         if (pixelRef != nullptr) { |   748         if (pixelRef != nullptr) { | 
|   749             SkBitmap dst; |   749             SkBitmap dst; | 
|   750             dst.setInfo(SkImageInfo::Make(subset.width(), subset.height(), |   750             dst.setInfo(this->info().makeWH(subset.width(), subset.height())); | 
|   751                                           this->colorType(), this->alphaType(), |  | 
|   752                                           this->profileType())); |  | 
|   753             dst.setIsVolatile(this->isVolatile()); |   751             dst.setIsVolatile(this->isVolatile()); | 
|   754             dst.setPixelRef(pixelRef)->unref(); |   752             dst.setPixelRef(pixelRef)->unref(); | 
|   755             SkDEBUGCODE(dst.validate()); |   753             SkDEBUGCODE(dst.validate()); | 
|   756             result->swap(dst); |   754             result->swap(dst); | 
|   757             return true; |   755             return true; | 
|   758         } |   756         } | 
|   759     } |   757     } | 
|   760  |   758  | 
|   761     // If the upper left of the rectangle was outside the bounds of this SkBitma
      p, we should have |   759     // If the upper left of the rectangle was outside the bounds of this SkBitma
      p, we should have | 
|   762     // exited above. |   760     // exited above. | 
|   763     SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width(
      ))); |   761     SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width(
      ))); | 
|   764     SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height(
      ))); |   762     SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height(
      ))); | 
|   765  |   763  | 
|   766     SkBitmap dst; |   764     SkBitmap dst; | 
|   767     dst.setInfo(SkImageInfo::Make(r.width(), r.height(), |   765     dst.setInfo(this->info().makeWH(r.width(), r.height()), this->rowBytes()); | 
|   768                                   this->colorType(), this->alphaType(), this->pr
      ofileType()), |  | 
|   769                 this->rowBytes()); |  | 
|   770     dst.setIsVolatile(this->isVolatile()); |   766     dst.setIsVolatile(this->isVolatile()); | 
|   771  |   767  | 
|   772     if (fPixelRef) { |   768     if (fPixelRef) { | 
|   773         SkIPoint origin = fPixelRefOrigin; |   769         SkIPoint origin = fPixelRefOrigin; | 
|   774         origin.fX += r.fLeft; |   770         origin.fX += r.fLeft; | 
|   775         origin.fY += r.fTop; |   771         origin.fY += r.fTop; | 
|   776         // share the pixelref with a custom offset |   772         // share the pixelref with a custom offset | 
|   777         dst.setPixelRef(fPixelRef, origin); |   773         dst.setPixelRef(fPixelRef, origin); | 
|   778     } |   774     } | 
|   779     SkDEBUGCODE(dst.validate();) |   775     SkDEBUGCODE(dst.validate();) | 
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1353 /////////////////////////////////////////////////////////////////////////////// |  1349 /////////////////////////////////////////////////////////////////////////////// | 
|  1354  |  1350  | 
|  1355 #ifdef SK_DEBUG |  1351 #ifdef SK_DEBUG | 
|  1356 void SkImageInfo::validate() const { |  1352 void SkImageInfo::validate() const { | 
|  1357     SkASSERT(fWidth >= 0); |  1353     SkASSERT(fWidth >= 0); | 
|  1358     SkASSERT(fHeight >= 0); |  1354     SkASSERT(fHeight >= 0); | 
|  1359     SkASSERT(SkColorTypeIsValid(fColorType)); |  1355     SkASSERT(SkColorTypeIsValid(fColorType)); | 
|  1360     SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |  1356     SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 
|  1361 } |  1357 } | 
|  1362 #endif |  1358 #endif | 
| OLD | NEW |