| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // Since this layer is atlased, the top/left corner needs | 259 // Since this layer is atlased, the top/left corner needs |
| 260 // to be offset to the correct location in the backing texture. | 260 // to be offset to the correct location in the backing texture. |
| 261 SkMatrix initialCTM; | 261 SkMatrix initialCTM; |
| 262 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-of
fset.fY)); | 262 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-of
fset.fY)); |
| 263 initialCTM.preTranslate(bound.fLeft, bound.fTop); | 263 initialCTM.preTranslate(bound.fLeft, bound.fTop); |
| 264 initialCTM.preConcat(atlased[i].fPreMat); | 264 initialCTM.preConcat(atlased[i].fPreMat); |
| 265 | 265 |
| 266 atlasCanvas->setMatrix(initialCTM); | 266 atlasCanvas->setMatrix(initialCTM); |
| 267 atlasCanvas->concat(atlased[i].fLocalMat); | 267 atlasCanvas->concat(atlased[i].fLocalMat); |
| 268 | 268 |
| 269 SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, bound, | 269 SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, |
| 270 layer->start() + 1, layer->stop(), initialCTM); | 270 pict->drawablePicts(), pict->drawableCount(), |
| 271 bound, layer->start() + 1, layer->stop(), initia
lCTM); |
| 271 | 272 |
| 272 atlasCanvas->restore(); | 273 atlasCanvas->restore(); |
| 273 } | 274 } |
| 274 | 275 |
| 275 atlasCanvas->flush(); | 276 atlasCanvas->flush(); |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
er>& layers) { | 280 void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
er>& layers) { |
| 280 for (int i = 0; i < layers.count(); ++i) { | 281 for (int i = 0; i < layers.count(); ++i) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 301 | 302 |
| 302 layerCanvas->clear(SK_ColorTRANSPARENT); | 303 layerCanvas->clear(SK_ColorTRANSPARENT); |
| 303 | 304 |
| 304 SkMatrix initialCTM; | 305 SkMatrix initialCTM; |
| 305 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-offset
.fY)); | 306 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-offset
.fY)); |
| 306 initialCTM.preConcat(layers[i].fPreMat); | 307 initialCTM.preConcat(layers[i].fPreMat); |
| 307 | 308 |
| 308 layerCanvas->setMatrix(initialCTM); | 309 layerCanvas->setMatrix(initialCTM); |
| 309 layerCanvas->concat(layers[i].fLocalMat); | 310 layerCanvas->concat(layers[i].fLocalMat); |
| 310 | 311 |
| 311 SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, bound, | 312 SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, |
| 312 layer->start()+1, layer->stop(), initialCTM); | 313 pict->drawablePicts(), pict->drawableCount(), |
| 314 bound, layer->start()+1, layer->stop(), initialCTM); |
| 313 | 315 |
| 314 layerCanvas->flush(); | 316 layerCanvas->flush(); |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 | 319 |
| 318 void GrLayerHoister::UnlockLayers(GrContext* context, | 320 void GrLayerHoister::UnlockLayers(GrContext* context, |
| 319 const SkTDArray<GrHoistedLayer>& layers) { | 321 const SkTDArray<GrHoistedLayer>& layers) { |
| 320 GrLayerCache* layerCache = context->getLayerCache(); | 322 GrLayerCache* layerCache = context->getLayerCache(); |
| 321 | 323 |
| 322 for (int i = 0; i < layers.count(); ++i) { | 324 for (int i = 0; i < layers.count(); ++i) { |
| 323 layerCache->removeUse(layers[i].fLayer); | 325 layerCache->removeUse(layers[i].fLayer); |
| 324 } | 326 } |
| 325 | 327 |
| 326 SkDEBUGCODE(layerCache->validate();) | 328 SkDEBUGCODE(layerCache->validate();) |
| 327 } | 329 } |
| 328 | 330 |
| 329 void GrLayerHoister::PurgeCache(GrContext* context) { | 331 void GrLayerHoister::PurgeCache(GrContext* context) { |
| 330 #if !GR_CACHE_HOISTED_LAYERS | 332 #if !GR_CACHE_HOISTED_LAYERS |
| 331 GrLayerCache* layerCache = context->getLayerCache(); | 333 GrLayerCache* layerCache = context->getLayerCache(); |
| 332 | 334 |
| 333 // This code completely clears out the atlas. It is required when | 335 // This code completely clears out the atlas. It is required when |
| 334 // caching is disabled so the atlas doesn't fill up and force more | 336 // caching is disabled so the atlas doesn't fill up and force more |
| 335 // free floating layers | 337 // free floating layers |
| 336 layerCache->purgeAll(); | 338 layerCache->purgeAll(); |
| 337 #endif | 339 #endif |
| 338 } | 340 } |
| OLD | NEW |