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

Side by Side Diff: tools/android/SkAndroidSDKCanvas.cpp

Issue 2464433003: update androidsdkcanvas for SkBlendMode (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « tools/android/SkAndroidSDKCanvas.h ('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 /* 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 "SkAndroidSDKCanvas.h" 8 #include "SkAndroidSDKCanvas.h"
9 9
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 paint->setFilterQuality(kLow_SkFilterQuality); 56 paint->setFilterQuality(kLow_SkFilterQuality);
57 } 57 }
58 58
59 CheckShader(paint); 59 CheckShader(paint);
60 60
61 // Android SDK only supports mode & matrix color filters 61 // Android SDK only supports mode & matrix color filters
62 // (and, again, no modes above kLighten_Mode). 62 // (and, again, no modes above kLighten_Mode).
63 SkColorFilter* cf = paint->getColorFilter(); 63 SkColorFilter* cf = paint->getColorFilter();
64 if (cf) { 64 if (cf) {
65 SkColor color; 65 SkColor color;
66 SkXfermode::Mode mode; 66 SK_XFERMODE_MODE_PARAM mode;
67 SkScalar srcColorMatrix[20]; 67 SkScalar srcColorMatrix[20];
68 bool isMode = cf->asColorMode(&color, &mode); 68 bool isMode = cf->asColorMode(&color, &mode);
69 if (isMode && mode > SkXfermode::kLighten_Mode) { 69 if (isMode && (int)mode > (int)SkBlendMode::kLighten) {
70 paint->setColorFilter( 70 paint->setColorFilter(
71 SkColorFilter::MakeModeFilter(color, SkXfermode::kSrcOver_Mode)) ; 71 SkColorFilter::MakeModeFilter(color, SkBlendMode::kSrcOver));
72 } else if (!isMode && !cf->asColorMatrix(srcColorMatrix)) { 72 } else if (!isMode && !cf->asColorMatrix(srcColorMatrix)) {
73 paint->setColorFilter(nullptr); 73 paint->setColorFilter(nullptr);
74 } 74 }
75 } 75 }
76 76
77 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 77 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
78 SkPathEffect* pe = paint->getPathEffect(); 78 SkPathEffect* pe = paint->getPathEffect();
79 if (pe && !pe->exposedInAndroidJavaAPI()) { 79 if (pe && !pe->exposedInAndroidJavaAPI()) {
80 paint->setPathEffect(nullptr); 80 paint->setPathEffect(nullptr);
81 } 81 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void SkAndroidSDKCanvas::onDrawBitmapNine(const SkBitmap& bitmap, 157 void SkAndroidSDKCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
158 const SkIRect& center, 158 const SkIRect& center,
159 const SkRect& dst, 159 const SkRect& dst,
160 const SkPaint* paint) { 160 const SkPaint* paint) {
161 FILTER_PTR(paint); 161 FILTER_PTR(paint);
162 fProxyTarget->drawBitmapNine(bitmap, center, dst, filteredPaint); 162 fProxyTarget->drawBitmapNine(bitmap, center, dst, filteredPaint);
163 } 163 }
164 void SkAndroidSDKCanvas::onDrawVertices(VertexMode vMode, 164 void SkAndroidSDKCanvas::onDrawVertices(VertexMode vMode,
165 int vertexCount, 165 int vertexCount,
166 const SkPoint vertices[], 166 const SkPoint vertices[],
167 const SkPoint texs[], const SkColor colors[], SkXfermode* xM ode, 167 const SkPoint texs[], const SkColor colors[], SK_XFERMODE_PA RAM xMode,
168 const uint16_t indices[], int indexCount, 168 const uint16_t indices[], int indexCount,
169 const SkPaint& paint) { 169 const SkPaint& paint) {
170 FILTER(paint); 170 FILTER(paint);
171 fProxyTarget->drawVertices(vMode, vertexCount, vertices, texs, colors, 171 fProxyTarget->drawVertices(vMode, vertexCount, vertices, texs, colors,
172 xMode, indices, indexCount, filteredPaint); 172 xMode, indices, indexCount, filteredPaint);
173 } 173 }
174 174
175 void SkAndroidSDKCanvas::onDrawDRRect(const SkRRect& outer, 175 void SkAndroidSDKCanvas::onDrawDRRect(const SkRRect& outer,
176 const SkRRect& inner, 176 const SkRRect& inner,
177 const SkPaint& paint) { 177 const SkPaint& paint) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 SkScalar x, 220 SkScalar x,
221 SkScalar y, 221 SkScalar y,
222 const SkPaint& paint) { 222 const SkPaint& paint) {
223 FILTER(paint); 223 FILTER(paint);
224 fProxyTarget->drawTextBlob(blob, x, y, filteredPaint); 224 fProxyTarget->drawTextBlob(blob, x, y, filteredPaint);
225 } 225 }
226 226
227 void SkAndroidSDKCanvas::onDrawPatch(const SkPoint cubics[12], 227 void SkAndroidSDKCanvas::onDrawPatch(const SkPoint cubics[12],
228 const SkColor colors[4], 228 const SkColor colors[4],
229 const SkPoint texCoords[4], 229 const SkPoint texCoords[4],
230 SkXfermode* xmode, 230 SK_XFERMODE_PARAM xmode,
231 const SkPaint& paint) { 231 const SkPaint& paint) {
232 FILTER(paint); 232 FILTER(paint);
233 fProxyTarget->drawPatch(cubics, colors, texCoords, xmode, filteredPaint); 233 fProxyTarget->drawPatch(cubics, colors, texCoords, xmode, filteredPaint);
234 } 234 }
235 235
236 236
237 void SkAndroidSDKCanvas::onDrawImage(const SkImage* image, 237 void SkAndroidSDKCanvas::onDrawImage(const SkImage* image,
238 SkScalar x, 238 SkScalar x,
239 SkScalar y, 239 SkScalar y,
240 const SkPaint* paint) { 240 const SkPaint* paint) {
(...skipping 15 matching lines...) Expand all
256 const SkPaint* paint) { 256 const SkPaint* paint) {
257 FILTER_PTR(paint); 257 FILTER_PTR(paint);
258 fProxyTarget->drawPicture(picture, matrix, filteredPaint); 258 fProxyTarget->drawPicture(picture, matrix, filteredPaint);
259 } 259 }
260 260
261 void SkAndroidSDKCanvas::onDrawAtlas(const SkImage* atlas, 261 void SkAndroidSDKCanvas::onDrawAtlas(const SkImage* atlas,
262 const SkRSXform xform[], 262 const SkRSXform xform[],
263 const SkRect tex[], 263 const SkRect tex[],
264 const SkColor colors[], 264 const SkColor colors[],
265 int count, 265 int count,
266 SkXfermode::Mode mode, 266 SK_XFERMODE_MODE_PARAM mode,
267 const SkRect* cullRect, 267 const SkRect* cullRect,
268 const SkPaint* paint) { 268 const SkPaint* paint) {
269 FILTER_PTR(paint); 269 FILTER_PTR(paint);
270 fProxyTarget->drawAtlas(atlas, xform, tex, colors, count, mode, cullRect, 270 fProxyTarget->drawAtlas(atlas, xform, tex, colors, count, mode, cullRect,
271 filteredPaint); 271 filteredPaint);
272 } 272 }
273 273
274 void SkAndroidSDKCanvas::onDrawImageNine(const SkImage* image, 274 void SkAndroidSDKCanvas::onDrawImageNine(const SkImage* image,
275 const SkIRect& center, 275 const SkIRect& center,
276 const SkRect& dst, 276 const SkRect& dst,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 ClipOp op, 357 ClipOp op,
358 ClipEdgeStyle style) { 358 ClipEdgeStyle style) {
359 fProxyTarget->clipPath(path, op, style); 359 fProxyTarget->clipPath(path, op, style);
360 } 360 }
361 361
362 void SkAndroidSDKCanvas::onClipRegion(const SkRegion& region, ClipOp op) { 362 void SkAndroidSDKCanvas::onClipRegion(const SkRegion& region, ClipOp op) {
363 fProxyTarget->clipRegion(region, op); 363 fProxyTarget->clipRegion(region, op);
364 } 364 }
365 365
366 void SkAndroidSDKCanvas::onDiscard() { fProxyTarget->discard(); } 366 void SkAndroidSDKCanvas::onDiscard() { fProxyTarget->discard(); }
OLDNEW
« no previous file with comments | « tools/android/SkAndroidSDKCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698