OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkOpts.h" | 8 #include "SkOpts.h" |
9 #include "SkSmallAllocator.h" | 9 #include "SkSmallAllocator.h" |
10 #include "SkSpriteBlitter.h" | 10 #include "SkSpriteBlitter.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 if (dst.info().gammaCloseToSRGB() != src.info().gammaCloseToSRGB()) { | 62 if (dst.info().gammaCloseToSRGB() != src.info().gammaCloseToSRGB()) { |
63 return false; | 63 return false; |
64 } | 64 } |
65 if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFil
ter()) { | 65 if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFil
ter()) { |
66 return false; | 66 return false; |
67 } | 67 } |
68 if (0xFF != paint.getAlpha()) { | 68 if (0xFF != paint.getAlpha()) { |
69 return false; | 69 return false; |
70 } | 70 } |
71 SkXfermode::Mode mode; | 71 SkBlendMode mode = paint.getBlendMode(); |
72 if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) { | 72 if (SkBlendMode::kSrc == mode) { |
73 return false; | |
74 } | |
75 if (SkXfermode::kSrc_Mode == mode) { | |
76 return true; | 73 return true; |
77 } | 74 } |
78 if (SkXfermode::kSrcOver_Mode == mode && src.isOpaque()) { | 75 if (SkBlendMode::kSrcOver == mode && src.isOpaque()) { |
79 return true; | 76 return true; |
80 } | 77 } |
81 | 78 |
82 // At this point memcpy can't be used. The following check for using Src
Over. | 79 // At this point memcpy can't be used. The following check for using Src
Over. |
83 | 80 |
84 if (dst.colorType() != kN32_SkColorType || !dst.info().gammaCloseToSRGB(
)) { | 81 if (dst.colorType() != kN32_SkColorType || !dst.info().gammaCloseToSRGB(
)) { |
85 return false; | 82 return false; |
86 } | 83 } |
87 | 84 |
88 return SkXfermode::kSrcOver_Mode == mode; | 85 return SkBlendMode::kSrcOver == mode; |
89 } | 86 } |
90 | 87 |
91 SkSpriteBlitter_Src_SrcOver(const SkPixmap& src) | 88 SkSpriteBlitter_Src_SrcOver(const SkPixmap& src) |
92 : INHERITED(src) {} | 89 : INHERITED(src) {} |
93 | 90 |
94 void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) ove
rride { | 91 void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) ove
rride { |
95 SkASSERT(Supports(dst, fSource, paint)); | 92 SkASSERT(Supports(dst, fSource, paint)); |
96 this->INHERITED::setup(dst, left, top, paint); | 93 this->INHERITED::setup(dst, left, top, paint); |
97 SkXfermode::Mode mode; | 94 SkBlendMode mode = paint.getBlendMode(); |
98 if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) { | |
99 SkFAIL("Should never happen."); | |
100 } | |
101 | 95 |
102 SkASSERT(mode == SkXfermode::kSrcOver_Mode || mode == SkXfermode::kSrc_M
ode); | 96 SkASSERT(mode == SkBlendMode::kSrcOver || mode == SkBlendMode::kSrc); |
103 | 97 |
104 if (mode == SkXfermode::kSrcOver_Mode && !fSource.isOpaque()) { | 98 if (mode == SkBlendMode::kSrcOver && !fSource.isOpaque()) { |
105 fUseMemcpy = false; | 99 fUseMemcpy = false; |
106 } | 100 } |
107 } | 101 } |
108 | 102 |
109 void blitRect(int x, int y, int width, int height) override { | 103 void blitRect(int x, int y, int width, int height) override { |
110 SkASSERT(fDst.colorType() == fSource.colorType()); | 104 SkASSERT(fDst.colorType() == fSource.colorType()); |
111 SkASSERT(fDst.info().gammaCloseToSRGB() == fSource.info().gammaCloseToSR
GB()); | 105 SkASSERT(fDst.info().gammaCloseToSRGB() == fSource.info().gammaCloseToSR
GB()); |
112 SkASSERT(width > 0 && height > 0); | 106 SkASSERT(width > 0 && height > 0); |
113 | 107 |
114 if (fUseMemcpy) { | 108 if (fUseMemcpy) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 default: | 180 default: |
187 break; | 181 break; |
188 } | 182 } |
189 } | 183 } |
190 | 184 |
191 if (blitter) { | 185 if (blitter) { |
192 blitter->setup(dst, left, top, paint); | 186 blitter->setup(dst, left, top, paint); |
193 } | 187 } |
194 return blitter; | 188 return blitter; |
195 } | 189 } |
OLD | NEW |