vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 The Android Open Source Project |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 9 | #ifndef SkPDFGraphicState_DEFINED |
| 10 | #define SkPDFGraphicState_DEFINED |
| 11 | |
halcanary | fa25106 | 2016-07-29 10:13:18 -0700 | [diff] [blame] | 12 | #include "SkPDFTypes.h" |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 13 | #include "SkOpts.h" |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 14 | |
martina.kollarova | b8d6af1 | 2016-06-29 05:12:31 -0700 | [diff] [blame] | 15 | class SkPaint; |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 16 | class SkPDFCanon; |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 17 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 18 | /** \class SkPDFGraphicState |
| 19 | SkPaint objects roughly correspond to graphic state dictionaries that can |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 20 | be installed. So that a given dictionary is only output to the pdf file |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 21 | once, we want to canonicalize them. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 22 | */ |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 23 | namespace SkPDFGraphicState { |
commit-bot@chromium.org | 93a2e21 | 2013-07-23 23:16:03 +0000 | [diff] [blame] | 24 | enum SkPDFSMaskMode { |
| 25 | kAlpha_SMaskMode, |
| 26 | kLuminosity_SMaskMode |
| 27 | }; |
| 28 | |
Hal Canary | 5c1b360 | 2017-04-17 16:30:06 -0400 | [diff] [blame] | 29 | /** Get the graphic state for the passed SkPaint. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 30 | */ |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 31 | sk_sp<SkPDFDict> GetGraphicStateForPaint(SkPDFCanon*, const SkPaint&); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 32 | |
halcanary | 1437c1e | 2016-03-13 18:30:24 -0700 | [diff] [blame] | 33 | /** Make a graphic state that only sets the passed soft mask. |
commit-bot@chromium.org | 93a2e21 | 2013-07-23 23:16:03 +0000 | [diff] [blame] | 34 | * @param sMask The form xobject to use as a soft mask. |
| 35 | * @param invert Indicates if the alpha of the sMask should be inverted. |
| 36 | * @param sMaskMode Whether to use alpha or luminosity for the sMask. |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 37 | * |
| 38 | * These are not de-duped. |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 39 | */ |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 40 | sk_sp<SkPDFDict> GetSMaskGraphicState(sk_sp<SkPDFObject> sMask, |
| 41 | bool invert, |
| 42 | SkPDFSMaskMode sMaskMode, |
| 43 | SkPDFCanon* canon); |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 44 | |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 45 | sk_sp<SkPDFStream> MakeInvertFunction(); |
| 46 | } |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 47 | |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 48 | SK_BEGIN_REQUIRE_DENSE |
| 49 | struct SkPDFStrokeGraphicState { |
| 50 | SkScalar fStrokeWidth; |
| 51 | SkScalar fStrokeMiter; |
| 52 | uint8_t fStrokeCap; // SkPaint::Cap |
| 53 | uint8_t fStrokeJoin; // SkPaint::Join |
| 54 | uint8_t fAlpha; |
| 55 | uint8_t fBlendMode; |
| 56 | bool operator==(const SkPDFStrokeGraphicState& o) const { return !memcmp(this, &o, sizeof(o)); } |
| 57 | bool operator!=(const SkPDFStrokeGraphicState& o) const { return !(*this == o); } |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 58 | }; |
Hal Canary | 80fa7ce | 2017-06-28 16:04:20 -0400 | [diff] [blame] | 59 | SK_END_REQUIRE_DENSE |
| 60 | |
| 61 | SK_BEGIN_REQUIRE_DENSE |
| 62 | struct SkPDFFillGraphicState { |
| 63 | uint8_t fAlpha; |
| 64 | uint8_t fBlendMode; |
| 65 | bool operator==(const SkPDFFillGraphicState& o) const { return !memcmp(this, &o, sizeof(o)); } |
| 66 | bool operator!=(const SkPDFFillGraphicState& o) const { return !(*this == o); } |
| 67 | }; |
| 68 | SK_END_REQUIRE_DENSE |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 69 | |
| 70 | #endif |