| 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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return anyHoisted; | 54 return anyHoisted; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void GrLayerHoister::DrawLayers(const SkPicture* picture, | 57 void GrLayerHoister::DrawLayers(const SkPicture* picture, |
| 58 const SkTDArray<GrCachedLayer*>& atlased, | 58 const SkTDArray<GrCachedLayer*>& atlased, |
| 59 const SkTDArray<GrCachedLayer*>& nonAtlased) { | 59 const SkTDArray<GrCachedLayer*>& nonAtlased) { |
| 60 // Render the atlased layers that require it | 60 // Render the atlased layers that require it |
| 61 if (atlased.count() > 0) { | 61 if (atlased.count() > 0) { |
| 62 // All the atlased layers are rendered into the same GrTexture | 62 // All the atlased layers are rendered into the same GrTexture |
| 63 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 63 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( |
| 64 atlased[0]->texture()->asRenderT
arget(), | 64 atlased[0]->texture()->asRenderTarget(),
NULL, |
| 65 SkSurface::kStandard_TextRenderM
ode, | 65 SkSurface::kDontClear_RenderTargetFlag))
; |
| 66 SkSurface::kDontClear_RenderTarg
etFlag)); | |
| 67 | 66 |
| 68 SkCanvas* atlasCanvas = surface->getCanvas(); | 67 SkCanvas* atlasCanvas = surface->getCanvas(); |
| 69 | 68 |
| 70 SkPaint paint; | 69 SkPaint paint; |
| 71 paint.setColor(SK_ColorTRANSPARENT); | 70 paint.setColor(SK_ColorTRANSPARENT); |
| 72 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref(); | 71 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref(); |
| 73 | 72 |
| 74 for (int i = 0; i < atlased.count(); ++i) { | 73 for (int i = 0; i < atlased.count(); ++i) { |
| 75 GrCachedLayer* layer = atlased[i]; | 74 GrCachedLayer* layer = atlased[i]; |
| 76 | 75 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 108 |
| 110 atlasCanvas->flush(); | 109 atlasCanvas->flush(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 // Render the non-atlased layers that require it | 112 // Render the non-atlased layers that require it |
| 114 for (int i = 0; i < nonAtlased.count(); ++i) { | 113 for (int i = 0; i < nonAtlased.count(); ++i) { |
| 115 GrCachedLayer* layer = nonAtlased[i]; | 114 GrCachedLayer* layer = nonAtlased[i]; |
| 116 | 115 |
| 117 // Each non-atlased layer has its own GrTexture | 116 // Each non-atlased layer has its own GrTexture |
| 118 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 117 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( |
| 119 layer->texture()->asRenderTarget
(), | 118 layer->texture()->asRenderTarget(), NULL
, |
| 120 SkSurface::kStandard_TextRenderM
ode, | 119 SkSurface::kDontClear_RenderTargetFlag))
; |
| 121 SkSurface::kDontClear_RenderTarg
etFlag)); | |
| 122 | 120 |
| 123 SkCanvas* layerCanvas = surface->getCanvas(); | 121 SkCanvas* layerCanvas = surface->getCanvas(); |
| 124 | 122 |
| 125 // Add a rect clip to make sure the rendering doesn't | 123 // Add a rect clip to make sure the rendering doesn't |
| 126 // extend beyond the boundaries of the atlased sub-rect | 124 // extend beyond the boundaries of the atlased sub-rect |
| 127 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), | 125 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), |
| 128 SkIntToScalar(layer->rect().fTop), | 126 SkIntToScalar(layer->rect().fTop), |
| 129 SkIntToScalar(layer->rect().width()), | 127 SkIntToScalar(layer->rect().width()), |
| 130 SkIntToScalar(layer->rect().height())); | 128 SkIntToScalar(layer->rect().height())); |
| 131 | 129 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 #if DISABLE_CACHING | 170 #if DISABLE_CACHING |
| 173 // This code completely clears out the atlas. It is required when | 171 // This code completely clears out the atlas. It is required when |
| 174 // caching is disabled so the atlas doesn't fill up and force more | 172 // caching is disabled so the atlas doesn't fill up and force more |
| 175 // free floating layers | 173 // free floating layers |
| 176 layerCache->purge(picture->uniqueID()); | 174 layerCache->purge(picture->uniqueID()); |
| 177 | 175 |
| 178 layerCache->purgeAll(); | 176 layerCache->purgeAll(); |
| 179 #endif | 177 #endif |
| 180 } | 178 } |
| 181 | 179 |
| OLD | NEW |