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

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

Issue 1783063002: Revert of add Make variations to return SkImage by sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/SkPictureShader.cpp ('k') | src/core/SkShader.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } // anonymous namespace 291 } // anonymous namespace
292 292
293 SkImage* SkReadBuffer::readImage() { 293 SkImage* SkReadBuffer::readImage() {
294 int width = this->read32(); 294 int width = this->read32();
295 int height = this->read32(); 295 int height = this->read32();
296 if (width <= 0 || height <= 0) { // SkImage never has a zero dimension 296 if (width <= 0 || height <= 0) { // SkImage never has a zero dimension
297 this->validate(false); 297 this->validate(false);
298 return nullptr; 298 return nullptr;
299 } 299 }
300 300
301 sk_sp<SkData> encoded(this->readByteArrayAsData()); 301 SkAutoTUnref<SkData> encoded(this->readByteArrayAsData());
302 if (encoded->size() == 0) { 302 if (encoded->size() == 0) {
303 // The image could not be encoded at serialization time - return an empt y placeholder. 303 // The image could not be encoded at serialization time - return an empt y placeholder.
304 return SkImage::MakeFromGenerator( 304 return SkImage::NewFromGenerator(
305 new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height))). release(); 305 new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height)));
306 } 306 }
307 307
308 int originX = this->read32(); 308 int originX = this->read32();
309 int originY = this->read32(); 309 int originY = this->read32();
310 if (originX < 0 || originY < 0) { 310 if (originX < 0 || originY < 0) {
311 this->validate(false); 311 this->validate(false);
312 return nullptr; 312 return nullptr;
313 } 313 }
314 314
315 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); 315 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height);
316 SkImage* image = SkImage::MakeFromEncoded(std::move(encoded), &subset).relea se(); 316 SkImage* image = SkImage::NewFromEncoded(encoded, &subset);
317 if (image) { 317 if (image) {
318 return image; 318 return image;
319 } 319 }
320 320
321 return SkImage::MakeFromGenerator( 321 return SkImage::NewFromGenerator(
322 new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height))). release(); 322 new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height)));
323 } 323 }
324 324
325 SkTypeface* SkReadBuffer::readTypeface() { 325 SkTypeface* SkReadBuffer::readTypeface() {
326 326
327 uint32_t index = fReader.readU32(); 327 uint32_t index = fReader.readU32();
328 if (0 == index || index > (unsigned)fTFCount) { 328 if (0 == index || index > (unsigned)fTFCount) {
329 return nullptr; 329 return nullptr;
330 } else { 330 } else {
331 SkASSERT(fTFArray); 331 SkASSERT(fTFArray);
332 return fTFArray[index - 1]; 332 return fTFArray[index - 1];
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return; 403 return;
404 } 404 }
405 } else { 405 } else {
406 if (nullptr == this->readFunctionPtr()) { 406 if (nullptr == this->readFunctionPtr()) {
407 return; 407 return;
408 } 408 }
409 } 409 }
410 uint32_t sizeRecorded = fReader.readU32(); 410 uint32_t sizeRecorded = fReader.readU32();
411 fReader.skip(sizeRecorded); 411 fReader.skip(sizeRecorded);
412 } 412 }
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/core/SkShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698