| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrLayerCache.h" | 8 #include "GrLayerCache.h" |
| 9 #include "GrLayerHoister.h" | 9 #include "GrLayerHoister.h" |
| 10 #include "GrRecordReplaceDraw.h" | 10 #include "GrRecordReplaceDraw.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 layerCache->addUse(layer); | 76 layerCache->addUse(layer); |
| 77 hl->fLayer = layer; | 77 hl->fLayer = layer; |
| 78 hl->fPicture = pict; | 78 hl->fPicture = pict; |
| 79 hl->fLocalMat = info.fLocalMat; | 79 hl->fLocalMat = info.fLocalMat; |
| 80 hl->fInitialMat = initialMat; | 80 hl->fInitialMat = initialMat; |
| 81 hl->fPreMat = initialMat; | 81 hl->fPreMat = initialMat; |
| 82 hl->fPreMat.preConcat(info.fPreMat); | 82 hl->fPreMat.preConcat(info.fPreMat); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Compute the source rect if possible and return false if further processing | 85 // Compute the source rect and return false if it is empty. |
| 86 // on the layer should be abandoned based on its source rect. | |
| 87 static bool compute_source_rect(const SkLayerInfo::BlockInfo& info, const SkMatr
ix& initialMat, | 86 static bool compute_source_rect(const SkLayerInfo::BlockInfo& info, const SkMatr
ix& initialMat, |
| 88 const SkIRect& dstIR, SkIRect* srcIR) { | 87 const SkIRect& dstIR, SkIRect* srcIR) { |
| 89 SkIRect clipBounds = dstIR; | 88 SkIRect clipBounds = dstIR; |
| 90 | 89 |
| 91 SkMatrix totMat = initialMat; | 90 SkMatrix totMat = initialMat; |
| 92 totMat.preConcat(info.fPreMat); | 91 totMat.preConcat(info.fPreMat); |
| 93 totMat.preConcat(info.fLocalMat); | 92 totMat.preConcat(info.fLocalMat); |
| 94 | 93 |
| 95 if (info.fPaint && info.fPaint->getImageFilter()) { | 94 if (info.fPaint && info.fPaint->getImageFilter()) { |
| 96 info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat, &clipBou
nds); | 95 info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat, &clipBou
nds); |
| 97 } | 96 } |
| 98 | 97 |
| 99 if (!info.fSrcBounds.isEmpty()) { | 98 if (!info.fSrcBounds.isEmpty()) { |
| 100 SkRect r; | 99 SkRect r; |
| 101 | 100 |
| 102 totMat.mapRect(&r, info.fSrcBounds); | 101 totMat.mapRect(&r, info.fSrcBounds); |
| 103 r.roundOut(srcIR); | 102 r.roundOut(srcIR); |
| 104 | 103 |
| 105 if (!srcIR->intersect(clipBounds)) { | 104 if (!srcIR->intersect(clipBounds)) { |
| 106 return false; | 105 return false; |
| 107 } | 106 } |
| 108 } else { | 107 } else { |
| 109 *srcIR = clipBounds; | 108 *srcIR = clipBounds; |
| 110 } | 109 } |
| 111 | 110 |
| 112 if (!GrLayerCache::PlausiblyAtlasable(srcIR->width(), srcIR->height())) { | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 return true; | 111 return true; |
| 117 } | 112 } |
| 118 | 113 |
| 119 // Atlased layers must be small enough to fit in the atlas, not have a | 114 // Atlased layers must be small enough to fit in the atlas, not have a |
| 120 // paint with an image filter and be neither nested nor nesting. | 115 // paint with an image filter and be neither nested nor nesting. |
| 121 // TODO: allow leaf nested layers to appear in the atlas. | 116 // TODO: allow leaf nested layers to appear in the atlas. |
| 122 void GrLayerHoister::FindLayersToAtlas(GrContext* context, | 117 void GrLayerHoister::FindLayersToAtlas(GrContext* context, |
| 123 const SkPicture* topLevelPicture, | 118 const SkPicture* topLevelPicture, |
| 124 const SkMatrix& initialMat, | 119 const SkMatrix& initialMat, |
| 125 const SkRect& query, | 120 const SkRect& query, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 SkRect layerRect; | 158 SkRect layerRect; |
| 164 initialMat.mapRect(&layerRect, info.fBounds); | 159 initialMat.mapRect(&layerRect, info.fBounds); |
| 165 if (!layerRect.intersect(query)) { | 160 if (!layerRect.intersect(query)) { |
| 166 continue; | 161 continue; |
| 167 } | 162 } |
| 168 | 163 |
| 169 const SkIRect dstIR = layerRect.roundOut(); | 164 const SkIRect dstIR = layerRect.roundOut(); |
| 170 | 165 |
| 171 SkIRect srcIR; | 166 SkIRect srcIR; |
| 172 | 167 |
| 173 if (!compute_source_rect(info, initialMat, dstIR, &srcIR)) { | 168 if (!compute_source_rect(info, initialMat, dstIR, &srcIR) || |
| 169 !GrLayerCache::PlausiblyAtlasable(srcIR.width(), srcIR.height())) { |
| 174 continue; | 170 continue; |
| 175 } | 171 } |
| 176 | 172 |
| 177 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, | 173 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, |
| 178 info, srcIR, dstIR, atlased, recycled, true, 0); | 174 info, srcIR, dstIR, atlased, recycled, true, 0); |
| 179 } | 175 } |
| 180 | 176 |
| 181 } | 177 } |
| 182 | 178 |
| 183 void GrLayerHoister::FindLayersToHoist(GrContext* context, | 179 void GrLayerHoister::FindLayersToHoist(GrContext* context, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 void GrLayerHoister::PurgeCache(GrContext* context) { | 370 void GrLayerHoister::PurgeCache(GrContext* context) { |
| 375 #if !GR_CACHE_HOISTED_LAYERS | 371 #if !GR_CACHE_HOISTED_LAYERS |
| 376 GrLayerCache* layerCache = context->getLayerCache(); | 372 GrLayerCache* layerCache = context->getLayerCache(); |
| 377 | 373 |
| 378 // This code completely clears out the atlas. It is required when | 374 // This code completely clears out the atlas. It is required when |
| 379 // caching is disabled so the atlas doesn't fill up and force more | 375 // caching is disabled so the atlas doesn't fill up and force more |
| 380 // free floating layers | 376 // free floating layers |
| 381 layerCache->purgeAll(); | 377 layerCache->purgeAll(); |
| 382 #endif | 378 #endif |
| 383 } | 379 } |
| OLD | NEW |