| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 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 "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top, | 1273 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top, |
| 1274 width, height, dstConfig, | 1274 width, height, dstConfig, |
| 1275 rowBytes); | 1275 rowBytes); |
| 1276 // We ignore the preferred config if it is different than our config unless
it is an R/B swap. | 1276 // We ignore the preferred config if it is different than our config unless
it is an R/B swap. |
| 1277 // In that case we'll perform an R and B swap while drawing to a scratch tex
ture of the swapped | 1277 // In that case we'll perform an R and B swap while drawing to a scratch tex
ture of the swapped |
| 1278 // config. Then we will call readPixels on the scratch with the swapped conf
ig. The swaps during | 1278 // config. Then we will call readPixels on the scratch with the swapped conf
ig. The swaps during |
| 1279 // the draw cancels out the fact that we call readPixels with a config that
is R/B swapped from | 1279 // the draw cancels out the fact that we call readPixels with a config that
is R/B swapped from |
| 1280 // dstConfig. | 1280 // dstConfig. |
| 1281 GrPixelConfig readConfig = dstConfig; | 1281 GrPixelConfig readConfig = dstConfig; |
| 1282 bool swapRAndB = false; | 1282 bool swapRAndB = false; |
| 1283 if (GrPixelConfigSwapRAndB(dstConfig) == fGpu->preferredReadPixelsConfig(dst
Config)) { | 1283 if (GrPixelConfigSwapRAndB(dstConfig) == |
| 1284 fGpu->preferredReadPixelsConfig(dstConfig, target->config())) { |
| 1284 readConfig = GrPixelConfigSwapRAndB(readConfig); | 1285 readConfig = GrPixelConfigSwapRAndB(readConfig); |
| 1285 swapRAndB = true; | 1286 swapRAndB = true; |
| 1286 } | 1287 } |
| 1287 | 1288 |
| 1288 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); | 1289 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
| 1289 | 1290 |
| 1290 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { | 1291 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
| 1291 // The unpremul flag is only allowed for these two configs. | 1292 // The unpremul flag is only allowed for these two configs. |
| 1292 return false; | 1293 return false; |
| 1293 } | 1294 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 srcConfig, buffer, rowBytes, flags); | 1472 srcConfig, buffer, rowBytes, flags); |
| 1472 } | 1473 } |
| 1473 #endif | 1474 #endif |
| 1474 | 1475 |
| 1475 // We ignore the preferred config unless it is a R/B swap of the src config.
In that case | 1476 // We ignore the preferred config unless it is a R/B swap of the src config.
In that case |
| 1476 // we will upload the original src data to a scratch texture but we will spo
of it as the swapped | 1477 // we will upload the original src data to a scratch texture but we will spo
of it as the swapped |
| 1477 // config. This scratch will then have R and B swapped. We correct for this
by swapping again | 1478 // config. This scratch will then have R and B swapped. We correct for this
by swapping again |
| 1478 // when drawing the scratch to the dst using a conversion effect. | 1479 // when drawing the scratch to the dst using a conversion effect. |
| 1479 bool swapRAndB = false; | 1480 bool swapRAndB = false; |
| 1480 GrPixelConfig writeConfig = srcConfig; | 1481 GrPixelConfig writeConfig = srcConfig; |
| 1481 if (fGpu->preferredWritePixelsConfig(srcConfig) == GrPixelConfigSwapRAndB(sr
cConfig)) { | 1482 if (GrPixelConfigSwapRAndB(srcConfig) == |
| 1483 fGpu->preferredWritePixelsConfig(srcConfig, target->config())) { |
| 1482 writeConfig = GrPixelConfigSwapRAndB(srcConfig); | 1484 writeConfig = GrPixelConfigSwapRAndB(srcConfig); |
| 1483 swapRAndB = true; | 1485 swapRAndB = true; |
| 1484 } | 1486 } |
| 1485 | 1487 |
| 1486 GrTextureDesc desc; | 1488 GrTextureDesc desc; |
| 1487 desc.fWidth = width; | 1489 desc.fWidth = width; |
| 1488 desc.fHeight = height; | 1490 desc.fHeight = height; |
| 1489 desc.fConfig = writeConfig; | 1491 desc.fConfig = writeConfig; |
| 1490 GrAutoScratchTexture ast(this, desc); | 1492 GrAutoScratchTexture ast(this, desc); |
| 1491 GrTexture* texture = ast.texture(); | 1493 GrTexture* texture = ast.texture(); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 return srcTexture; | 1863 return srcTexture; |
| 1862 } | 1864 } |
| 1863 } | 1865 } |
| 1864 | 1866 |
| 1865 /////////////////////////////////////////////////////////////////////////////// | 1867 /////////////////////////////////////////////////////////////////////////////// |
| 1866 #if GR_CACHE_STATS | 1868 #if GR_CACHE_STATS |
| 1867 void GrContext::printCacheStats() const { | 1869 void GrContext::printCacheStats() const { |
| 1868 fTextureCache->printStats(); | 1870 fTextureCache->printStats(); |
| 1869 } | 1871 } |
| 1870 #endif | 1872 #endif |
| OLD | NEW |