Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/gpu/GrLayerHoister.cpp

Issue 540543002: Switch Layer Hoisting over to SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPictureReplacementPlayback.cpp ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkPictureRangePlayback.h"
11 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkRecordDraw.h"
12 #include "SkSurface.h" 12 #include "SkSurface.h"
13 13
14 // Return true if any layers are suitable for hoisting 14 // Return true if any layers are suitable for hoisting
15 bool GrLayerHoister::FindLayersToHoist(const GrAccelData *gpuData, 15 bool GrLayerHoister::FindLayersToHoist(const GrAccelData *gpuData,
16 const SkRect& query, 16 const SkRect& query,
17 bool pullForward[]) { 17 bool pullForward[]) {
18 bool anyHoisted = false; 18 bool anyHoisted = false;
19 19
20 // Layer hoisting pre-renders the entire layer since it will be cached and p otentially 20 // Layer hoisting pre-renders the entire layer since it will be cached and p otentially
21 // reused with different clips (e.g., in different tiles). Because of this t he 21 // reused with different clips (e.g., in different tiles). Because of this t he
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Since 'clear' doesn't respect the clip we need to draw a rect 87 // Since 'clear' doesn't respect the clip we need to draw a rect
88 // TODO: ensure none of the atlased layers contain a clear call! 88 // TODO: ensure none of the atlased layers contain a clear call!
89 atlasCanvas->drawRect(bound, paint); 89 atlasCanvas->drawRect(bound, paint);
90 90
91 // info.fCTM maps the layer's top/left to the origin. 91 // info.fCTM maps the layer's top/left to the origin.
92 // Since this layer is atlased, the top/left corner needs 92 // Since this layer is atlased, the top/left corner needs
93 // to be offset to the correct location in the backing texture. 93 // to be offset to the correct location in the backing texture.
94 atlasCanvas->translate(bound.fLeft, bound.fTop); 94 atlasCanvas->translate(bound.fLeft, bound.fTop);
95 atlasCanvas->concat(layer->ctm()); 95 atlasCanvas->concat(layer->ctm());
96 96
97 SkPictureRangePlayback rangePlayback(picture, 97 SkRecordPartialDraw(*picture->fRecord.get(), atlasCanvas, bound,
98 layer->start(), 98 layer->start(), layer->stop());
99 layer->stop());
100 rangePlayback.draw(atlasCanvas, NULL);
101 99
102 atlasCanvas->restore(); 100 atlasCanvas->restore();
103 } 101 }
104 102
105 atlasCanvas->flush(); 103 atlasCanvas->flush();
106 } 104 }
107 105
108 // Render the non-atlased layers that require it 106 // Render the non-atlased layers that require it
109 for (int i = 0; i < nonAtlased.count(); ++i) { 107 for (int i = 0; i < nonAtlased.count(); ++i) {
110 GrCachedLayer* layer = nonAtlased[i]; 108 GrCachedLayer* layer = nonAtlased[i];
111 109
112 // Each non-atlased layer has its own GrTexture 110 // Each non-atlased layer has its own GrTexture
113 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( 111 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
114 layer->texture()->asRenderTarget(), 112 layer->texture()->asRenderTarget (),
115 SkSurface::kStandard_TextRenderMode, 113 SkSurface::kStandard_TextRenderM ode,
116 SkSurface::kDontClear_RenderTargetFlag)); 114 SkSurface::kDontClear_RenderTarg etFlag));
117 115
118 SkCanvas* layerCanvas = surface->getCanvas(); 116 SkCanvas* layerCanvas = surface->getCanvas();
119 117
120 // Add a rect clip to make sure the rendering doesn't 118 // Add a rect clip to make sure the rendering doesn't
121 // extend beyond the boundaries of the atlased sub-rect 119 // extend beyond the boundaries of the atlased sub-rect
122 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), 120 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
123 SkIntToScalar(layer->rect().fTop), 121 SkIntToScalar(layer->rect().fTop),
124 SkIntToScalar(layer->rect().width()), 122 SkIntToScalar(layer->rect().width()),
125 SkIntToScalar(layer->rect().height())); 123 SkIntToScalar(layer->rect().height()));
126 124
127 layerCanvas->clipRect(bound); // TODO: still useful? 125 layerCanvas->clipRect(bound); // TODO: still useful?
128 126
129 layerCanvas->clear(SK_ColorTRANSPARENT); 127 layerCanvas->clear(SK_ColorTRANSPARENT);
130 128
131 layerCanvas->concat(layer->ctm()); 129 layerCanvas->concat(layer->ctm());
132 130
133 SkPictureRangePlayback rangePlayback(picture, 131 SkRecordPartialDraw(*picture->fRecord.get(), layerCanvas, bound,
134 layer->start(), 132 layer->start(), layer->stop());
135 layer->stop());
136 rangePlayback.draw(layerCanvas, NULL);
137 133
138 layerCanvas->flush(); 134 layerCanvas->flush();
139 } 135 }
140 } 136 }
141 137
142 void GrLayerHoister::UnlockLayers(GrLayerCache* layerCache, const SkPicture* pic ture) { 138 void GrLayerHoister::UnlockLayers(GrLayerCache* layerCache, const SkPicture* pic ture) {
143 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); 139 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey();
144 140
145 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); 141 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key);
146 SkASSERT(NULL != data); 142 SkASSERT(NULL != data);
(...skipping 15 matching lines...) Expand all
162 #if DISABLE_CACHING 158 #if DISABLE_CACHING
163 // This code completely clears out the atlas. It is required when 159 // This code completely clears out the atlas. It is required when
164 // caching is disabled so the atlas doesn't fill up and force more 160 // caching is disabled so the atlas doesn't fill up and force more
165 // free floating layers 161 // free floating layers
166 layerCache->purge(picture->uniqueID()); 162 layerCache->purge(picture->uniqueID());
167 163
168 layerCache->purgeAll(); 164 layerCache->purgeAll();
169 #endif 165 #endif
170 } 166 }
171 167
OLDNEW
« no previous file with comments | « src/core/SkPictureReplacementPlayback.cpp ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698