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

Side by Side Diff: src/core/SkPictureShader.cpp

Issue 1327943003: Clean up some lint complaints and fix center_of_mass() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | src/gpu/batches/GrAAConvexPathRenderer.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 "SkPictureShader.h" 8 #include "SkPictureShader.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // The deserialization code won't trust that our serialized picture is safe to deserialize. 148 // The deserialization code won't trust that our serialized picture is safe to deserialize.
149 // So write a 'false' telling it that we're not serializing a picture. 149 // So write a 'false' telling it that we're not serializing a picture.
150 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) { 150 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
151 buffer.writeBool(false); 151 buffer.writeBool(false);
152 } else { 152 } else {
153 buffer.writeBool(true); 153 buffer.writeBool(true);
154 fPicture->flatten(buffer); 154 fPicture->flatten(buffer);
155 } 155 }
156 } 156 }
157 157
158 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri x* localM, 158 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM atrix* localM,
159 const int maxTextureSize) const { 159 const int maxTextureSize) const {
160 SkASSERT(fPicture && !fPicture->cullRect().isEmpty()); 160 SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
161 161
162 SkMatrix m; 162 SkMatrix m;
163 m.setConcat(matrix, this->getLocalMatrix()); 163 m.setConcat(viewMatrix, this->getLocalMatrix());
164 if (localM) { 164 if (localM) {
165 m.preConcat(*localM); 165 m.preConcat(*localM);
166 } 166 }
167 167
168 // Use a rotation-invariant scale 168 // Use a rotation-invariant scale
169 SkPoint scale; 169 SkPoint scale;
170 // 170 //
171 // TODO: replace this with decomposeScale() -- but beware LayoutTest rebasel ines! 171 // TODO: replace this with decomposeScale() -- but beware LayoutTest rebasel ines!
172 // 172 //
173 if (!SkDecomposeUpper2x2(m, nullptr, &scale, nullptr)) { 173 if (!SkDecomposeUpper2x2(m, nullptr, &scale, nullptr)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 SkAutoTUnref<SkShader> tileShader; 209 SkAutoTUnref<SkShader> tileShader;
210 BitmapShaderKey key(fPicture->uniqueID(), 210 BitmapShaderKey key(fPicture->uniqueID(),
211 fTile, 211 fTile,
212 fTmx, 212 fTmx,
213 fTmy, 213 fTmy,
214 tileScale, 214 tileScale,
215 this->getLocalMatrix()); 215 this->getLocalMatrix());
216 216
217 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { 217 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
218 SkMatrix matrix; 218 SkMatrix tileMatrix;
219 matrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.h eight()), 219 tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSi ze.height()),
220 SkMatrix::kFill_ScaleToFit); 220 SkMatrix::kFill_ScaleToFit);
221 SkBitmap bm; 221 SkBitmap bm;
222 if (!SkInstallDiscardablePixelRef( 222 if (!SkInstallDiscardablePixelRef(
223 SkImageGenerator::NewFromPicture(tileSize, fPicture, &matrix, nullpt r), &bm)) { 223 SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nu llptr), &bm)) {
224 return nullptr; 224 return nullptr;
225 } 225 }
226 226
227 SkMatrix shaderMatrix = this->getLocalMatrix(); 227 SkMatrix shaderMatrix = this->getLocalMatrix();
228 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); 228 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
229 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); 229 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
230 230
231 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSi ze())); 231 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSi ze()));
232 } 232 }
233 233
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (context) { 324 if (context) {
325 maxTextureSize = context->caps()->maxTextureSize(); 325 maxTextureSize = context->caps()->maxTextureSize();
326 } 326 }
327 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize)); 327 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize));
328 if (!bitmapShader) { 328 if (!bitmapShader) {
329 return nullptr; 329 return nullptr;
330 } 330 }
331 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq, procDa taManager); 331 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq, procDa taManager);
332 } 332 }
333 #endif 333 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/batches/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698