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) == fGpu->preferredReadPixelsConfig(dst
Config, target->config())) { |
1284 readConfig = GrPixelConfigSwapRAndB(readConfig); | 1284 readConfig = GrPixelConfigSwapRAndB(readConfig); |
1285 swapRAndB = true; | 1285 swapRAndB = true; |
1286 } | 1286 } |
1287 | 1287 |
1288 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); | 1288 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
1289 | 1289 |
1290 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { | 1290 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
1291 // The unpremul flag is only allowed for these two configs. | 1291 // The unpremul flag is only allowed for these two configs. |
1292 return false; | 1292 return false; |
1293 } | 1293 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 srcConfig, buffer, rowBytes, flags); | 1471 srcConfig, buffer, rowBytes, flags); |
1472 } | 1472 } |
1473 #endif | 1473 #endif |
1474 | 1474 |
1475 // We ignore the preferred config unless it is a R/B swap of the src config.
In that case | 1475 // 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 | 1476 // 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 | 1477 // 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. | 1478 // when drawing the scratch to the dst using a conversion effect. |
1479 bool swapRAndB = false; | 1479 bool swapRAndB = false; |
1480 GrPixelConfig writeConfig = srcConfig; | 1480 GrPixelConfig writeConfig = srcConfig; |
1481 if (fGpu->preferredWritePixelsConfig(srcConfig) == GrPixelConfigSwapRAndB(sr
cConfig)) { | 1481 if (fGpu->preferredWritePixelsConfig(srcConfig, target->config()) == GrPixel
ConfigSwapRAndB(srcConfig)) { |
1482 writeConfig = GrPixelConfigSwapRAndB(srcConfig); | 1482 writeConfig = GrPixelConfigSwapRAndB(srcConfig); |
1483 swapRAndB = true; | 1483 swapRAndB = true; |
1484 } | 1484 } |
1485 | 1485 |
1486 GrTextureDesc desc; | 1486 GrTextureDesc desc; |
1487 desc.fWidth = width; | 1487 desc.fWidth = width; |
1488 desc.fHeight = height; | 1488 desc.fHeight = height; |
1489 desc.fConfig = writeConfig; | 1489 desc.fConfig = writeConfig; |
1490 GrAutoScratchTexture ast(this, desc); | 1490 GrAutoScratchTexture ast(this, desc); |
1491 GrTexture* texture = ast.texture(); | 1491 GrTexture* texture = ast.texture(); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 return srcTexture; | 1861 return srcTexture; |
1862 } | 1862 } |
1863 } | 1863 } |
1864 | 1864 |
1865 /////////////////////////////////////////////////////////////////////////////// | 1865 /////////////////////////////////////////////////////////////////////////////// |
1866 #if GR_CACHE_STATS | 1866 #if GR_CACHE_STATS |
1867 void GrContext::printCacheStats() const { | 1867 void GrContext::printCacheStats() const { |
1868 fTextureCache->printStats(); | 1868 fTextureCache->printStats(); |
1869 } | 1869 } |
1870 #endif | 1870 #endif |
OLD | NEW |