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