| 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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 subset.fRight = subset.fLeft + fWidth; | 1049 subset.fRight = subset.fLeft + fWidth; |
| 1050 subset.fBottom = subset.fTop + fHeight; | 1050 subset.fBottom = subset.fTop + fHeight; |
| 1051 if (fPixelRef->readPixels(&tmpSrc, &subset)) { | 1051 if (fPixelRef->readPixels(&tmpSrc, &subset)) { |
| 1052 SkASSERT(tmpSrc.width() == this->width()); | 1052 SkASSERT(tmpSrc.width() == this->width()); |
| 1053 SkASSERT(tmpSrc.height() == this->height()); | 1053 SkASSERT(tmpSrc.height() == this->height()); |
| 1054 | 1054 |
| 1055 // did we get lucky and we can just return tmpSrc? | 1055 // did we get lucky and we can just return tmpSrc? |
| 1056 if (tmpSrc.config() == dstConfig && NULL == alloc) { | 1056 if (tmpSrc.config() == dstConfig && NULL == alloc) { |
| 1057 dst->swap(tmpSrc); | 1057 dst->swap(tmpSrc); |
| 1058 if (dst->pixelRef() && this->config() == dstConfig) { | 1058 if (dst->pixelRef() && this->config() == dstConfig) { |
| 1059 dst->pixelRef()->fGenerationID = fPixelRef->getGeneratio
nID(); | 1059 // TODO(scroggo): fix issue 1742 |
| 1060 dst->pixelRef()->cloneGenID(*fPixelRef); |
| 1060 } | 1061 } |
| 1061 return true; | 1062 return true; |
| 1062 } | 1063 } |
| 1063 | 1064 |
| 1064 // fall through to the raster case | 1065 // fall through to the raster case |
| 1065 src = &tmpSrc; | 1066 src = &tmpSrc; |
| 1066 } | 1067 } |
| 1067 } | 1068 } |
| 1068 } | 1069 } |
| 1069 | 1070 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1089 // allocator/lock failed | 1090 // allocator/lock failed |
| 1090 return false; | 1091 return false; |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 /* do memcpy for the same configs cases, else use drawing | 1094 /* do memcpy for the same configs cases, else use drawing |
| 1094 */ | 1095 */ |
| 1095 if (src->config() == dstConfig) { | 1096 if (src->config() == dstConfig) { |
| 1096 if (tmpDst.getSize() == src->getSize()) { | 1097 if (tmpDst.getSize() == src->getSize()) { |
| 1097 memcpy(tmpDst.getPixels(), src->getPixels(), src->getSafeSize()); | 1098 memcpy(tmpDst.getPixels(), src->getPixels(), src->getSafeSize()); |
| 1098 SkPixelRef* pixelRef = tmpDst.pixelRef(); | 1099 SkPixelRef* pixelRef = tmpDst.pixelRef(); |
| 1099 if (pixelRef != NULL) { | 1100 if (NULL != pixelRef && NULL != fPixelRef) { |
| 1100 pixelRef->fGenerationID = this->getGenerationID(); | 1101 // TODO(scroggo): fix issue 1742 |
| 1102 pixelRef->cloneGenID(*fPixelRef); |
| 1101 } | 1103 } |
| 1102 } else { | 1104 } else { |
| 1103 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); | 1105 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); |
| 1104 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); | 1106 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); |
| 1105 // to be sure we don't read too much, only copy our logical pixels | 1107 // to be sure we don't read too much, only copy our logical pixels |
| 1106 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); | 1108 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); |
| 1107 for (int y = 0; y < tmpDst.height(); y++) { | 1109 for (int y = 0; y < tmpDst.height(); y++) { |
| 1108 memcpy(dstP, srcP, bytesToCopy); | 1110 memcpy(dstP, srcP, bytesToCopy); |
| 1109 srcP += src->rowBytes(); | 1111 srcP += src->rowBytes(); |
| 1110 dstP += tmpDst.rowBytes(); | 1112 dstP += tmpDst.rowBytes(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 return false; | 1146 return false; |
| 1145 } | 1147 } |
| 1146 | 1148 |
| 1147 // If we have a PixelRef, and it supports deep copy, use it. | 1149 // If we have a PixelRef, and it supports deep copy, use it. |
| 1148 // Currently supported only by texture-backed bitmaps. | 1150 // Currently supported only by texture-backed bitmaps. |
| 1149 if (fPixelRef) { | 1151 if (fPixelRef) { |
| 1150 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); | 1152 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); |
| 1151 if (pixelRef) { | 1153 if (pixelRef) { |
| 1152 uint32_t rowBytes; | 1154 uint32_t rowBytes; |
| 1153 if (dstConfig == fConfig) { | 1155 if (dstConfig == fConfig) { |
| 1154 pixelRef->fGenerationID = fPixelRef->getGenerationID(); | 1156 // TODO(scroggo): fix issue 1742 |
| 1157 pixelRef->cloneGenID(*fPixelRef); |
| 1155 // Use the same rowBytes as the original. | 1158 // Use the same rowBytes as the original. |
| 1156 rowBytes = fRowBytes; | 1159 rowBytes = fRowBytes; |
| 1157 } else { | 1160 } else { |
| 1158 // With the new config, an appropriate fRowBytes will be compute
d by setConfig. | 1161 // With the new config, an appropriate fRowBytes will be compute
d by setConfig. |
| 1159 rowBytes = 0; | 1162 rowBytes = 0; |
| 1160 } | 1163 } |
| 1161 dst->setConfig(dstConfig, fWidth, fHeight, rowBytes); | 1164 dst->setConfig(dstConfig, fWidth, fHeight, rowBytes); |
| 1162 | 1165 |
| 1163 size_t pixelRefOffset; | 1166 size_t pixelRefOffset; |
| 1164 if (0 == fPixelRefOffset || dstConfig == fConfig) { | 1167 if (0 == fPixelRefOffset || dstConfig == fConfig) { |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 if (NULL != uri) { | 1699 if (NULL != uri) { |
| 1697 str->appendf(" uri:\"%s\"", uri); | 1700 str->appendf(" uri:\"%s\"", uri); |
| 1698 } else { | 1701 } else { |
| 1699 str->appendf(" pixelref:%p", pr); | 1702 str->appendf(" pixelref:%p", pr); |
| 1700 } | 1703 } |
| 1701 } | 1704 } |
| 1702 | 1705 |
| 1703 str->append(")"); | 1706 str->append(")"); |
| 1704 } | 1707 } |
| 1705 #endif | 1708 #endif |
| OLD | NEW |