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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT 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 | « src/core/SkPictureRecorder.cpp ('k') | src/core/SkPixelRef.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 SkPictureShader::~SkPictureShader() { 118 SkPictureShader::~SkPictureShader() {
119 fPicture->unref(); 119 fPicture->unref();
120 } 120 }
121 121
122 SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMo de tmy, 122 SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMo de tmy,
123 const SkMatrix* localMatrix, const SkRe ct* tile) { 123 const SkMatrix* localMatrix, const SkRe ct* tile) {
124 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) { 124 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
125 return SkShader::CreateEmptyShader(); 125 return SkShader::CreateEmptyShader();
126 } 126 }
127 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); 127 return new SkPictureShader(picture, tmx, tmy, localMatrix, tile);
128 } 128 }
129 129
130 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) { 130 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
131 SkMatrix lm; 131 SkMatrix lm;
132 buffer.readMatrix(&lm); 132 buffer.readMatrix(&lm);
133 TileMode mx = (TileMode)buffer.read32(); 133 TileMode mx = (TileMode)buffer.read32();
134 TileMode my = (TileMode)buffer.read32(); 134 TileMode my = (TileMode)buffer.read32();
135 SkRect tile; 135 SkRect tile;
136 buffer.readRect(&tile); 136 buffer.readRect(&tile);
137 137
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 SkCanvas canvas(bm, SkSurfaceProps(0, kUnknown_SkPixelGeometry)); 243 SkCanvas canvas(bm, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
244 244
245 canvas.scale(tileScale.width(), tileScale.height()); 245 canvas.scale(tileScale.width(), tileScale.height());
246 canvas.translate(-fTile.x(), -fTile.y()); 246 canvas.translate(-fTile.x(), -fTile.y());
247 canvas.drawPicture(fPicture); 247 canvas.drawPicture(fPicture);
248 248
249 SkMatrix shaderMatrix = this->getLocalMatrix(); 249 SkMatrix shaderMatrix = this->getLocalMatrix();
250 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); 250 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
251 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); 251 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
252 252
253 SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(), bm.getSize()))); 253 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSi ze()));
254 } 254 }
255 255
256 return tileShader.detach(); 256 return tileShader.detach();
257 } 257 }
258 258
259 size_t SkPictureShader::contextSize() const { 259 size_t SkPictureShader::contextSize() const {
260 return sizeof(PictureShaderContext); 260 return sizeof(PictureShaderContext);
261 } 261 }
262 262
263 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const { 263 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const {
264 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec. fLocalMatrix)); 264 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec. fLocalMatrix));
265 if (NULL == bitmapShader.get()) { 265 if (NULL == bitmapShader.get()) {
266 return NULL; 266 return NULL;
267 } 267 }
268 return PictureShaderContext::Create(storage, *this, rec, bitmapShader); 268 return PictureShaderContext::Create(storage, *this, rec, bitmapShader);
269 } 269 }
270 270
271 //////////////////////////////////////////////////////////////////////////////// ///////// 271 //////////////////////////////////////////////////////////////////////////////// /////////
272 272
273 SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage, 273 SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
274 const SkPictureShader& shader, const ContextRec& rec, SkShade r* bitmapShader) { 274 const SkPictureShader& shader, const ContextRec& rec, SkShade r* bitmapShader) {
275 PictureShaderContext* ctx = SkNEW_PLACEMENT_ARGS(storage, PictureShaderConte xt, 275 PictureShaderContext* ctx = new (storage) PictureShaderContext(shader, rec, bitmapShader);
276 (shader, rec, bitmapShader) );
277 if (NULL == ctx->fBitmapShaderContext) { 276 if (NULL == ctx->fBitmapShaderContext) {
278 ctx->~PictureShaderContext(); 277 ctx->~PictureShaderContext();
279 ctx = NULL; 278 ctx = NULL;
280 } 279 }
281 return ctx; 280 return ctx;
282 } 281 }
283 282
284 SkPictureShader::PictureShaderContext::PictureShaderContext( 283 SkPictureShader::PictureShaderContext::PictureShaderContext(
285 const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapSh ader) 284 const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapSh ader)
286 : INHERITED(shader, rec) 285 : INHERITED(shader, rec)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 procDataManager, fp); 353 procDataManager, fp);
355 } 354 }
356 #else 355 #else
357 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 356 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
358 const SkMatrix*, GrColor*, GrProcessor DataManager*, 357 const SkMatrix*, GrColor*, GrProcessor DataManager*,
359 GrFragmentProcessor**) const { 358 GrFragmentProcessor**) const {
360 SkDEBUGFAIL("Should not call in GPU-less build"); 359 SkDEBUGFAIL("Should not call in GPU-less build");
361 return false; 360 return false;
362 } 361 }
363 #endif 362 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecorder.cpp ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698