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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, info, srcI
R, dstIR, | 225 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, info, srcI
R, dstIR, |
226 needRendering, recycled, false, numSamples); | 226 needRendering, recycled, false, numSamples); |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void GrLayerHoister::DrawLayersToAtlas(GrContext* context, | 230 void GrLayerHoister::DrawLayersToAtlas(GrContext* context, |
231 const SkTDArray<GrHoistedLayer>& atlased)
{ | 231 const SkTDArray<GrHoistedLayer>& atlased)
{ |
232 if (atlased.count() > 0) { | 232 if (atlased.count() > 0) { |
233 // All the atlased layers are rendered into the same GrTexture | 233 // All the atlased layers are rendered into the same GrTexture |
234 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 234 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
235 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 235 auto surface(SkSurface::MakeRenderTargetDirect( |
236 atlased[0].fLayer->texture()->asRenderTa
rget(), &props)); | 236 atlased[0].fLayer->texture()->asRenderTa
rget(), &props)); |
237 | 237 |
238 SkCanvas* atlasCanvas = surface->getCanvas(); | 238 SkCanvas* atlasCanvas = surface->getCanvas(); |
239 | 239 |
240 for (int i = 0; i < atlased.count(); ++i) { | 240 for (int i = 0; i < atlased.count(); ++i) { |
241 const GrCachedLayer* layer = atlased[i].fLayer; | 241 const GrCachedLayer* layer = atlased[i].fLayer; |
242 const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture(); | 242 const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture(); |
243 if (!pict) { | 243 if (!pict) { |
244 // TODO: can we assume / assert this? | 244 // TODO: can we assume / assert this? |
245 continue; | 245 continue; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 GrCachedLayer* layer = layers[i].fLayer; | 327 GrCachedLayer* layer = layers[i].fLayer; |
328 const SkBigPicture* pict = layers[i].fPicture->asSkBigPicture(); | 328 const SkBigPicture* pict = layers[i].fPicture->asSkBigPicture(); |
329 if (!pict) { | 329 if (!pict) { |
330 // TODO: can we assume / assert this? | 330 // TODO: can we assume / assert this? |
331 continue; | 331 continue; |
332 } | 332 } |
333 const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcI
R().fTop); | 333 const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcI
R().fTop); |
334 | 334 |
335 // Each non-atlased layer has its own GrTexture | 335 // Each non-atlased layer has its own GrTexture |
336 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 336 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
337 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 337 auto surface(SkSurface::MakeRenderTargetDirect( |
338 layer->texture()->asRenderTarget(), &pro
ps)); | 338 layer->texture()->asRenderTarget(), &pro
ps)); |
339 | 339 |
340 SkCanvas* layerCanvas = surface->getCanvas(); | 340 SkCanvas* layerCanvas = surface->getCanvas(); |
341 | 341 |
342 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop); | 342 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop); |
343 | 343 |
344 // Add a rect clip to make sure the rendering doesn't | 344 // Add a rect clip to make sure the rendering doesn't |
345 // extend beyond the boundaries of the layer | 345 // extend beyond the boundaries of the layer |
346 const SkRect bound = SkRect::Make(layer->rect()); | 346 const SkRect bound = SkRect::Make(layer->rect()); |
347 layerCanvas->clipRect(bound); | 347 layerCanvas->clipRect(bound); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 #if !GR_CACHE_HOISTED_LAYERS | 388 #if !GR_CACHE_HOISTED_LAYERS |
389 | 389 |
390 // This code completely clears out the atlas. It is required when | 390 // This code completely clears out the atlas. It is required when |
391 // caching is disabled so the atlas doesn't fill up and force more | 391 // caching is disabled so the atlas doesn't fill up and force more |
392 // free floating layers | 392 // free floating layers |
393 layerCache->purgeAll(); | 393 layerCache->purgeAll(); |
394 #endif | 394 #endif |
395 | 395 |
396 layerCache->end(); | 396 layerCache->end(); |
397 } | 397 } |
OLD | NEW |