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

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

Issue 2395273002: Assorted Android fixes (Closed)
Patch Set: rebase 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 | « 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"
11 #include "SkDrawLooper.h" 11 #include "SkDrawLooper.h"
12 #include "SkPaint.h" 12 #include "SkPaint.h"
13 #include "SkPathEffect.h" 13 #include "SkPathEffect.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 #include "SkSurface.h" 15 #include "SkSurface.h"
16 #include "SkTLazy.h" 16 #include "SkTLazy.h"
17 17
18 namespace { 18 namespace {
19 19
20 /** Discard SkShaders not exposed by the Android Java API. */ 20 /** Discard SkShaders not exposed by the Android Java API. */
21 21
22 void CheckShader(SkPaint* paint) { 22 void CheckShader(SkPaint* paint) {
23 SkShader* shader = paint->getShader(); 23 SkShader* shader = paint->getShader();
24 if (!shader) { 24 if (!shader) {
25 return; 25 return;
26 } 26 }
27 27
28 if (shader->isABitmap()) { 28 if (shader->isAImage()) {
29 return; 29 return;
30 } 30 }
31 if (shader->asACompose(nullptr)) { 31 if (shader->asACompose(nullptr)) {
32 return; 32 return;
33 } 33 }
34 SkShader::GradientType gtype = shader->asAGradient(nullptr); 34 SkShader::GradientType gtype = shader->asAGradient(nullptr);
35 if (gtype == SkShader::kLinear_GradientType || 35 if (gtype == SkShader::kLinear_GradientType ||
36 gtype == SkShader::kRadial_GradientType || 36 gtype == SkShader::kRadial_GradientType ||
37 gtype == SkShader::kSweep_GradientType) { 37 gtype == SkShader::kSweep_GradientType) {
38 return; 38 return;
39 } 39 }
40 paint->setShader(nullptr); 40 paint->setShader(nullptr);
41 } 41 }
42 42
43 void Filter(SkPaint* paint) { 43 void Filter(SkPaint* paint) {
44 44
45 uint32_t flags = paint->getFlags(); 45 uint32_t flags = paint->getFlags();
46 flags &= ~SkPaint::kLCDRenderText_Flag; 46 flags &= ~SkPaint::kLCDRenderText_Flag;
47 paint->setFlags(flags); 47 paint->setFlags(flags);
48 48
49 // Android doesn't support Xfermodes above kLighten_Mode 49 // Android doesn't support blend modes above kLighten_Mode
50 SkXfermode::Mode mode; 50 if (paint->getBlendMode() > SkBlendMode::kLighten) {
51 SkXfermode::AsMode(paint->getXfermode(), &mode); 51 paint->setBlendMode(SkBlendMode::kSrcOver);
52 if (mode > SkXfermode::kLighten_Mode) {
53 paint->setXfermode(nullptr);
54 } 52 }
55 53
56 // Force bilinear scaling or none 54 // Force bilinear scaling or none
57 if (paint->getFilterQuality() != kNone_SkFilterQuality) { 55 if (paint->getFilterQuality() != kNone_SkFilterQuality) {
58 paint->setFilterQuality(kLow_SkFilterQuality); 56 paint->setFilterQuality(kLow_SkFilterQuality);
59 } 57 }
60 58
61 CheckShader(paint); 59 CheckShader(paint);
62 60
63 // Android SDK only supports mode & matrix color filters 61 // Android SDK only supports mode & matrix color filters
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 335
338 void SkAndroidSDKCanvas::didConcat(const SkMatrix& m) { 336 void SkAndroidSDKCanvas::didConcat(const SkMatrix& m) {
339 fProxyTarget->concat(m); 337 fProxyTarget->concat(m);
340 } 338 }
341 339
342 void SkAndroidSDKCanvas::didSetMatrix(const SkMatrix& m) { 340 void SkAndroidSDKCanvas::didSetMatrix(const SkMatrix& m) {
343 fProxyTarget->setMatrix(m); 341 fProxyTarget->setMatrix(m);
344 } 342 }
345 343
346 void SkAndroidSDKCanvas::onClipRect(const SkRect& rect, 344 void SkAndroidSDKCanvas::onClipRect(const SkRect& rect,
347 SkRegion::Op op, 345 ClipOp op,
348 ClipEdgeStyle style) { 346 ClipEdgeStyle style) {
349 fProxyTarget->clipRect(rect, op, style); 347 fProxyTarget->clipRect(rect, op, style);
350 } 348 }
351 349
352 void SkAndroidSDKCanvas::onClipRRect(const SkRRect& rrect, 350 void SkAndroidSDKCanvas::onClipRRect(const SkRRect& rrect,
353 SkRegion::Op op, 351 ClipOp op,
354 ClipEdgeStyle style) { 352 ClipEdgeStyle style) {
355 fProxyTarget->clipRRect(rrect, op, style); 353 fProxyTarget->clipRRect(rrect, op, style);
356 } 354 }
357 355
358 void SkAndroidSDKCanvas::onClipPath(const SkPath& path, 356 void SkAndroidSDKCanvas::onClipPath(const SkPath& path,
359 SkRegion::Op op, 357 ClipOp op,
360 ClipEdgeStyle style) { 358 ClipEdgeStyle style) {
361 fProxyTarget->clipPath(path, op, style); 359 fProxyTarget->clipPath(path, op, style);
362 } 360 }
363 361
364 void SkAndroidSDKCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) { 362 void SkAndroidSDKCanvas::onClipRegion(const SkRegion& region, ClipOp op) {
365 fProxyTarget->clipRegion(region, op); 363 fProxyTarget->clipRegion(region, op);
366 } 364 }
367 365
368 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