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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 2337803002: Don't copy image buffer when calculating size.
Patch Set: Making SkImage_Gpu always return false. Created 4 years, 1 month 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/image/SkImage_Gpu.h ('k') | tests/ImageTest.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 2012 Google Inc. 2 * Copyright 2012 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 <cstddef> 8 #include <cstddef>
9 #include <cstring> 9 #include <cstring>
10 #include <type_traits> 10 #include <type_traits>
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 size_t ctSize = 0; 480 size_t ctSize = 0;
481 int ctCount = 0; 481 int ctCount = 0;
482 if (!isScaled && this->peekPixels(&pixmap)) { 482 if (!isScaled && this->peekPixels(&pixmap)) {
483 info = pixmap.info(); 483 info = pixmap.info();
484 pixelSize = SkAlign8(pixmap.getSafeSize()); 484 pixelSize = SkAlign8(pixmap.getSafeSize());
485 if (pixmap.ctable()) { 485 if (pixmap.ctable()) {
486 ctCount = pixmap.ctable()->count(); 486 ctCount = pixmap.ctable()->count();
487 ctSize = SkAlign8(pixmap.ctable()->count() * 4); 487 ctSize = SkAlign8(pixmap.ctable()->count() * 4);
488 } 488 }
489 } else { 489 } else {
490 // Here we're just using presence of data to know whether there is a cod ec behind the image. 490 if (as_IB(this)->canGenerateTexture(proxy)) {
491 // In the future we will access the cacherator and get the exact data th at we want to (e.g.
492 // yuv planes) upload.
493 sk_sp<SkData> data(this->refEncoded());
494 if (!data && !this->peekPixels(nullptr)) {
495 return 0; 491 return 0;
496 } 492 }
497 info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize. height()); 493 info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize. height());
498 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); 494 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr));
499 if (fillMode) { 495 if (fillMode) {
500 pixmap.alloc(info); 496 pixmap.alloc(info);
501 if (isScaled) { 497 if (isScaled) {
502 if (!this->scalePixels(pixmap, scaleFilterQuality, 498 if (!this->scalePixels(pixmap, scaleFilterQuality,
503 SkImage::kDisallow_CachingHint)) { 499 SkImage::kDisallow_CachingHint)) {
504 return 0; 500 return 0;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 702 }
707 sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevel Count)); 703 sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevel Count));
708 if (!texture) { 704 if (!texture) {
709 return nullptr; 705 return nullptr;
710 } 706 }
711 texture->texturePriv().setMipColorMode(colorMode); 707 texture->texturePriv().setMipColorMode(colorMode);
712 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID, 708 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID,
713 info.alphaType(), std::move(texture), 709 info.alphaType(), std::move(texture),
714 sk_ref_sp(info.colorSpace()), budgeted); 710 sk_ref_sp(info.colorSpace()), budgeted);
715 } 711 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698