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

Side by Side Diff: core/fxge/skia/fx_skia_device.cpp

Issue 2394683004: switch to new skia blend mode enum class (Closed)
Patch Set: update to skia with corrected blend mode implementation Created 4 years, 2 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 | « DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if defined(_SKIA_SUPPORT_) 5 #if defined(_SKIA_SUPPORT_)
6 #include <algorithm> 6 #include <algorithm>
7 #include <vector> 7 #include <vector>
8 8
9 #include "core/fxcodec/fx_codec.h" 9 #include "core/fxcodec/fx_codec.h"
10 #include "core/fxcrt/fx_memory.h" 10 #include "core/fxcrt/fx_memory.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 // use when pdf's y-axis points up insead of down 144 // use when pdf's y-axis points up insead of down
145 SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m, SkScalar flip) { 145 SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m, SkScalar flip) {
146 SkMatrix skMatrix; 146 SkMatrix skMatrix;
147 skMatrix.setAll(m.a * flip, -m.c * flip, m.e, m.b * flip, -m.d * flip, m.f, 0, 147 skMatrix.setAll(m.a * flip, -m.c * flip, m.e, m.b * flip, -m.d * flip, m.f, 0,
148 0, 1); 148 0, 1);
149 return skMatrix; 149 return skMatrix;
150 } 150 }
151 151
152 SkXfermode::Mode GetSkiaBlendMode(int blend_type) { 152 SkBlendMode GetSkiaBlendMode(int blend_type) {
153 switch (blend_type) { 153 switch (blend_type) {
154 case FXDIB_BLEND_MULTIPLY: 154 case FXDIB_BLEND_MULTIPLY:
155 return SkXfermode::kMultiply_Mode; 155 return SkBlendMode::kMultiply;
156 case FXDIB_BLEND_SCREEN: 156 case FXDIB_BLEND_SCREEN:
157 return SkXfermode::kScreen_Mode; 157 return SkBlendMode::kScreen;
158 case FXDIB_BLEND_OVERLAY: 158 case FXDIB_BLEND_OVERLAY:
159 return SkXfermode::kOverlay_Mode; 159 return SkBlendMode::kOverlay;
160 case FXDIB_BLEND_DARKEN: 160 case FXDIB_BLEND_DARKEN:
161 return SkXfermode::kDarken_Mode; 161 return SkBlendMode::kDarken;
162 case FXDIB_BLEND_LIGHTEN: 162 case FXDIB_BLEND_LIGHTEN:
163 return SkXfermode::kLighten_Mode; 163 return SkBlendMode::kLighten;
164 case FXDIB_BLEND_COLORDODGE: 164 case FXDIB_BLEND_COLORDODGE:
165 return SkXfermode::kColorDodge_Mode; 165 return SkBlendMode::kColorDodge;
166 case FXDIB_BLEND_COLORBURN: 166 case FXDIB_BLEND_COLORBURN:
167 return SkXfermode::kColorBurn_Mode; 167 return SkBlendMode::kColorBurn;
168 case FXDIB_BLEND_HARDLIGHT: 168 case FXDIB_BLEND_HARDLIGHT:
169 return SkXfermode::kHardLight_Mode; 169 return SkBlendMode::kHardLight;
170 case FXDIB_BLEND_SOFTLIGHT: 170 case FXDIB_BLEND_SOFTLIGHT:
171 return SkXfermode::kSoftLight_Mode; 171 return SkBlendMode::kSoftLight;
172 case FXDIB_BLEND_DIFFERENCE: 172 case FXDIB_BLEND_DIFFERENCE:
173 return SkXfermode::kDifference_Mode; 173 return SkBlendMode::kDifference;
174 case FXDIB_BLEND_EXCLUSION: 174 case FXDIB_BLEND_EXCLUSION:
175 return SkXfermode::kExclusion_Mode; 175 return SkBlendMode::kExclusion;
176 case FXDIB_BLEND_HUE: 176 case FXDIB_BLEND_HUE:
177 return SkXfermode::kHue_Mode; 177 return SkBlendMode::kHue;
178 case FXDIB_BLEND_SATURATION: 178 case FXDIB_BLEND_SATURATION:
179 return SkXfermode::kSaturation_Mode; 179 return SkBlendMode::kSaturation;
180 case FXDIB_BLEND_COLOR: 180 case FXDIB_BLEND_COLOR:
181 return SkXfermode::kColor_Mode; 181 return SkBlendMode::kColor;
182 case FXDIB_BLEND_LUMINOSITY: 182 case FXDIB_BLEND_LUMINOSITY:
183 return SkXfermode::kLuminosity_Mode; 183 return SkBlendMode::kLuminosity;
184 case FXDIB_BLEND_NORMAL: 184 case FXDIB_BLEND_NORMAL:
185 default: 185 default:
186 return SkXfermode::kSrcOver_Mode; 186 return SkBlendMode::kSrcOver;
187 } 187 }
188 } 188 }
189 189
190 bool AddColors(const CPDF_ExpIntFunc* pFunc, SkTDArray<SkColor>* skColors) { 190 bool AddColors(const CPDF_ExpIntFunc* pFunc, SkTDArray<SkColor>* skColors) {
191 if (pFunc->CountInputs() != 1) 191 if (pFunc->CountInputs() != 1)
192 return false; 192 return false;
193 if (pFunc->m_Exponent != 1) 193 if (pFunc->m_Exponent != 1)
194 return false; 194 return false;
195 if (pFunc->m_nOrigOutputs != 3) 195 if (pFunc->m_nOrigOutputs != 3)
196 return false; 196 return false;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 uint32_t argb, 383 uint32_t argb,
384 int bitmap_alpha, 384 int bitmap_alpha,
385 int blend_type, 385 int blend_type,
386 SkPaint* paint) { 386 SkPaint* paint) {
387 paint->setAntiAlias(true); 387 paint->setAntiAlias(true);
388 if (isAlphaMask) { 388 if (isAlphaMask) {
389 paint->setColorFilter( 389 paint->setColorFilter(
390 SkColorFilter::MakeModeFilter(argb, SkXfermode::kSrc_Mode)); 390 SkColorFilter::MakeModeFilter(argb, SkXfermode::kSrc_Mode));
391 } 391 }
392 // paint->setFilterQuality(kHigh_SkFilterQuality); 392 // paint->setFilterQuality(kHigh_SkFilterQuality);
393 paint->setXfermodeMode(GetSkiaBlendMode(blend_type)); 393 paint->setBlendMode(GetSkiaBlendMode(blend_type));
394 paint->setAlpha(bitmap_alpha); 394 paint->setAlpha(bitmap_alpha);
395 } 395 }
396 396
397 bool Upsample(const CFX_DIBSource* pSource, 397 bool Upsample(const CFX_DIBSource* pSource,
398 std::unique_ptr<uint8_t, FxFreeDeleter>& dst8Storage, 398 std::unique_ptr<uint8_t, FxFreeDeleter>& dst8Storage,
399 std::unique_ptr<uint32_t, FxFreeDeleter>& dst32Storage, 399 std::unique_ptr<uint32_t, FxFreeDeleter>& dst32Storage,
400 SkColorTable** ctPtr, 400 SkColorTable** ctPtr,
401 SkBitmap* skBitmap, 401 SkBitmap* skBitmap,
402 int* widthPtr, 402 int* widthPtr,
403 int* heightPtr, 403 int* heightPtr,
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 int blend_type) { 1189 int blend_type) {
1190 return FALSE; 1190 return FALSE;
1191 } 1191 }
1192 1192
1193 FX_BOOL CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, 1193 FX_BOOL CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
1194 uint32_t fill_color, 1194 uint32_t fill_color,
1195 int blend_type) { 1195 int blend_type) {
1196 SkPaint spaint; 1196 SkPaint spaint;
1197 spaint.setAntiAlias(true); 1197 spaint.setAntiAlias(true);
1198 spaint.setColor(fill_color); 1198 spaint.setColor(fill_color);
1199 spaint.setXfermodeMode(GetSkiaBlendMode(blend_type)); 1199 spaint.setBlendMode(GetSkiaBlendMode(blend_type));
1200 1200
1201 m_pCanvas->drawRect( 1201 m_pCanvas->drawRect(
1202 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), 1202 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom),
1203 spaint); 1203 spaint);
1204 return TRUE; 1204 return TRUE;
1205 } 1205 }
1206 1206
1207 FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, 1207 FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
1208 const CFX_Matrix* pMatrix, 1208 const CFX_Matrix* pMatrix,
1209 const FX_RECT& clip_rect, 1209 const FX_RECT& clip_rect,
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 SkA32Assert(a); 1672 SkA32Assert(a);
1673 SkASSERT(r <= a); 1673 SkASSERT(r <= a);
1674 SkASSERT(g <= a); 1674 SkASSERT(g <= a);
1675 SkASSERT(b <= a); 1675 SkASSERT(b <= a);
1676 } 1676 }
1677 } 1677 }
1678 #endif 1678 #endif
1679 } 1679 }
1680 1680
1681 #endif 1681 #endif
OLDNEW
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698