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

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

Issue 2197243003: Replace old SkRecords RefBox with sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: builds Created 4 years, 4 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/SkRecordDraw.cpp ('k') | no next file » | 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 "SkBigPicture.h" 8 #include "SkBigPicture.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 const SkRect& dst, 201 const SkRect& dst,
202 const SkPaint* paint) { 202 const SkPaint* paint) {
203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap); 203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
204 if (image) { 204 if (image) {
205 this->onDrawImageNine(image.get(), center, dst, paint); 205 this->onDrawImageNine(image.get(), center, dst, paint);
206 } 206 }
207 } 207 }
208 208
209 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, 209 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
210 const SkPaint* paint) { 210 const SkPaint* paint) {
211 APPEND(DrawImage, this->copy(paint), image, left, top); 211 APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top);
212 } 212 }
213 213
214 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, 214 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
215 const SkPaint* paint, SrcRectConstraint constra int) { 215 const SkPaint* paint, SrcRectConstraint constra int) {
216 APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constr aint); 216 APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
217 } 217 }
218 218
219 void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center, 219 void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
220 const SkRect& dst, const SkPaint* paint) { 220 const SkRect& dst, const SkPaint* paint) {
221 APPEND(DrawImageNine, this->copy(paint), image, center, dst); 221 APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst);
222 } 222 }
223 223
224 void SkRecorder::onDrawText(const void* text, size_t byteLength, 224 void SkRecorder::onDrawText(const void* text, size_t byteLength,
225 SkScalar x, SkScalar y, const SkPaint& paint) { 225 SkScalar x, SkScalar y, const SkPaint& paint) {
226 APPEND(DrawText, 226 APPEND(DrawText,
227 paint, this->copy((const char*)text, byteLength), byteLength, x, y); 227 paint, this->copy((const char*)text, byteLength), byteLength, x, y);
228 } 228 }
229 229
230 void SkRecorder::onDrawPosText(const void* text, size_t byteLength, 230 void SkRecorder::onDrawPosText(const void* text, size_t byteLength,
231 const SkPoint pos[], const SkPaint& paint) { 231 const SkPoint pos[], const SkPaint& paint) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 paint, 264 paint,
265 this->copy((const char*)text, byteLength), 265 this->copy((const char*)text, byteLength),
266 byteLength, 266 byteLength,
267 this->copy(xform, paint.countText(text, byteLength)), 267 this->copy(xform, paint.countText(text, byteLength)),
268 this->copy(cull)); 268 this->copy(cull));
269 } 269 }
270 270
271 void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 271 void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
272 const SkPaint& paint) { 272 const SkPaint& paint) {
273 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint); 273 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint);
274 APPEND(DrawTextBlob, paint, blob, x, y); 274 APPEND(DrawTextBlob, paint, sk_ref_sp(blob), x, y);
275 } 275 }
276 276
277 void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, con st SkPaint* paint) { 277 void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, con st SkPaint* paint) {
278 if (fDrawPictureMode == Record_DrawPictureMode) { 278 if (fDrawPictureMode == Record_DrawPictureMode) {
279 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pi c); 279 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pi c);
280 APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix: :I()); 280 APPEND(DrawPicture, this->copy(paint), sk_ref_sp(pic), matrix ? *matrix : SkMatrix::I());
281 } else { 281 } else {
282 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode); 282 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
283 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect()); 283 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
284 pic->playback(this); 284 pic->playback(this);
285 } 285 }
286 } 286 }
287 287
288 void SkRecorder::onDrawShadowedPicture(const SkPicture* pic, 288 void SkRecorder::onDrawShadowedPicture(const SkPicture* pic,
289 const SkMatrix* matrix, 289 const SkMatrix* matrix,
290 const SkPaint* paint) { 290 const SkPaint* paint) {
291 if (fDrawPictureMode == Record_DrawPictureMode) { 291 if (fDrawPictureMode == Record_DrawPictureMode) {
292 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pi c); 292 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pi c);
293 APPEND(DrawShadowedPicture, this->copy(paint), pic, matrix ? *matrix : S kMatrix::I()); 293 APPEND(DrawShadowedPicture, this->copy(paint),
294 sk_ref_sp(pic),
295 matrix ? *matrix : SkMatrix::I());
294 } else { 296 } else {
295 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode); 297 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
296 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect()); 298 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
297 pic->playback(this); 299 pic->playback(this);
298 } 300 }
299 } 301 }
300 302
301 303
302 void SkRecorder::onDrawVertices(VertexMode vmode, 304 void SkRecorder::onDrawVertices(VertexMode vmode,
303 int vertexCount, const SkPoint vertices[], 305 int vertexCount, const SkPoint vertices[],
304 const SkPoint texs[], const SkColor colors[], 306 const SkPoint texs[], const SkColor colors[],
305 SkXfermode* xmode, 307 SkXfermode* xmode,
306 const uint16_t indices[], int indexCount, const SkPaint& paint) { 308 const uint16_t indices[], int indexCount, const SkPaint& paint) {
307 APPEND(DrawVertices, paint, 309 APPEND(DrawVertices, paint,
308 vmode, 310 vmode,
309 vertexCount, 311 vertexCount,
310 this->copy(vertices, vertexCount), 312 this->copy(vertices, vertexCount),
311 texs ? this->copy(texs, vertexCount) : nullptr, 313 texs ? this->copy(texs, vertexCount) : nullptr,
312 colors ? this->copy(colors, vertexCount) : nullptr, 314 colors ? this->copy(colors, vertexCount) : nullptr,
313 xmode, 315 sk_ref_sp(xmode),
314 this->copy(indices, indexCount), 316 this->copy(indices, indexCount),
315 indexCount); 317 indexCount);
316 } 318 }
317 319
318 void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 320 void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
319 const SkPoint texCoords[4], SkXfermode* xmode, cons t SkPaint& paint) { 321 const SkPoint texCoords[4], SkXfermode* xmode, cons t SkPaint& paint) {
320 APPEND(DrawPatch, paint, 322 APPEND(DrawPatch, paint,
321 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : nullptr, 323 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : nullptr,
322 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : nullptr, 324 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : nullptr,
323 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : nullpt r, 325 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : nullpt r,
324 xmode); 326 sk_ref_sp(xmode));
325 } 327 }
326 328
327 void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], cons t SkRect tex[], 329 void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], cons t SkRect tex[],
328 const SkColor colors[], int count, SkXfermode::Mode mode, 330 const SkColor colors[], int count, SkXfermode::Mode mode,
329 const SkRect* cull, const SkPaint* paint) { 331 const SkRect* cull, const SkPaint* paint) {
330 APPEND(DrawAtlas, this->copy(paint), 332 APPEND(DrawAtlas, this->copy(paint),
331 atlas, 333 sk_ref_sp(atlas),
332 this->copy(xform, count), 334 this->copy(xform, count),
333 this->copy(tex, count), 335 this->copy(tex, count),
334 this->copy(colors, count), 336 this->copy(colors, count),
335 count, 337 count,
336 mode, 338 mode,
337 this->copy(cull)); 339 this->copy(cull));
338 } 340 }
339 341
340 void SkRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) { 342 void SkRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
341 APPEND(DrawAnnotation, rect, SkString(key), value); 343 APPEND(DrawAnnotation, rect, SkString(key), sk_ref_sp(value));
342 } 344 }
343 345
344 void SkRecorder::willSave() { 346 void SkRecorder::willSave() {
345 APPEND(Save); 347 APPEND(Save);
346 } 348 }
347 349
348 SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) { 350 SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
349 APPEND(SaveLayer, 351 APPEND(SaveLayer, this->copy(rec.fBounds)
350 this->copy(rec.fBounds), this->copy(rec.fPaint), rec.fBackdrop, rec.f SaveLayerFlags); 352 , this->copy(rec.fPaint)
353 , sk_ref_sp(rec.fBackdrop)
354 , rec.fSaveLayerFlags);
351 return SkCanvas::kNoLayer_SaveLayerStrategy; 355 return SkCanvas::kNoLayer_SaveLayerStrategy;
352 } 356 }
353 357
354 void SkRecorder::didRestore() { 358 void SkRecorder::didRestore() {
355 APPEND(Restore, this->devBounds(), this->getTotalMatrix()); 359 APPEND(Restore, this->devBounds(), this->getTotalMatrix());
356 } 360 }
357 361
358 void SkRecorder::didConcat(const SkMatrix& matrix) { 362 void SkRecorder::didConcat(const SkMatrix& matrix) {
359 APPEND(Concat, matrix); 363 APPEND(Concat, matrix);
360 } 364 }
(...skipping 27 matching lines...) Expand all
388 } 392 }
389 393
390 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 394 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
391 INHERITED(onClipRegion, deviceRgn, op); 395 INHERITED(onClipRegion, deviceRgn, op);
392 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); 396 APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
393 } 397 }
394 398
395 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) { 399 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) {
396 return nullptr; 400 return nullptr;
397 } 401 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698