| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkLinearBitmapPipeline.h" | 8 #include "SkLinearBitmapPipeline.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlend
erStage); | 884 auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlend
erStage); |
| 885 auto samplerStage = choose_pixel_sampler( | 885 auto samplerStage = choose_pixel_sampler( |
| 886 blenderStage, filterQuality, srcPixmap, paintColor, &fSampleStage); | 886 blenderStage, filterQuality, srcPixmap, paintColor, &fSampleStage); |
| 887 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, | 887 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, |
| 888 filterQuality, dx, &fTileStage); | 888 filterQuality, dx, &fTileStage); |
| 889 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage
); | 889 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage
); |
| 890 fLastStage = blenderStage; | 890 fLastStage = blenderStage; |
| 891 } | 891 } |
| 892 | 892 |
| 893 bool SkLinearBitmapPipeline::ClonePipelineForBlitting( | 893 bool SkLinearBitmapPipeline::ClonePipelineForBlitting( |
| 894 void* blitterStorage, | 894 SkEmbeddableLinearPipeline* pipelineStorage, |
| 895 const SkLinearBitmapPipeline& pipeline, | 895 const SkLinearBitmapPipeline& pipeline, |
| 896 SkMatrix::TypeMask matrixMask, | 896 SkMatrix::TypeMask matrixMask, |
| 897 SkShader::TileMode xTileMode, | 897 SkShader::TileMode xTileMode, |
| 898 SkShader::TileMode yTileMode, | 898 SkShader::TileMode yTileMode, |
| 899 SkFilterQuality filterQuality, | 899 SkFilterQuality filterQuality, |
| 900 const SkPixmap& srcPixmap, | 900 const SkPixmap& srcPixmap, |
| 901 float finalAlpha, | 901 float finalAlpha, |
| 902 SkXfermode::Mode xferMode, | 902 SkXfermode::Mode xferMode, |
| 903 const SkImageInfo& dstInfo) | 903 const SkImageInfo& dstInfo) |
| 904 { | 904 { |
| 905 if (xferMode == SkXfermode::kSrcOver_Mode | 905 if (xferMode == SkXfermode::kSrcOver_Mode |
| 906 && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) { | 906 && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) { |
| 907 xferMode = SkXfermode::kSrc_Mode; | 907 xferMode = SkXfermode::kSrc_Mode; |
| 908 } | 908 } |
| 909 | 909 |
| 910 if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; } | 910 if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; } |
| 911 if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return false;
} | 911 if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return false;
} |
| 912 if (finalAlpha != 1.0f) { return false; } | 912 if (finalAlpha != 1.0f) { return false; } |
| 913 if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType | 913 if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType |
| 914 || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; } | 914 || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; } |
| 915 | 915 |
| 916 if (srcPixmap.info().profileType() != kSRGB_SkColorProfileType | 916 if (srcPixmap.info().profileType() != kSRGB_SkColorProfileType |
| 917 || dstInfo.profileType() != kSRGB_SkColorProfileType) { return false; } | 917 || dstInfo.profileType() != kSRGB_SkColorProfileType) { return false; } |
| 918 | 918 |
| 919 if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mo
de) { | 919 if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mo
de) { |
| 920 return false; | 920 return false; |
| 921 } | 921 } |
| 922 | 922 |
| 923 new (blitterStorage) SkLinearBitmapPipeline(pipeline, srcPixmap, xferMode, d
stInfo); | 923 pipelineStorage->init(pipeline, srcPixmap, xferMode, dstInfo); |
| 924 | 924 |
| 925 return true; | 925 return true; |
| 926 } | 926 } |
| 927 | 927 |
| 928 SkLinearBitmapPipeline::SkLinearBitmapPipeline( | 928 SkLinearBitmapPipeline::SkLinearBitmapPipeline( |
| 929 const SkLinearBitmapPipeline& pipeline, | 929 const SkLinearBitmapPipeline& pipeline, |
| 930 const SkPixmap& srcPixmap, | 930 const SkPixmap& srcPixmap, |
| 931 SkXfermode::Mode mode, | 931 SkXfermode::Mode mode, |
| 932 const SkImageInfo& dstInfo) | 932 const SkImageInfo& dstInfo) |
| 933 { | 933 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 961 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { | 961 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { |
| 962 SkASSERT(count > 0); | 962 SkASSERT(count > 0); |
| 963 fLastStage->setDestination(dst, count); | 963 fLastStage->setDestination(dst, count); |
| 964 | 964 |
| 965 // The count and length arguments start out in a precise relation in order t
o keep the | 965 // The count and length arguments start out in a precise relation in order t
o keep the |
| 966 // math correct through the different stages. Count is the number of pixel t
o produce. | 966 // math correct through the different stages. Count is the number of pixel t
o produce. |
| 967 // Since the code samples at pixel centers, length is the distance from the
center of the | 967 // Since the code samples at pixel centers, length is the distance from the
center of the |
| 968 // first pixel to the center of the last pixel. This implies that length is
count-1. | 968 // first pixel to the center of the last pixel. This implies that length is
count-1. |
| 969 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); | 969 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); |
| 970 } | 970 } |
| OLD | NEW |