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

Side by Side Diff: src/device/xps/SkXPSDevice.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 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/SkXfermode.cpp ('k') | src/effects/SkArithmeticMode.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 7
8 #ifndef UNICODE 8 #ifndef UNICODE
9 #define UNICODE 9 #define UNICODE
10 #endif 10 #endif
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 HRM(clampBrush->SetTileMode(SkToXpsTileMode[xy[0]][xy[1]]), 802 HRM(clampBrush->SetTileMode(SkToXpsTileMode[xy[0]][xy[1]]),
803 "Could not set tile mode on visual brush for image brush."); 803 "Could not set tile mode on visual brush for image brush.");
804 HRM(clampBrush->SetOpacity(alpha / 255.0f), 804 HRM(clampBrush->SetOpacity(alpha / 255.0f),
805 "Could not set opacity on visual brush for image brush."); 805 "Could not set opacity on visual brush for image brush.");
806 806
807 HRM(clampBrush->QueryInterface(xpsBrush), "QI failed."); 807 HRM(clampBrush->QueryInterface(xpsBrush), "QI failed.");
808 } 808 }
809 809
810 SkTScopedComPtr<IXpsOMMatrixTransform> xpsMatrixToUse; 810 SkTScopedComPtr<IXpsOMMatrixTransform> xpsMatrixToUse;
811 HR(this->createXpsTransform(localMatrix, &xpsMatrixToUse)); 811 HR(this->createXpsTransform(localMatrix, &xpsMatrixToUse));
812 if (NULL != xpsMatrixToUse.get()) { 812 if (xpsMatrixToUse.get()) {
813 HRM((*xpsBrush)->SetTransformLocal(xpsMatrixToUse.get()), 813 HRM((*xpsBrush)->SetTransformLocal(xpsMatrixToUse.get()),
814 "Could not set transform for image brush."); 814 "Could not set transform for image brush.");
815 } else { 815 } else {
816 //TODO(bungeman): perspective bitmaps in general. 816 //TODO(bungeman): perspective bitmaps in general.
817 } 817 }
818 818
819 return S_OK; 819 return S_OK;
820 } 820 }
821 821
822 HRESULT SkXPSDevice::createXpsGradientStop(const SkColor skColor, 822 HRESULT SkXPSDevice::createXpsGradientStop(const SkColor skColor,
823 const SkScalar offset, 823 const SkScalar offset,
824 IXpsOMGradientStop** xpsGradStop) { 824 IXpsOMGradientStop** xpsGradStop) {
825 XPS_COLOR gradStopXpsColor = xps_color(skColor); 825 XPS_COLOR gradStopXpsColor = xps_color(skColor);
826 HRM(this->fXpsFactory->CreateGradientStop(&gradStopXpsColor, 826 HRM(this->fXpsFactory->CreateGradientStop(&gradStopXpsColor,
827 NULL, 827 NULL,
828 SkScalarToFLOAT(offset), 828 SkScalarToFLOAT(offset),
829 xpsGradStop), 829 xpsGradStop),
830 "Could not create gradient stop."); 830 "Could not create gradient stop.");
831 return S_OK; 831 return S_OK;
832 } 832 }
833 833
834 HRESULT SkXPSDevice::createXpsLinearGradient(SkShader::GradientInfo info, 834 HRESULT SkXPSDevice::createXpsLinearGradient(SkShader::GradientInfo info,
835 const SkAlpha alpha, 835 const SkAlpha alpha,
836 const SkMatrix& localMatrix, 836 const SkMatrix& localMatrix,
837 IXpsOMMatrixTransform* xpsMatrix, 837 IXpsOMMatrixTransform* xpsMatrix,
838 IXpsOMBrush** xpsBrush) { 838 IXpsOMBrush** xpsBrush) {
839 XPS_POINT startPoint; 839 XPS_POINT startPoint;
840 XPS_POINT endPoint; 840 XPS_POINT endPoint;
841 if (NULL != xpsMatrix) { 841 if (xpsMatrix) {
842 startPoint = xps_point(info.fPoint[0]); 842 startPoint = xps_point(info.fPoint[0]);
843 endPoint = xps_point(info.fPoint[1]); 843 endPoint = xps_point(info.fPoint[1]);
844 } else { 844 } else {
845 transform_offsets(info.fColorOffsets, info.fColorCount, 845 transform_offsets(info.fColorOffsets, info.fColorCount,
846 info.fPoint[0], info.fPoint[1], 846 info.fPoint[0], info.fPoint[1],
847 localMatrix); 847 localMatrix);
848 startPoint = xps_point(info.fPoint[0], localMatrix); 848 startPoint = xps_point(info.fPoint[0], localMatrix);
849 endPoint = xps_point(info.fPoint[1], localMatrix); 849 endPoint = xps_point(info.fPoint[1], localMatrix);
850 } 850 }
851 851
852 SkTScopedComPtr<IXpsOMGradientStop> gradStop0; 852 SkTScopedComPtr<IXpsOMGradientStop> gradStop0;
853 HR(createXpsGradientStop(info.fColors[0], 853 HR(createXpsGradientStop(info.fColors[0],
854 info.fColorOffsets[0], 854 info.fColorOffsets[0],
855 &gradStop0)); 855 &gradStop0));
856 856
857 SkTScopedComPtr<IXpsOMGradientStop> gradStop1; 857 SkTScopedComPtr<IXpsOMGradientStop> gradStop1;
858 HR(createXpsGradientStop(info.fColors[1], 858 HR(createXpsGradientStop(info.fColors[1],
859 info.fColorOffsets[1], 859 info.fColorOffsets[1],
860 &gradStop1)); 860 &gradStop1));
861 861
862 SkTScopedComPtr<IXpsOMLinearGradientBrush> gradientBrush; 862 SkTScopedComPtr<IXpsOMLinearGradientBrush> gradientBrush;
863 HRM(this->fXpsFactory->CreateLinearGradientBrush(gradStop0.get(), 863 HRM(this->fXpsFactory->CreateLinearGradientBrush(gradStop0.get(),
864 gradStop1.get(), 864 gradStop1.get(),
865 &startPoint, 865 &startPoint,
866 &endPoint, 866 &endPoint,
867 &gradientBrush), 867 &gradientBrush),
868 "Could not create linear gradient brush."); 868 "Could not create linear gradient brush.");
869 if (NULL != xpsMatrix) { 869 if (xpsMatrix) {
870 HRM(gradientBrush->SetTransformLocal(xpsMatrix), 870 HRM(gradientBrush->SetTransformLocal(xpsMatrix),
871 "Could not set transform on linear gradient brush."); 871 "Could not set transform on linear gradient brush.");
872 } 872 }
873 873
874 SkTScopedComPtr<IXpsOMGradientStopCollection> gradStopCollection; 874 SkTScopedComPtr<IXpsOMGradientStopCollection> gradStopCollection;
875 HRM(gradientBrush->GetGradientStops(&gradStopCollection), 875 HRM(gradientBrush->GetGradientStops(&gradStopCollection),
876 "Could not get linear gradient stop collection."); 876 "Could not get linear gradient stop collection.");
877 for (int i = 2; i < info.fColorCount; ++i) { 877 for (int i = 2; i < info.fColorCount; ++i) {
878 SkTScopedComPtr<IXpsOMGradientStop> gradStop; 878 SkTScopedComPtr<IXpsOMGradientStop> gradStop;
879 HR(createXpsGradientStop(info.fColors[i], 879 HR(createXpsGradientStop(info.fColors[i],
(...skipping 25 matching lines...) Expand all
905 905
906 SkTScopedComPtr<IXpsOMGradientStop> gradStop1; 906 SkTScopedComPtr<IXpsOMGradientStop> gradStop1;
907 HR(createXpsGradientStop(info.fColors[1], 907 HR(createXpsGradientStop(info.fColors[1],
908 info.fColorOffsets[1], 908 info.fColorOffsets[1],
909 &gradStop1)); 909 &gradStop1));
910 910
911 //TODO: figure out how to fake better if not affine 911 //TODO: figure out how to fake better if not affine
912 XPS_POINT centerPoint; 912 XPS_POINT centerPoint;
913 XPS_POINT gradientOrigin; 913 XPS_POINT gradientOrigin;
914 XPS_SIZE radiiSizes; 914 XPS_SIZE radiiSizes;
915 if (NULL != xpsMatrix) { 915 if (xpsMatrix) {
916 centerPoint = xps_point(info.fPoint[0]); 916 centerPoint = xps_point(info.fPoint[0]);
917 gradientOrigin = xps_point(info.fPoint[0]); 917 gradientOrigin = xps_point(info.fPoint[0]);
918 radiiSizes.width = SkScalarToFLOAT(info.fRadius[0]); 918 radiiSizes.width = SkScalarToFLOAT(info.fRadius[0]);
919 radiiSizes.height = SkScalarToFLOAT(info.fRadius[0]); 919 radiiSizes.height = SkScalarToFLOAT(info.fRadius[0]);
920 } else { 920 } else {
921 centerPoint = xps_point(info.fPoint[0], localMatrix); 921 centerPoint = xps_point(info.fPoint[0], localMatrix);
922 gradientOrigin = xps_point(info.fPoint[0], localMatrix); 922 gradientOrigin = xps_point(info.fPoint[0], localMatrix);
923 923
924 SkScalar radius = info.fRadius[0]; 924 SkScalar radius = info.fRadius[0];
925 SkVector vec[2]; 925 SkVector vec[2];
(...skipping 10 matching lines...) Expand all
936 } 936 }
937 937
938 SkTScopedComPtr<IXpsOMRadialGradientBrush> gradientBrush; 938 SkTScopedComPtr<IXpsOMRadialGradientBrush> gradientBrush;
939 HRM(this->fXpsFactory->CreateRadialGradientBrush(gradStop0.get(), 939 HRM(this->fXpsFactory->CreateRadialGradientBrush(gradStop0.get(),
940 gradStop1.get(), 940 gradStop1.get(),
941 &centerPoint, 941 &centerPoint,
942 &gradientOrigin, 942 &gradientOrigin,
943 &radiiSizes, 943 &radiiSizes,
944 &gradientBrush), 944 &gradientBrush),
945 "Could not create radial gradient brush."); 945 "Could not create radial gradient brush.");
946 if (NULL != xpsMatrix) { 946 if (xpsMatrix) {
947 HRM(gradientBrush->SetTransformLocal(xpsMatrix), 947 HRM(gradientBrush->SetTransformLocal(xpsMatrix),
948 "Could not set transform on radial gradient brush."); 948 "Could not set transform on radial gradient brush.");
949 } 949 }
950 950
951 SkTScopedComPtr<IXpsOMGradientStopCollection> gradStopCollection; 951 SkTScopedComPtr<IXpsOMGradientStopCollection> gradStopCollection;
952 HRM(gradientBrush->GetGradientStops(&gradStopCollection), 952 HRM(gradientBrush->GetGradientStops(&gradStopCollection),
953 "Could not get radial gradient stop collection."); 953 "Could not get radial gradient stop collection.");
954 for (int i = 2; i < info.fColorCount; ++i) { 954 for (int i = 2; i < info.fColorCount; ++i) {
955 SkTScopedComPtr<IXpsOMGradientStop> gradStop; 955 SkTScopedComPtr<IXpsOMGradientStop> gradStop;
956 HR(createXpsGradientStop(info.fColors[i], 956 HR(createXpsGradientStop(info.fColors[i],
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 shader->asAGradient(&info); 1012 shader->asAGradient(&info);
1013 1013
1014 if (1 == info.fColorCount) { 1014 if (1 == info.fColorCount) {
1015 SkColor color = info.fColors[0]; 1015 SkColor color = info.fColors[0];
1016 SkAlpha alpha = skPaint.getAlpha(); 1016 SkAlpha alpha = skPaint.getAlpha();
1017 HR(this->createXpsSolidColorBrush(color, alpha, brush)); 1017 HR(this->createXpsSolidColorBrush(color, alpha, brush));
1018 return S_OK; 1018 return S_OK;
1019 } 1019 }
1020 1020
1021 SkMatrix localMatrix = shader->getLocalMatrix(); 1021 SkMatrix localMatrix = shader->getLocalMatrix();
1022 if (NULL != parentTransform) { 1022 if (parentTransform) {
1023 localMatrix.preConcat(*parentTransform); 1023 localMatrix.preConcat(*parentTransform);
1024 } 1024 }
1025 SkTScopedComPtr<IXpsOMMatrixTransform> xpsMatrixToUse; 1025 SkTScopedComPtr<IXpsOMMatrixTransform> xpsMatrixToUse;
1026 HR(this->createXpsTransform(localMatrix, &xpsMatrixToUse)); 1026 HR(this->createXpsTransform(localMatrix, &xpsMatrixToUse));
1027 1027
1028 if (SkShader::kLinear_GradientType == gradientType) { 1028 if (SkShader::kLinear_GradientType == gradientType) {
1029 HR(this->createXpsLinearGradient(info, 1029 HR(this->createXpsLinearGradient(info,
1030 skPaint.getAlpha(), 1030 skPaint.getAlpha(),
1031 localMatrix, 1031 localMatrix,
1032 xpsMatrixToUse.get(), 1032 xpsMatrixToUse.get(),
(...skipping 25 matching lines...) Expand all
1058 SkShader::TileMode xy[2]; 1058 SkShader::TileMode xy[2];
1059 SkShader::BitmapType bitmapType = shader->asABitmap(&outTexture, 1059 SkShader::BitmapType bitmapType = shader->asABitmap(&outTexture,
1060 &outMatrix, 1060 &outMatrix,
1061 xy); 1061 xy);
1062 switch (bitmapType) { 1062 switch (bitmapType) {
1063 case SkShader::kNone_BitmapType: 1063 case SkShader::kNone_BitmapType:
1064 break; 1064 break;
1065 case SkShader::kDefault_BitmapType: { 1065 case SkShader::kDefault_BitmapType: {
1066 //TODO: outMatrix?? 1066 //TODO: outMatrix??
1067 SkMatrix localMatrix = shader->getLocalMatrix(); 1067 SkMatrix localMatrix = shader->getLocalMatrix();
1068 if (NULL != parentTransform) { 1068 if (parentTransform) {
1069 localMatrix.preConcat(*parentTransform); 1069 localMatrix.preConcat(*parentTransform);
1070 } 1070 }
1071 1071
1072 SkTScopedComPtr<IXpsOMTileBrush> tileBrush; 1072 SkTScopedComPtr<IXpsOMTileBrush> tileBrush;
1073 HR(this->createXpsImageBrush(outTexture, 1073 HR(this->createXpsImageBrush(outTexture,
1074 localMatrix, 1074 localMatrix,
1075 xy, 1075 xy,
1076 skPaint.getAlpha(), 1076 skPaint.getAlpha(),
1077 &tileBrush)); 1077 &tileBrush));
1078 1078
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 SkTDArray<BOOL> segmentStrokes; 1320 SkTDArray<BOOL> segmentStrokes;
1321 SkTDArray<FLOAT> segmentData; 1321 SkTDArray<FLOAT> segmentData;
1322 1322
1323 SkTScopedComPtr<IXpsOMGeometryFigure> xpsFigure; 1323 SkTScopedComPtr<IXpsOMGeometryFigure> xpsFigure;
1324 SkPath::Iter iter(path, true); 1324 SkPath::Iter iter(path, true);
1325 SkPoint points[4]; 1325 SkPoint points[4];
1326 SkPath::Verb verb; 1326 SkPath::Verb verb;
1327 while ((verb = iter.next(points)) != SkPath::kDone_Verb) { 1327 while ((verb = iter.next(points)) != SkPath::kDone_Verb) {
1328 switch (verb) { 1328 switch (verb) {
1329 case SkPath::kMove_Verb: { 1329 case SkPath::kMove_Verb: {
1330 if (NULL != xpsFigure.get()) { 1330 if (xpsFigure.get()) {
1331 HR(close_figure(segmentTypes, segmentStrokes, segmentData, 1331 HR(close_figure(segmentTypes, segmentStrokes, segmentData,
1332 stroke, fill, 1332 stroke, fill,
1333 xpsFigure.get() , xpsFigures)); 1333 xpsFigure.get() , xpsFigures));
1334 xpsFigure.reset(); 1334 xpsFigure.reset();
1335 segmentTypes.rewind(); 1335 segmentTypes.rewind();
1336 segmentStrokes.rewind(); 1336 segmentStrokes.rewind();
1337 segmentData.rewind(); 1337 segmentData.rewind();
1338 } 1338 }
1339 // Define the start point. 1339 // Define the start point.
1340 XPS_POINT startPoint = xps_point(points[0]); 1340 XPS_POINT startPoint = xps_point(points[0]);
(...skipping 30 matching lines...) Expand all
1371 break; 1371 break;
1372 case SkPath::kClose_Verb: 1372 case SkPath::kClose_Verb:
1373 // we ignore these, and just get the whole segment from 1373 // we ignore these, and just get the whole segment from
1374 // the corresponding line/quad/cubic verbs 1374 // the corresponding line/quad/cubic verbs
1375 break; 1375 break;
1376 default: 1376 default:
1377 SkDEBUGFAIL("unexpected verb"); 1377 SkDEBUGFAIL("unexpected verb");
1378 break; 1378 break;
1379 } 1379 }
1380 } 1380 }
1381 if (NULL != xpsFigure.get()) { 1381 if (xpsFigure.get()) {
1382 HR(close_figure(segmentTypes, segmentStrokes, segmentData, 1382 HR(close_figure(segmentTypes, segmentStrokes, segmentData,
1383 stroke, fill, 1383 stroke, fill,
1384 xpsFigure.get(), xpsFigures)); 1384 xpsFigure.get(), xpsFigures));
1385 } 1385 }
1386 return S_OK; 1386 return S_OK;
1387 } 1387 }
1388 1388
1389 void SkXPSDevice::convertToPpm(const SkMaskFilter* filter, 1389 void SkXPSDevice::convertToPpm(const SkMaskFilter* filter,
1390 SkMatrix* matrix, 1390 SkMatrix* matrix,
1391 SkVector* ppuScale, 1391 SkVector* ppuScale,
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform; 1827 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
1828 HRV(this->createXpsTransform(transform, &xpsTransform)); 1828 HRV(this->createXpsTransform(transform, &xpsTransform));
1829 if (xpsTransform.get()) { 1829 if (xpsTransform.get()) {
1830 HRVM(shadedGeometry->SetTransformLocal(xpsTransform.get()), 1830 HRVM(shadedGeometry->SetTransformLocal(xpsTransform.get()),
1831 "Could not set transform for bitmap."); 1831 "Could not set transform for bitmap.");
1832 } else { 1832 } else {
1833 //TODO: perspective that bitmap! 1833 //TODO: perspective that bitmap!
1834 } 1834 }
1835 1835
1836 SkTScopedComPtr<IXpsOMGeometryFigure> rectFigure; 1836 SkTScopedComPtr<IXpsOMGeometryFigure> rectFigure;
1837 if (NULL != xpsTransform.get()) { 1837 if (xpsTransform.get()) {
1838 const SkShader::TileMode xy[2] = { 1838 const SkShader::TileMode xy[2] = {
1839 SkShader::kClamp_TileMode, 1839 SkShader::kClamp_TileMode,
1840 SkShader::kClamp_TileMode, 1840 SkShader::kClamp_TileMode,
1841 }; 1841 };
1842 SkTScopedComPtr<IXpsOMTileBrush> xpsImageBrush; 1842 SkTScopedComPtr<IXpsOMTileBrush> xpsImageBrush;
1843 HRV(this->createXpsImageBrush(bitmap, 1843 HRV(this->createXpsImageBrush(bitmap,
1844 transform, 1844 transform,
1845 xy, 1845 xy,
1846 paint.getAlpha(), 1846 paint.getAlpha(),
1847 &xpsImageBrush)); 1847 &xpsImageBrush));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 useCanvasForClip = true; 1972 useCanvasForClip = true;
1973 } else { 1973 } else {
1974 SkDEBUGFAIL("Attempt to add glyphs in perspective."); 1974 SkDEBUGFAIL("Attempt to add glyphs in perspective.");
1975 useCanvasForClip = false; 1975 useCanvasForClip = false;
1976 } 1976 }
1977 } 1977 }
1978 1978
1979 SkTScopedComPtr<IXpsOMGlyphsEditor> glyphsEditor; 1979 SkTScopedComPtr<IXpsOMGlyphsEditor> glyphsEditor;
1980 HRM(glyphs->GetGlyphsEditor(&glyphsEditor), "Could not get glyph editor."); 1980 HRM(glyphs->GetGlyphsEditor(&glyphsEditor), "Could not get glyph editor.");
1981 1981
1982 if (NULL != text) { 1982 if (text) {
1983 HRM(glyphsEditor->SetUnicodeString(text), 1983 HRM(glyphsEditor->SetUnicodeString(text),
1984 "Could not set unicode string."); 1984 "Could not set unicode string.");
1985 } 1985 }
1986 1986
1987 if (NULL != xpsGlyphs) { 1987 if (xpsGlyphs) {
1988 HRM(glyphsEditor->SetGlyphIndices(xpsGlyphsLen, xpsGlyphs), 1988 HRM(glyphsEditor->SetGlyphIndices(xpsGlyphsLen, xpsGlyphs),
1989 "Could not set glyphs."); 1989 "Could not set glyphs.");
1990 } 1990 }
1991 1991
1992 HRM(glyphsEditor->ApplyEdits(), "Could not apply glyph edits."); 1992 HRM(glyphsEditor->ApplyEdits(), "Could not apply glyph edits.");
1993 1993
1994 SkTScopedComPtr<IXpsOMBrush> xpsFillBrush; 1994 SkTScopedComPtr<IXpsOMBrush> xpsFillBrush;
1995 HR(this->createXpsBrush( 1995 HR(this->createXpsBrush(
1996 paint, 1996 paint,
1997 &xpsFillBrush, 1997 &xpsFillBrush,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 IID_PPV_ARGS(&this->fXpsFactory)), 2277 IID_PPV_ARGS(&this->fXpsFactory)),
2278 "Could not create factory for layer."); 2278 "Could not create factory for layer.");
2279 2279
2280 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), 2280 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
2281 "Could not create canvas for layer."); 2281 "Could not create canvas for layer.");
2282 } 2282 }
2283 2283
2284 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) { 2284 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) {
2285 return false; 2285 return false;
2286 } 2286 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkArithmeticMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698