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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1824983003: SkRecord: infer return type for visit() and mutate(). (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 | « no previous file | src/core/SkBigPicture.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 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 // We have disabled these tests in DM.cpp. 835 // We have disabled these tests in DM.cpp.
836 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType()); 836 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType());
837 837
838 sk_sp<SkImage> image(SkImage::MakeFromGenerator(gen.release(), nullptr)) ; 838 sk_sp<SkImage> image(SkImage::MakeFromGenerator(gen.release(), nullptr)) ;
839 if (!image) { 839 if (!image) {
840 return "Could not create image from codec image generator."; 840 return "Could not create image from codec image generator.";
841 } 841 }
842 canvas->drawImage(image, 0, 0); 842 canvas->drawImage(image, 0, 0);
843 return ""; 843 return "";
844 } 844 }
845 845
846 // Test various color and alpha types on CPU 846 // Test various color and alpha types on CPU
847 SkImageInfo decodeInfo = gen->getInfo().makeAlphaType(fDstAlphaType); 847 SkImageInfo decodeInfo = gen->getInfo().makeAlphaType(fDstAlphaType);
848 848
849 if (kGray_8_SkColorType == decodeInfo.colorType() && 849 if (kGray_8_SkColorType == decodeInfo.colorType() &&
850 kOpaque_SkAlphaType != decodeInfo.alphaType()) { 850 kOpaque_SkAlphaType != decodeInfo.alphaType()) {
851 return Error::Nonfatal("Avoid requesting non-opaque kGray8 decodes."); 851 return Error::Nonfatal("Avoid requesting non-opaque kGray8 decodes.");
852 } 852 }
853 853
854 SkAutoTUnref<SkColorTable> colorTable(nullptr); 854 SkAutoTUnref<SkColorTable> colorTable(nullptr);
855 SkPMColor* colorPtr = nullptr; 855 SkPMColor* colorPtr = nullptr;
856 int* colorCountPtr = nullptr; 856 int* colorCountPtr = nullptr;
857 int maxColors = 256; 857 int maxColors = 256;
858 if (kIndex_8_SkColorType == decodeInfo.colorType()) { 858 if (kIndex_8_SkColorType == decodeInfo.colorType()) {
859 SkPMColor colors[256]; 859 SkPMColor colors[256];
860 colorTable.reset(new SkColorTable(colors, maxColors)); 860 colorTable.reset(new SkColorTable(colors, maxColors));
861 colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); 861 colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
862 colorCountPtr = &maxColors; 862 colorCountPtr = &maxColors;
863 } 863 }
864 864
865 SkBitmap bitmap; 865 SkBitmap bitmap;
866 if (!bitmap.tryAllocPixels(decodeInfo, nullptr, colorTable.get())) { 866 if (!bitmap.tryAllocPixels(decodeInfo, nullptr, colorTable.get())) {
867 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(), 867 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(),
868 decodeInfo.width(), decodeInfo.height()); 868 decodeInfo.width(), decodeInfo.height());
869 } 869 }
870 870
871 if (!gen->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), color Ptr, 871 if (!gen->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), color Ptr,
872 colorCountPtr)) 872 colorCountPtr))
873 { 873 {
874 return SkStringPrintf("Image generator could not getPixels() for %s\n", fPath.c_str()); 874 return SkStringPrintf("Image generator could not getPixels() for %s\n", fPath.c_str());
875 } 875 }
876 876
877 premultiply_if_necessary(bitmap); 877 premultiply_if_necessary(bitmap);
878 canvas->drawBitmap(bitmap, 0, 0); 878 canvas->drawBitmap(bitmap, 0, 0);
879 return ""; 879 return "";
880 } 880 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 SkIntToScalar(size.heigh t())); 1501 SkIntToScalar(size.heigh t()));
1502 1502
1503 SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList()); 1503 SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList());
1504 const SkDrawableList empty; 1504 const SkDrawableList empty;
1505 1505
1506 DrawsAsSingletonPictures drawsAsSingletonPictures = { 1506 DrawsAsSingletonPictures drawsAsSingletonPictures = {
1507 macroCanvas, 1507 macroCanvas,
1508 drawables ? *drawables : empty, 1508 drawables ? *drawables : empty,
1509 }; 1509 };
1510 for (int i = 0; i < skr.count(); i++) { 1510 for (int i = 0; i < skr.count(); i++) {
1511 skr.visit<void>(i, drawsAsSingletonPictures); 1511 skr.visit(i, drawsAsSingletonPictures);
1512 } 1512 }
1513 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1513 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1514 1514
1515 canvas->drawPicture(macroPic); 1515 canvas->drawPicture(macroPic);
1516 return check_against_reference(bitmap, src, fSink); 1516 return check_against_reference(bitmap, src, fSink);
1517 }); 1517 });
1518 } 1518 }
1519 1519
1520 } // namespace DM 1520 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBigPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698