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

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

Issue 549143003: Fix bug in layer hoisting transition to SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT 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/gpu/GrLayerCache.cpp ('k') | src/gpu/GrPictureUtils.h » ('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 "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 SkIntToScalar(layer->rect().height() )); 84 SkIntToScalar(layer->rect().height() ));
85 atlasCanvas->clipRect(bound); 85 atlasCanvas->clipRect(bound);
86 86
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 SkMatrix initialCTM;
95 initialCTM.setTranslate(SkIntToScalar(-layer->offset().fX),
96 SkIntToScalar(-layer->offset().fY));
97 initialCTM.postTranslate(bound.fLeft, bound.fTop);
98
99 atlasCanvas->translate(SkIntToScalar(-layer->offset().fX),
100 SkIntToScalar(-layer->offset().fY));
94 atlasCanvas->translate(bound.fLeft, bound.fTop); 101 atlasCanvas->translate(bound.fLeft, bound.fTop);
95 atlasCanvas->concat(layer->ctm()); 102 atlasCanvas->concat(layer->ctm());
96 103
97 SkRecordPartialDraw(*picture->fRecord.get(), atlasCanvas, bound, 104 SkRecordPartialDraw(*picture->fRecord.get(), atlasCanvas, bound,
98 layer->start()+1, layer->stop()); 105 layer->start()+1, layer->stop(), initialCTM);
99 106
100 atlasCanvas->restore(); 107 atlasCanvas->restore();
101 } 108 }
102 109
103 atlasCanvas->flush(); 110 atlasCanvas->flush();
104 } 111 }
105 112
106 // Render the non-atlased layers that require it 113 // Render the non-atlased layers that require it
107 for (int i = 0; i < nonAtlased.count(); ++i) { 114 for (int i = 0; i < nonAtlased.count(); ++i) {
108 GrCachedLayer* layer = nonAtlased[i]; 115 GrCachedLayer* layer = nonAtlased[i];
(...skipping 10 matching lines...) Expand all
119 // extend beyond the boundaries of the atlased sub-rect 126 // extend beyond the boundaries of the atlased sub-rect
120 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft), 127 SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
121 SkIntToScalar(layer->rect().fTop), 128 SkIntToScalar(layer->rect().fTop),
122 SkIntToScalar(layer->rect().width()), 129 SkIntToScalar(layer->rect().width()),
123 SkIntToScalar(layer->rect().height())); 130 SkIntToScalar(layer->rect().height()));
124 131
125 layerCanvas->clipRect(bound); // TODO: still useful? 132 layerCanvas->clipRect(bound); // TODO: still useful?
126 133
127 layerCanvas->clear(SK_ColorTRANSPARENT); 134 layerCanvas->clear(SK_ColorTRANSPARENT);
128 135
136 SkMatrix initialCTM;
137 initialCTM.setTranslate(SkIntToScalar(-layer->offset().fX),
138 SkIntToScalar(-layer->offset().fY));
139
140 layerCanvas->translate(SkIntToScalar(-layer->offset().fX),
141 SkIntToScalar(-layer->offset().fY));
129 layerCanvas->concat(layer->ctm()); 142 layerCanvas->concat(layer->ctm());
130 143
131 SkRecordPartialDraw(*picture->fRecord.get(), layerCanvas, bound, 144 SkRecordPartialDraw(*picture->fRecord.get(), layerCanvas, bound,
132 layer->start()+1, layer->stop()); 145 layer->start()+1, layer->stop(), initialCTM);
133 146
134 layerCanvas->flush(); 147 layerCanvas->flush();
135 } 148 }
136 } 149 }
137 150
138 void GrLayerHoister::UnlockLayers(GrLayerCache* layerCache, const SkPicture* pic ture) { 151 void GrLayerHoister::UnlockLayers(GrLayerCache* layerCache, const SkPicture* pic ture) {
139 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); 152 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey();
140 153
141 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); 154 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key);
142 SkASSERT(data); 155 SkASSERT(data);
143 156
144 const GrAccelData *gpuData = static_cast<const GrAccelData*>(data); 157 const GrAccelData *gpuData = static_cast<const GrAccelData*>(data);
145 SkASSERT(0 != gpuData->numSaveLayers()); 158 SkASSERT(0 != gpuData->numSaveLayers());
146 159
147 // unlock the layers 160 // unlock the layers
148 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { 161 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
149 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); 162 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
150 163
151 GrCachedLayer* layer = layerCache->findLayer(picture->uniqueID(), 164 GrCachedLayer* layer = layerCache->findLayer(picture->uniqueID(),
152 info.fSaveLayerOpID, 165 info.fSaveLayerOpID,
153 info.fRestoreOpID, 166 info.fRestoreOpID,
167 info.fOffset,
154 info.fOriginXform); 168 info.fOriginXform);
155 layerCache->unlock(layer); 169 layerCache->unlock(layer);
156 } 170 }
157 171
158 #if DISABLE_CACHING 172 #if DISABLE_CACHING
159 // This code completely clears out the atlas. It is required when 173 // This code completely clears out the atlas. It is required when
160 // caching is disabled so the atlas doesn't fill up and force more 174 // caching is disabled so the atlas doesn't fill up and force more
161 // free floating layers 175 // free floating layers
162 layerCache->purge(picture->uniqueID()); 176 layerCache->purge(picture->uniqueID());
163 177
164 layerCache->purgeAll(); 178 layerCache->purgeAll();
165 #endif 179 #endif
166 } 180 }
167 181
OLDNEW
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | src/gpu/GrPictureUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698