Chromium Code Reviews| 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 dst->pixelRef()->cloneGenID(*fPixelRef); |
|
scroggo
2013/10/22 21:04:02
So this patch does not address the bug we discusse
bsalomon
2013/10/23 13:52:57
I'd prefer keeping a fix for that as a separate is
mtklein
2013/10/23 15:28:10
Added skia:1742.
scroggo
2013/10/23 15:39:19
I still think it would be nice to document this in
mtklein
2013/10/23 16:07:10
Done.
| |
| 1060 } | 1060 } |
| 1061 return true; | 1061 return true; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 // fall through to the raster case | 1064 // fall through to the raster case |
| 1065 src = &tmpSrc; | 1065 src = &tmpSrc; |
| 1066 } | 1066 } |
| 1067 } | 1067 } |
| 1068 } | 1068 } |
| 1069 | 1069 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1089 // allocator/lock failed | 1089 // allocator/lock failed |
| 1090 return false; | 1090 return false; |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 /* do memcpy for the same configs cases, else use drawing | 1093 /* do memcpy for the same configs cases, else use drawing |
| 1094 */ | 1094 */ |
| 1095 if (src->config() == dstConfig) { | 1095 if (src->config() == dstConfig) { |
| 1096 if (tmpDst.getSize() == src->getSize()) { | 1096 if (tmpDst.getSize() == src->getSize()) { |
| 1097 memcpy(tmpDst.getPixels(), src->getPixels(), src->getSafeSize()); | 1097 memcpy(tmpDst.getPixels(), src->getPixels(), src->getSafeSize()); |
| 1098 SkPixelRef* pixelRef = tmpDst.pixelRef(); | 1098 SkPixelRef* pixelRef = tmpDst.pixelRef(); |
| 1099 if (pixelRef != NULL) { | 1099 if (pixelRef != NULL && fPixelRef != NULL) { |
|
bsalomon
2013/10/23 13:52:57
ubernbit: NULL != pixelRef
mtklein
2013/10/23 15:28:10
Done.
| |
| 1100 pixelRef->fGenerationID = this->getGenerationID(); | 1100 pixelRef->cloneGenID(*fPixelRef); |
| 1101 } | 1101 } |
| 1102 } else { | 1102 } else { |
| 1103 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); | 1103 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); |
| 1104 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); | 1104 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); |
| 1105 // to be sure we don't read too much, only copy our logical pixels | 1105 // to be sure we don't read too much, only copy our logical pixels |
| 1106 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); | 1106 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); |
| 1107 for (int y = 0; y < tmpDst.height(); y++) { | 1107 for (int y = 0; y < tmpDst.height(); y++) { |
| 1108 memcpy(dstP, srcP, bytesToCopy); | 1108 memcpy(dstP, srcP, bytesToCopy); |
| 1109 srcP += src->rowBytes(); | 1109 srcP += src->rowBytes(); |
| 1110 dstP += tmpDst.rowBytes(); | 1110 dstP += tmpDst.rowBytes(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1144 return false; | 1144 return false; |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 // If we have a PixelRef, and it supports deep copy, use it. | 1147 // If we have a PixelRef, and it supports deep copy, use it. |
| 1148 // Currently supported only by texture-backed bitmaps. | 1148 // Currently supported only by texture-backed bitmaps. |
| 1149 if (fPixelRef) { | 1149 if (fPixelRef) { |
| 1150 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); | 1150 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); |
| 1151 if (pixelRef) { | 1151 if (pixelRef) { |
| 1152 uint32_t rowBytes; | 1152 uint32_t rowBytes; |
| 1153 if (dstConfig == fConfig) { | 1153 if (dstConfig == fConfig) { |
| 1154 pixelRef->fGenerationID = fPixelRef->getGenerationID(); | 1154 pixelRef->cloneGenID(*fPixelRef); |
| 1155 // Use the same rowBytes as the original. | 1155 // Use the same rowBytes as the original. |
| 1156 rowBytes = fRowBytes; | 1156 rowBytes = fRowBytes; |
| 1157 } else { | 1157 } else { |
| 1158 // With the new config, an appropriate fRowBytes will be compute d by setConfig. | 1158 // With the new config, an appropriate fRowBytes will be compute d by setConfig. |
| 1159 rowBytes = 0; | 1159 rowBytes = 0; |
| 1160 } | 1160 } |
| 1161 dst->setConfig(dstConfig, fWidth, fHeight, rowBytes); | 1161 dst->setConfig(dstConfig, fWidth, fHeight, rowBytes); |
| 1162 | 1162 |
| 1163 size_t pixelRefOffset; | 1163 size_t pixelRefOffset; |
| 1164 if (0 == fPixelRefOffset || dstConfig == fConfig) { | 1164 if (0 == fPixelRefOffset || dstConfig == fConfig) { |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1696 if (NULL != uri) { | 1696 if (NULL != uri) { |
| 1697 str->appendf(" uri:\"%s\"", uri); | 1697 str->appendf(" uri:\"%s\"", uri); |
| 1698 } else { | 1698 } else { |
| 1699 str->appendf(" pixelref:%p", pr); | 1699 str->appendf(" pixelref:%p", pr); |
| 1700 } | 1700 } |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 str->append(")"); | 1703 str->append(")"); |
| 1704 } | 1704 } |
| 1705 #endif | 1705 #endif |
| OLD | NEW |