| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 void GrLayerHoister::DrawLayers(const SkPicture* picture, | 137 void GrLayerHoister::DrawLayers(const SkPicture* picture, |
| 138 const SkTDArray<GrCachedLayer*>& atlased, | 138 const SkTDArray<GrCachedLayer*>& atlased, |
| 139 const SkTDArray<GrCachedLayer*>& nonAtlased, | 139 const SkTDArray<GrCachedLayer*>& nonAtlased, |
| 140 GrReplacements* replacements) { | 140 GrReplacements* replacements) { |
| 141 // Render the atlased layers that require it | 141 // Render the atlased layers that require it |
| 142 if (atlased.count() > 0) { | 142 if (atlased.count() > 0) { |
| 143 // All the atlased layers are rendered into the same GrTexture | 143 // All the atlased layers are rendered into the same GrTexture |
| 144 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 144 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( |
| 145 atlased[0]->texture()->asRenderT
arget(), | 145 atlased[0]->texture()->asRenderT
arget(), |
| 146 SkSurface::kStandard_TextRenderM
ode, | 146 SkSurface::kStandard_TextRenderM
ode)); |
| 147 SkSurface::kDontClear_RenderTarg
etFlag)); | |
| 148 | 147 |
| 149 SkCanvas* atlasCanvas = surface->getCanvas(); | 148 SkCanvas* atlasCanvas = surface->getCanvas(); |
| 150 | 149 |
| 151 SkPaint paint; | 150 SkPaint paint; |
| 152 paint.setColor(SK_ColorTRANSPARENT); | 151 paint.setColor(SK_ColorTRANSPARENT); |
| 153 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref(); | 152 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref(); |
| 154 | 153 |
| 155 for (int i = 0; i < atlased.count(); ++i) { | 154 for (int i = 0; i < atlased.count(); ++i) { |
| 156 GrCachedLayer* layer = atlased[i]; | 155 GrCachedLayer* layer = atlased[i]; |
| 157 | 156 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 atlasCanvas->flush(); | 190 atlasCanvas->flush(); |
| 192 } | 191 } |
| 193 | 192 |
| 194 // Render the non-atlased layers that require it | 193 // Render the non-atlased layers that require it |
| 195 for (int i = 0; i < nonAtlased.count(); ++i) { | 194 for (int i = 0; i < nonAtlased.count(); ++i) { |
| 196 GrCachedLayer* layer = nonAtlased[i]; | 195 GrCachedLayer* layer = nonAtlased[i]; |
| 197 | 196 |
| 198 // Each non-atlased layer has its own GrTexture | 197 // Each non-atlased layer has its own GrTexture |
| 199 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( | 198 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( |
| 200 layer->texture()->asRenderTarget
(), | 199 layer->texture()->asRenderTarget
(), |
| 201 SkSurface::kStandard_TextRenderM
ode, | 200 SkSurface::kStandard_TextRenderM
ode)); |
| 202 SkSurface::kDontClear_RenderTarg
etFlag)); | |
| 203 | 201 |
| 204 SkCanvas* layerCanvas = surface->getCanvas(); | 202 SkCanvas* layerCanvas = surface->getCanvas(); |
| 205 | 203 |
| 206 // Add a rect clip to make sure the rendering doesn't | 204 // Add a rect clip to make sure the rendering doesn't |
| 207 // extend beyond the boundaries of the atlased sub-rect | 205 // extend beyond the boundaries of the atlased sub-rect |
| 208 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), | 206 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), |
| 209 SkIntToScalar(layer->rect().fTop), | 207 SkIntToScalar(layer->rect().fTop), |
| 210 SkIntToScalar(layer->rect().width()), | 208 SkIntToScalar(layer->rect().width()), |
| 211 SkIntToScalar(layer->rect().height())); | 209 SkIntToScalar(layer->rect().height())); |
| 212 | 210 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 #if DISABLE_CACHING | 254 #if DISABLE_CACHING |
| 257 // This code completely clears out the atlas. It is required when | 255 // This code completely clears out the atlas. It is required when |
| 258 // caching is disabled so the atlas doesn't fill up and force more | 256 // caching is disabled so the atlas doesn't fill up and force more |
| 259 // free floating layers | 257 // free floating layers |
| 260 layerCache->purge(picture->uniqueID()); | 258 layerCache->purge(picture->uniqueID()); |
| 261 | 259 |
| 262 layerCache->purgeAll(); | 260 layerCache->purgeAll(); |
| 263 #endif | 261 #endif |
| 264 } | 262 } |
| 265 | 263 |
| OLD | NEW |