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

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

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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/SkPicture.cpp ('k') | src/core/SkPictureRecorder.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 2011 Google Inc. 2 * Copyright 2011 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 #include <new> 7 #include <new>
8 #include "SkImageGenerator.h" 8 #include "SkImageGenerator.h"
9 #include "SkPictureData.h" 9 #include "SkPictureData.h"
10 #include "SkPictureRecord.h" 10 #include "SkPictureRecord.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // the default here. 385 // the default here.
386 tf.reset(SkTypeface::RefDefault()); 386 tf.reset(SkTypeface::RefDefault());
387 } 387 }
388 fTFPlayback.set(i, tf); 388 fTFPlayback.set(i, tf);
389 } 389 }
390 } break; 390 } break;
391 case SK_PICT_PICTURE_TAG: { 391 case SK_PICT_PICTURE_TAG: {
392 fPictureCount = 0; 392 fPictureCount = 0;
393 fPictureRefs = new const SkPicture* [size]; 393 fPictureRefs = new const SkPicture* [size];
394 for (uint32_t i = 0; i < size; i++) { 394 for (uint32_t i = 0; i < size; i++) {
395 fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc, topL evelTFPlayback); 395 fPictureRefs[i] = SkPicture::MakeFromStream(stream, proc, topLev elTFPlayback).release();
396 if (!fPictureRefs[i]) { 396 if (!fPictureRefs[i]) {
397 return false; 397 return false;
398 } 398 }
399 fPictureCount++; 399 fPictureCount++;
400 } 400 }
401 } break; 401 } break;
402 case SK_PICT_BUFFER_SIZE_TAG: { 402 case SK_PICT_BUFFER_SIZE_TAG: {
403 SkAutoMalloc storage(size); 403 SkAutoMalloc storage(size);
404 if (stream->read(storage.get(), size) != size) { 404 if (stream->read(storage.get(), size) != size) {
405 return false; 405 return false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 return true; // success 440 return true; // success
441 } 441 }
442 442
443 static const SkImage* create_image_from_buffer(SkReadBuffer& buffer) { 443 static const SkImage* create_image_from_buffer(SkReadBuffer& buffer) {
444 return buffer.readImage(); 444 return buffer.readImage();
445 } 445 }
446 446
447 // Need a shallow wrapper to return const SkPicture* to match the other factorie s, 447 // Need a shallow wrapper to return const SkPicture* to match the other factorie s,
448 // as SkPicture::CreateFromBuffer() returns SkPicture* 448 // as SkPicture::CreateFromBuffer() returns SkPicture*
449 static const SkPicture* create_picture_from_buffer(SkReadBuffer& buffer) { 449 static const SkPicture* create_picture_from_buffer(SkReadBuffer& buffer) {
450 return SkPicture::CreateFromBuffer(buffer); 450 return SkPicture::MakeFromBuffer(buffer).release();
451 } 451 }
452 452
453 template <typename T> 453 template <typename T>
454 bool new_array_from_buffer(SkReadBuffer& buffer, uint32_t inCount, 454 bool new_array_from_buffer(SkReadBuffer& buffer, uint32_t inCount,
455 const T*** array, int* outCount, const T* (*factory)( SkReadBuffer&)) { 455 const T*** array, int* outCount, const T* (*factory)( SkReadBuffer&)) {
456 if (!buffer.validate((0 == *outCount) && (nullptr == *array))) { 456 if (!buffer.validate((0 == *outCount) && (nullptr == *array))) {
457 return false; 457 return false;
458 } 458 }
459 if (0 == inCount) { 459 if (0 == inCount) {
460 return true; 460 return true;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 } 626 }
627 627
628 bool SkPictureData::suitableForLayerOptimization() const { 628 bool SkPictureData::suitableForLayerOptimization() const {
629 return fContentInfo.numLayers() > 0; 629 return fContentInfo.numLayers() > 0;
630 } 630 }
631 #endif 631 #endif
632 /////////////////////////////////////////////////////////////////////////////// 632 ///////////////////////////////////////////////////////////////////////////////
633 633
634 634
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698