OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1073 |
1074 // At this point we know we could do the draw by uploading the entire bitmap | 1074 // At this point we know we could do the draw by uploading the entire bitmap |
1075 // as a texture. However, if the texture would be large compared to the | 1075 // as a texture. However, if the texture would be large compared to the |
1076 // cache size and we don't require most of it for this draw then tile to | 1076 // cache size and we don't require most of it for this draw then tile to |
1077 // reduce the amount of upload and cache spill. | 1077 // reduce the amount of upload and cache spill. |
1078 | 1078 |
1079 // assumption here is that sw bitmap size is a good proxy for its size as | 1079 // assumption here is that sw bitmap size is a good proxy for its size as |
1080 // a texture | 1080 // a texture |
1081 size_t bmpSize = bitmap.getSize(); | 1081 size_t bmpSize = bitmap.getSize(); |
1082 size_t cacheSize; | 1082 size_t cacheSize; |
1083 fContext->getTextureCacheLimits(NULL, &cacheSize); | 1083 fContext->getResourceCacheLimits(NULL, &cacheSize); |
1084 if (bmpSize < cacheSize / 2) { | 1084 if (bmpSize < cacheSize / 2) { |
1085 return false; | 1085 return false; |
1086 } | 1086 } |
1087 | 1087 |
1088 // Figure out how much of the src we will need based on the src rect and cli
pping. | 1088 // Figure out how much of the src we will need based on the src rect and cli
pping. |
1089 determine_clipped_src_rect(fContext, bitmap, srcRectPtr, clippedSrcRect); | 1089 determine_clipped_src_rect(fContext, bitmap, srcRectPtr, clippedSrcRect); |
1090 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max
sized tile. | 1090 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max
sized tile. |
1091 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * | 1091 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * |
1092 kBmpSmallTileSize * kBmpSmallTileSize; | 1092 kBmpSmallTileSize * kBmpSmallTileSize; |
1093 | 1093 |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2085 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
2086 | 2086 |
2087 if (NULL != layer->getTexture()) { | 2087 if (NULL != layer->getTexture()) { |
2088 fContext->unlockScratchTexture(layer->getTexture()); | 2088 fContext->unlockScratchTexture(layer->getTexture()); |
2089 layer->setTexture(NULL); | 2089 layer->setTexture(NULL); |
2090 } | 2090 } |
2091 } | 2091 } |
2092 | 2092 |
2093 return true; | 2093 return true; |
2094 } | 2094 } |
OLD | NEW |