Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.graphics; |
| 18 | |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 19 | import com.android.ide.common.rendering.api.LayoutLog; |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 20 | import com.android.layoutlib.bridge.Bridge; |
Xavier Ducrohet | 3bd9898 | 2010-11-09 18:25:03 -0800 | [diff] [blame] | 21 | import com.android.layoutlib.bridge.impl.DelegateManager; |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 22 | import com.android.tools.layoutlib.annotations.LayoutlibDelegate; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 23 | |
| 24 | import android.graphics.Paint.FontMetrics; |
| 25 | import android.graphics.Paint.FontMetricsInt; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 26 | import android.text.TextUtils; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 27 | |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 28 | import java.awt.BasicStroke; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 29 | import java.awt.Font; |
Xavier Ducrohet | b976124 | 2010-12-23 10:22:14 -0800 | [diff] [blame] | 30 | import java.awt.Shape; |
| 31 | import java.awt.Stroke; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 32 | import java.awt.Toolkit; |
| 33 | import java.awt.font.FontRenderContext; |
| 34 | import java.awt.geom.AffineTransform; |
| 35 | import java.util.ArrayList; |
| 36 | import java.util.Collections; |
| 37 | import java.util.List; |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 38 | import java.util.Locale; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Delegate implementing the native methods of android.graphics.Paint |
| 42 | * |
| 43 | * Through the layoutlib_create tool, the original native methods of Paint have been replaced |
| 44 | * by calls to methods of the same name in this delegate class. |
| 45 | * |
| 46 | * This class behaves like the original native implementation, but in Java, keeping previously |
| 47 | * native data into its own objects and mapping them to int that are sent back and forth between |
| 48 | * it and the original Paint class. |
| 49 | * |
| 50 | * @see DelegateManager |
| 51 | * |
| 52 | */ |
| 53 | public class Paint_Delegate { |
| 54 | |
| 55 | /** |
| 56 | * Class associating a {@link Font} and it's {@link java.awt.FontMetrics}. |
| 57 | */ |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 58 | /*package*/ static final class FontInfo { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 59 | Font mFont; |
| 60 | java.awt.FontMetrics mMetrics; |
| 61 | } |
| 62 | |
| 63 | // ---- delegate manager ---- |
| 64 | private static final DelegateManager<Paint_Delegate> sManager = |
Xavier Ducrohet | b2de839 | 2011-02-23 16:51:08 -0800 | [diff] [blame] | 65 | new DelegateManager<Paint_Delegate>(Paint_Delegate.class); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 66 | |
| 67 | // ---- delegate helper data ---- |
| 68 | private List<FontInfo> mFonts; |
| 69 | private final FontRenderContext mFontContext = new FontRenderContext( |
| 70 | new AffineTransform(), true, true); |
| 71 | |
| 72 | // ---- delegate data ---- |
| 73 | private int mFlags; |
| 74 | private int mColor; |
| 75 | private int mStyle; |
| 76 | private int mCap; |
| 77 | private int mJoin; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 78 | private int mTextAlign; |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 79 | private Typeface_Delegate mTypeface; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 80 | private float mStrokeWidth; |
| 81 | private float mStrokeMiter; |
| 82 | private float mTextSize; |
| 83 | private float mTextScaleX; |
| 84 | private float mTextSkewX; |
Xavier Ducrohet | b6f7f57 | 2011-08-22 13:13:16 -0700 | [diff] [blame] | 85 | private int mHintingMode = Paint.HINTING_ON; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 86 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 87 | private Xfermode_Delegate mXfermode; |
| 88 | private ColorFilter_Delegate mColorFilter; |
| 89 | private Shader_Delegate mShader; |
| 90 | private PathEffect_Delegate mPathEffect; |
| 91 | private MaskFilter_Delegate mMaskFilter; |
| 92 | private Rasterizer_Delegate mRasterizer; |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 93 | |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 94 | private Locale mLocale = Locale.getDefault(); |
| 95 | |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 96 | |
| 97 | // ---- Public Helper methods ---- |
| 98 | |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 99 | public static Paint_Delegate getDelegate(long native_paint) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 100 | return sManager.getDelegate(native_paint); |
| 101 | } |
| 102 | |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 103 | /** |
| 104 | * Returns the list of {@link Font} objects. The first item is the main font, the rest |
| 105 | * are fall backs for characters not present in the main font. |
| 106 | */ |
| 107 | public List<FontInfo> getFonts() { |
| 108 | return mFonts; |
| 109 | } |
| 110 | |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 111 | public boolean isAntiAliased() { |
| 112 | return (mFlags & Paint.ANTI_ALIAS_FLAG) != 0; |
| 113 | } |
| 114 | |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 115 | public boolean isFilterBitmap() { |
| 116 | return (mFlags & Paint.FILTER_BITMAP_FLAG) != 0; |
| 117 | } |
| 118 | |
| 119 | public int getStyle() { |
| 120 | return mStyle; |
| 121 | } |
| 122 | |
| 123 | public int getColor() { |
| 124 | return mColor; |
| 125 | } |
| 126 | |
Xavier Ducrohet | 6622522 | 2010-12-21 01:33:04 -0800 | [diff] [blame] | 127 | public int getAlpha() { |
| 128 | return mColor >>> 24; |
| 129 | } |
| 130 | |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 131 | public void setAlpha(int alpha) { |
| 132 | mColor = (alpha << 24) | (mColor & 0x00FFFFFF); |
| 133 | } |
| 134 | |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 135 | public int getTextAlign() { |
| 136 | return mTextAlign; |
| 137 | } |
| 138 | |
| 139 | public float getStrokeWidth() { |
| 140 | return mStrokeWidth; |
| 141 | } |
| 142 | |
Xavier Ducrohet | 6622522 | 2010-12-21 01:33:04 -0800 | [diff] [blame] | 143 | /** |
| 144 | * returns the value of stroke miter needed by the java api. |
| 145 | */ |
| 146 | public float getJavaStrokeMiter() { |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 147 | float miter = mStrokeMiter * mStrokeWidth; |
| 148 | if (miter < 1.f) { |
| 149 | miter = 1.f; |
| 150 | } |
| 151 | return miter; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | public int getJavaCap() { |
| 155 | switch (Paint.sCapArray[mCap]) { |
| 156 | case BUTT: |
| 157 | return BasicStroke.CAP_BUTT; |
| 158 | case ROUND: |
| 159 | return BasicStroke.CAP_ROUND; |
| 160 | default: |
| 161 | case SQUARE: |
| 162 | return BasicStroke.CAP_SQUARE; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | public int getJavaJoin() { |
| 167 | switch (Paint.sJoinArray[mJoin]) { |
| 168 | default: |
| 169 | case MITER: |
| 170 | return BasicStroke.JOIN_MITER; |
| 171 | case ROUND: |
| 172 | return BasicStroke.JOIN_ROUND; |
| 173 | case BEVEL: |
| 174 | return BasicStroke.JOIN_BEVEL; |
| 175 | } |
| 176 | } |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 177 | |
Xavier Ducrohet | b976124 | 2010-12-23 10:22:14 -0800 | [diff] [blame] | 178 | public Stroke getJavaStroke() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 179 | if (mPathEffect != null) { |
| 180 | if (mPathEffect.isSupported()) { |
| 181 | Stroke stroke = mPathEffect.getStroke(this); |
Xavier Ducrohet | b976124 | 2010-12-23 10:22:14 -0800 | [diff] [blame] | 182 | assert stroke != null; |
| 183 | if (stroke != null) { |
| 184 | return stroke; |
| 185 | } |
| 186 | } else { |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 187 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_PATHEFFECT, |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 188 | mPathEffect.getSupportMessage(), |
Xavier Ducrohet | f69bb29 | 2011-01-14 16:40:43 -0800 | [diff] [blame] | 189 | null, null /*data*/); |
Xavier Ducrohet | b976124 | 2010-12-23 10:22:14 -0800 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | |
| 193 | // if no custom stroke as been set, set the default one. |
| 194 | return new BasicStroke( |
| 195 | getStrokeWidth(), |
| 196 | getJavaCap(), |
| 197 | getJavaJoin(), |
| 198 | getJavaStrokeMiter()); |
| 199 | } |
| 200 | |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 201 | /** |
| 202 | * Returns the {@link Xfermode} delegate or null if none have been set |
| 203 | * |
| 204 | * @return the delegate or null. |
| 205 | */ |
| 206 | public Xfermode_Delegate getXfermode() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 207 | return mXfermode; |
Xavier Ducrohet | f1a17452 | 2010-11-01 22:02:08 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 210 | /** |
| 211 | * Returns the {@link ColorFilter} delegate or null if none have been set |
| 212 | * |
| 213 | * @return the delegate or null. |
| 214 | */ |
| 215 | public ColorFilter_Delegate getColorFilter() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 216 | return mColorFilter; |
Xavier Ducrohet | f1a17452 | 2010-11-01 22:02:08 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 219 | /** |
| 220 | * Returns the {@link Shader} delegate or null if none have been set |
| 221 | * |
| 222 | * @return the delegate or null. |
| 223 | */ |
| 224 | public Shader_Delegate getShader() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 225 | return mShader; |
Xavier Ducrohet | f1a17452 | 2010-11-01 22:02:08 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 228 | /** |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 229 | * Returns the {@link MaskFilter} delegate or null if none have been set |
| 230 | * |
| 231 | * @return the delegate or null. |
| 232 | */ |
| 233 | public MaskFilter_Delegate getMaskFilter() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 234 | return mMaskFilter; |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Returns the {@link Rasterizer} delegate or null if none have been set |
| 239 | * |
| 240 | * @return the delegate or null. |
| 241 | */ |
| 242 | public Rasterizer_Delegate getRasterizer() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 243 | return mRasterizer; |
Xavier Ducrohet | f1a17452 | 2010-11-01 22:02:08 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 246 | // ---- native methods ---- |
| 247 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 248 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 249 | /*package*/ static int getFlags(Paint thisPaint) { |
| 250 | // get the delegate from the native int. |
| 251 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 252 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | return delegate.mFlags; |
| 257 | } |
| 258 | |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 259 | |
| 260 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 261 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 262 | /*package*/ static void setFlags(Paint thisPaint, int flags) { |
| 263 | // get the delegate from the native int. |
| 264 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 265 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 266 | return; |
| 267 | } |
| 268 | |
| 269 | delegate.mFlags = flags; |
| 270 | } |
| 271 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 272 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 273 | /*package*/ static void setFilterBitmap(Paint thisPaint, boolean filter) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 274 | setFlag(thisPaint, Paint.FILTER_BITMAP_FLAG, filter); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 277 | @LayoutlibDelegate |
Xavier Ducrohet | b6f7f57 | 2011-08-22 13:13:16 -0700 | [diff] [blame] | 278 | /*package*/ static int getHinting(Paint thisPaint) { |
| 279 | // get the delegate from the native int. |
| 280 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 281 | if (delegate == null) { |
| 282 | return Paint.HINTING_ON; |
| 283 | } |
| 284 | |
| 285 | return delegate.mHintingMode; |
| 286 | } |
| 287 | |
| 288 | @LayoutlibDelegate |
| 289 | /*package*/ static void setHinting(Paint thisPaint, int mode) { |
| 290 | // get the delegate from the native int. |
| 291 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 292 | if (delegate == null) { |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | delegate.mHintingMode = mode; |
| 297 | } |
| 298 | |
| 299 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 300 | /*package*/ static void setAntiAlias(Paint thisPaint, boolean aa) { |
| 301 | setFlag(thisPaint, Paint.ANTI_ALIAS_FLAG, aa); |
| 302 | } |
| 303 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 304 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 305 | /*package*/ static void setSubpixelText(Paint thisPaint, boolean subpixelText) { |
| 306 | setFlag(thisPaint, Paint.SUBPIXEL_TEXT_FLAG, subpixelText); |
| 307 | } |
| 308 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 309 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 310 | /*package*/ static void setUnderlineText(Paint thisPaint, boolean underlineText) { |
| 311 | setFlag(thisPaint, Paint.UNDERLINE_TEXT_FLAG, underlineText); |
| 312 | } |
| 313 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 314 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 315 | /*package*/ static void setStrikeThruText(Paint thisPaint, boolean strikeThruText) { |
| 316 | setFlag(thisPaint, Paint.STRIKE_THRU_TEXT_FLAG, strikeThruText); |
| 317 | } |
| 318 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 319 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 320 | /*package*/ static void setFakeBoldText(Paint thisPaint, boolean fakeBoldText) { |
| 321 | setFlag(thisPaint, Paint.FAKE_BOLD_TEXT_FLAG, fakeBoldText); |
| 322 | } |
| 323 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 324 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 325 | /*package*/ static void setDither(Paint thisPaint, boolean dither) { |
| 326 | setFlag(thisPaint, Paint.DITHER_FLAG, dither); |
| 327 | } |
| 328 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 329 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 330 | /*package*/ static void setLinearText(Paint thisPaint, boolean linearText) { |
| 331 | setFlag(thisPaint, Paint.LINEAR_TEXT_FLAG, linearText); |
| 332 | } |
| 333 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 334 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 335 | /*package*/ static int getColor(Paint thisPaint) { |
| 336 | // get the delegate from the native int. |
| 337 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 338 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | return delegate.mColor; |
| 343 | } |
| 344 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 345 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 346 | /*package*/ static void setColor(Paint thisPaint, int color) { |
| 347 | // get the delegate from the native int. |
| 348 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 349 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 350 | return; |
| 351 | } |
| 352 | |
| 353 | delegate.mColor = color; |
| 354 | } |
| 355 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 356 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 357 | /*package*/ static int getAlpha(Paint thisPaint) { |
| 358 | // get the delegate from the native int. |
| 359 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 360 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 361 | return 0; |
| 362 | } |
| 363 | |
Xavier Ducrohet | 6622522 | 2010-12-21 01:33:04 -0800 | [diff] [blame] | 364 | return delegate.getAlpha(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 367 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 368 | /*package*/ static void setAlpha(Paint thisPaint, int a) { |
| 369 | // get the delegate from the native int. |
| 370 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 371 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 372 | return; |
| 373 | } |
| 374 | |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 375 | delegate.setAlpha(a); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 378 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 379 | /*package*/ static float getStrokeWidth(Paint thisPaint) { |
| 380 | // get the delegate from the native int. |
| 381 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 382 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 383 | return 1.f; |
| 384 | } |
| 385 | |
| 386 | return delegate.mStrokeWidth; |
| 387 | } |
| 388 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 389 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 390 | /*package*/ static void setStrokeWidth(Paint thisPaint, float width) { |
| 391 | // get the delegate from the native int. |
| 392 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 393 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 394 | return; |
| 395 | } |
| 396 | |
| 397 | delegate.mStrokeWidth = width; |
| 398 | } |
| 399 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 400 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 401 | /*package*/ static float getStrokeMiter(Paint thisPaint) { |
| 402 | // get the delegate from the native int. |
| 403 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 404 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 405 | return 1.f; |
| 406 | } |
| 407 | |
| 408 | return delegate.mStrokeMiter; |
| 409 | } |
| 410 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 411 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 412 | /*package*/ static void setStrokeMiter(Paint thisPaint, float miter) { |
| 413 | // get the delegate from the native int. |
| 414 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 415 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 416 | return; |
| 417 | } |
| 418 | |
| 419 | delegate.mStrokeMiter = miter; |
| 420 | } |
| 421 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 422 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 423 | /*package*/ static void nSetShadowLayer(Paint thisPaint, float radius, float dx, float dy, |
| 424 | int color) { |
| 425 | // FIXME |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 426 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, |
Xavier Ducrohet | f69bb29 | 2011-01-14 16:40:43 -0800 | [diff] [blame] | 427 | "Paint.setShadowLayer is not supported.", null, null /*data*/); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 430 | @LayoutlibDelegate |
Deepanshu Gupta | bd49b12 | 2014-04-18 15:43:06 -0700 | [diff] [blame^] | 431 | /*package*/ static boolean isElegantTextHeight(Paint thisPaint) { |
| 432 | return false; |
| 433 | } |
| 434 | |
| 435 | @LayoutlibDelegate |
| 436 | /*package*/ static void setElegantTextHeight(Paint thisPaint, boolean elegant) { |
| 437 | // TODO |
| 438 | } |
| 439 | |
| 440 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 441 | /*package*/ static float getTextSize(Paint thisPaint) { |
| 442 | // get the delegate from the native int. |
| 443 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 444 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 445 | return 1.f; |
| 446 | } |
| 447 | |
| 448 | return delegate.mTextSize; |
| 449 | } |
| 450 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 451 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 452 | /*package*/ static void setTextSize(Paint thisPaint, float textSize) { |
| 453 | // get the delegate from the native int. |
| 454 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 455 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 456 | return; |
| 457 | } |
| 458 | |
| 459 | delegate.mTextSize = textSize; |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 460 | delegate.updateFontObject(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 461 | } |
| 462 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 463 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 464 | /*package*/ static float getTextScaleX(Paint thisPaint) { |
| 465 | // get the delegate from the native int. |
| 466 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 467 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 468 | return 1.f; |
| 469 | } |
| 470 | |
| 471 | return delegate.mTextScaleX; |
| 472 | } |
| 473 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 474 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 475 | /*package*/ static void setTextScaleX(Paint thisPaint, float scaleX) { |
| 476 | // get the delegate from the native int. |
| 477 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 478 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 479 | return; |
| 480 | } |
| 481 | |
| 482 | delegate.mTextScaleX = scaleX; |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 483 | delegate.updateFontObject(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 486 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 487 | /*package*/ static float getTextSkewX(Paint thisPaint) { |
| 488 | // get the delegate from the native int. |
| 489 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 490 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 491 | return 1.f; |
| 492 | } |
| 493 | |
| 494 | return delegate.mTextSkewX; |
| 495 | } |
| 496 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 497 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 498 | /*package*/ static void setTextSkewX(Paint thisPaint, float skewX) { |
| 499 | // get the delegate from the native int. |
| 500 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 501 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 502 | return; |
| 503 | } |
| 504 | |
| 505 | delegate.mTextSkewX = skewX; |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 506 | delegate.updateFontObject(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 509 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 510 | /*package*/ static float ascent(Paint thisPaint) { |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 511 | // get the delegate |
| 512 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 513 | if (delegate == null) { |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | if (delegate.mFonts.size() > 0) { |
| 518 | java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics; |
| 519 | // Android expects negative ascent so we invert the value from Java. |
| 520 | return - javaMetrics.getAscent(); |
| 521 | } |
| 522 | |
| 523 | return 0; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 526 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 527 | /*package*/ static float descent(Paint thisPaint) { |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 528 | // get the delegate |
| 529 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 530 | if (delegate == null) { |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | if (delegate.mFonts.size() > 0) { |
| 535 | java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics; |
| 536 | return javaMetrics.getDescent(); |
| 537 | } |
| 538 | |
| 539 | return 0; |
| 540 | |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 543 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 544 | /*package*/ static float getFontMetrics(Paint thisPaint, FontMetrics metrics) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 545 | // get the delegate |
| 546 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 547 | if (delegate == null) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 548 | return 0; |
| 549 | } |
| 550 | |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 551 | return delegate.getFontMetrics(metrics); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 554 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 555 | /*package*/ static int getFontMetricsInt(Paint thisPaint, FontMetricsInt fmi) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 556 | // get the delegate |
| 557 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 558 | if (delegate == null) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | if (delegate.mFonts.size() > 0) { |
| 563 | java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics; |
| 564 | if (fmi != null) { |
| 565 | // Android expects negative ascent so we invert the value from Java. |
| 566 | fmi.top = - javaMetrics.getMaxAscent(); |
| 567 | fmi.ascent = - javaMetrics.getAscent(); |
| 568 | fmi.descent = javaMetrics.getDescent(); |
| 569 | fmi.bottom = javaMetrics.getMaxDescent(); |
| 570 | fmi.leading = javaMetrics.getLeading(); |
| 571 | } |
| 572 | |
| 573 | return javaMetrics.getHeight(); |
| 574 | } |
| 575 | |
| 576 | return 0; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 579 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 580 | /*package*/ static float native_measureText(Paint thisPaint, char[] text, int index, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 581 | int count, int bidiFlags) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 582 | // get the delegate |
| 583 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 584 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 585 | return 0; |
| 586 | } |
| 587 | |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 588 | RectF bounds = delegate.measureText(text, index, count, isRtl(bidiFlags)); |
| 589 | return bounds.right - bounds.left; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 592 | @LayoutlibDelegate |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 593 | /*package*/ static float native_measureText(Paint thisPaint, String text, int start, int end, |
| 594 | int bidiFlags) { |
| 595 | return native_measureText(thisPaint, text.toCharArray(), start, end - start, bidiFlags); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 596 | } |
| 597 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 598 | @LayoutlibDelegate |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 599 | /*package*/ static float native_measureText(Paint thisPaint, String text, int bidiFlags) { |
| 600 | return native_measureText(thisPaint, text.toCharArray(), 0, text.length(), bidiFlags); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 603 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 604 | /*package*/ static int native_breakText(Paint thisPaint, char[] text, int index, int count, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 605 | float maxWidth, int bidiFlags, float[] measuredWidth) { |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 606 | |
| 607 | // get the delegate |
| 608 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 609 | if (delegate == null) { |
| 610 | return 0; |
| 611 | } |
| 612 | |
| 613 | int inc = count > 0 ? 1 : -1; |
| 614 | |
| 615 | int measureIndex = 0; |
| 616 | float measureAcc = 0; |
| 617 | for (int i = index; i != index + count; i += inc, measureIndex++) { |
| 618 | int start, end; |
| 619 | if (i < index) { |
| 620 | start = i; |
| 621 | end = index; |
| 622 | } else { |
| 623 | start = index; |
| 624 | end = i; |
| 625 | } |
| 626 | |
| 627 | // measure from start to end |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 628 | RectF bounds = delegate.measureText(text, start, end - start + 1, isRtl(bidiFlags)); |
| 629 | float res = bounds.right - bounds.left; |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 630 | |
| 631 | if (measuredWidth != null) { |
| 632 | measuredWidth[measureIndex] = res; |
| 633 | } |
| 634 | |
| 635 | measureAcc += res; |
| 636 | if (res > maxWidth) { |
| 637 | // we should not return this char index, but since it's 0-based |
| 638 | // and we need to return a count, we simply return measureIndex; |
| 639 | return measureIndex; |
| 640 | } |
| 641 | |
| 642 | } |
| 643 | |
| 644 | return measureIndex; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 645 | } |
| 646 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 647 | @LayoutlibDelegate |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 648 | /*package*/ static int native_breakText(Paint thisPaint, String text, boolean measureForwards, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 649 | float maxWidth, int bidiFlags, float[] measuredWidth) { |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 650 | return native_breakText(thisPaint, text.toCharArray(), 0, text.length(), maxWidth, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 651 | bidiFlags, measuredWidth); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 654 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 655 | /*package*/ static long native_init() { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 656 | Paint_Delegate newDelegate = new Paint_Delegate(); |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 657 | return sManager.addNewDelegate(newDelegate); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 658 | } |
| 659 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 660 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 661 | /*package*/ static long native_initWithPaint(long paint) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 662 | // get the delegate from the native int. |
| 663 | Paint_Delegate delegate = sManager.getDelegate(paint); |
| 664 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | Paint_Delegate newDelegate = new Paint_Delegate(delegate); |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 669 | return sManager.addNewDelegate(newDelegate); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 670 | } |
| 671 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 672 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 673 | /*package*/ static void native_reset(long native_object) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 674 | // get the delegate from the native int. |
| 675 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 676 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 677 | return; |
| 678 | } |
| 679 | |
| 680 | delegate.reset(); |
| 681 | } |
| 682 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 683 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 684 | /*package*/ static void native_set(long native_dst, long native_src) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 685 | // get the delegate from the native int. |
| 686 | Paint_Delegate delegate_dst = sManager.getDelegate(native_dst); |
| 687 | if (delegate_dst == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 688 | return; |
| 689 | } |
| 690 | |
| 691 | // get the delegate from the native int. |
| 692 | Paint_Delegate delegate_src = sManager.getDelegate(native_src); |
| 693 | if (delegate_src == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 694 | return; |
| 695 | } |
| 696 | |
| 697 | delegate_dst.set(delegate_src); |
| 698 | } |
| 699 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 700 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 701 | /*package*/ static int native_getStyle(long native_object) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 702 | // get the delegate from the native int. |
| 703 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 704 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | return delegate.mStyle; |
| 709 | } |
| 710 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 711 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 712 | /*package*/ static void native_setStyle(long native_object, int style) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 713 | // get the delegate from the native int. |
| 714 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 715 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 716 | return; |
| 717 | } |
| 718 | |
| 719 | delegate.mStyle = style; |
| 720 | } |
| 721 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 722 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 723 | /*package*/ static int native_getStrokeCap(long native_object) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 724 | // get the delegate from the native int. |
| 725 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 726 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 727 | return 0; |
| 728 | } |
| 729 | |
| 730 | return delegate.mCap; |
| 731 | } |
| 732 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 733 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 734 | /*package*/ static void native_setStrokeCap(long native_object, int cap) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 735 | // get the delegate from the native int. |
| 736 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 737 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 738 | return; |
| 739 | } |
| 740 | |
| 741 | delegate.mCap = cap; |
| 742 | } |
| 743 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 744 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 745 | /*package*/ static int native_getStrokeJoin(long native_object) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 746 | // get the delegate from the native int. |
| 747 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 748 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | return delegate.mJoin; |
| 753 | } |
| 754 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 755 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 756 | /*package*/ static void native_setStrokeJoin(long native_object, int join) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 757 | // get the delegate from the native int. |
| 758 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 759 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 760 | return; |
| 761 | } |
| 762 | |
| 763 | delegate.mJoin = join; |
| 764 | } |
| 765 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 766 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 767 | /*package*/ static boolean native_getFillPath(long native_object, long src, long dst) { |
Xavier Ducrohet | b976124 | 2010-12-23 10:22:14 -0800 | [diff] [blame] | 768 | Paint_Delegate paint = sManager.getDelegate(native_object); |
| 769 | if (paint == null) { |
| 770 | return false; |
| 771 | } |
| 772 | |
| 773 | Path_Delegate srcPath = Path_Delegate.getDelegate(src); |
| 774 | if (srcPath == null) { |
| 775 | return true; |
| 776 | } |
| 777 | |
| 778 | Path_Delegate dstPath = Path_Delegate.getDelegate(dst); |
| 779 | if (dstPath == null) { |
| 780 | return true; |
| 781 | } |
| 782 | |
| 783 | Stroke stroke = paint.getJavaStroke(); |
| 784 | Shape strokeShape = stroke.createStrokedShape(srcPath.getJavaShape()); |
| 785 | |
| 786 | dstPath.setJavaShape(strokeShape); |
| 787 | |
| 788 | // FIXME figure out the return value? |
| 789 | return true; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 790 | } |
| 791 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 792 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 793 | /*package*/ static long native_setShader(long native_object, long shader) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 794 | // get the delegate from the native int. |
| 795 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 796 | if (delegate == null) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 797 | return shader; |
| 798 | } |
| 799 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 800 | delegate.mShader = Shader_Delegate.getDelegate(shader); |
| 801 | |
| 802 | return shader; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 803 | } |
| 804 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 805 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 806 | /*package*/ static long native_setColorFilter(long native_object, long filter) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 807 | // get the delegate from the native int. |
| 808 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 809 | if (delegate == null) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 810 | return filter; |
| 811 | } |
| 812 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 813 | delegate.mColorFilter = ColorFilter_Delegate.getDelegate(filter);; |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 814 | |
| 815 | // since none of those are supported, display a fidelity warning right away |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 816 | if (delegate.mColorFilter != null && delegate.mColorFilter.isSupported() == false) { |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 817 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_COLORFILTER, |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 818 | delegate.mColorFilter.getSupportMessage(), null, null /*data*/); |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | return filter; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 822 | } |
| 823 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 824 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 825 | /*package*/ static long native_setXfermode(long native_object, long xfermode) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 826 | // get the delegate from the native int. |
| 827 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 828 | if (delegate == null) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 829 | return xfermode; |
| 830 | } |
| 831 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 832 | delegate.mXfermode = Xfermode_Delegate.getDelegate(xfermode); |
| 833 | |
| 834 | return xfermode; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 837 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 838 | /*package*/ static long native_setPathEffect(long native_object, long effect) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 839 | // get the delegate from the native int. |
| 840 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 841 | if (delegate == null) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 842 | return effect; |
| 843 | } |
| 844 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 845 | delegate.mPathEffect = PathEffect_Delegate.getDelegate(effect); |
| 846 | |
| 847 | return effect; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 850 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 851 | /*package*/ static long native_setMaskFilter(long native_object, long maskfilter) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 852 | // get the delegate from the native int. |
| 853 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 854 | if (delegate == null) { |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 855 | return maskfilter; |
| 856 | } |
| 857 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 858 | delegate.mMaskFilter = MaskFilter_Delegate.getDelegate(maskfilter); |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 859 | |
| 860 | // since none of those are supported, display a fidelity warning right away |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 861 | if (delegate.mMaskFilter != null && delegate.mMaskFilter.isSupported() == false) { |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 862 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER, |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 863 | delegate.mMaskFilter.getSupportMessage(), null, null /*data*/); |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | return maskfilter; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 869 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 870 | /*package*/ static long native_setTypeface(long native_object, long typeface) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 871 | // get the delegate from the native int. |
| 872 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 873 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 874 | return 0; |
| 875 | } |
| 876 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 877 | delegate.mTypeface = Typeface_Delegate.getDelegate(typeface); |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 878 | delegate.updateFontObject(); |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 879 | return typeface; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 880 | } |
| 881 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 882 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 883 | /*package*/ static long native_setRasterizer(long native_object, long rasterizer) { |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 884 | // get the delegate from the native int. |
| 885 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 886 | if (delegate == null) { |
| 887 | return rasterizer; |
| 888 | } |
| 889 | |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 890 | delegate.mRasterizer = Rasterizer_Delegate.getDelegate(rasterizer); |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 891 | |
| 892 | // since none of those are supported, display a fidelity warning right away |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 893 | if (delegate.mRasterizer != null && delegate.mRasterizer.isSupported() == false) { |
Xavier Ducrohet | 3f9b037 | 2011-01-13 10:59:34 -0800 | [diff] [blame] | 894 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_RASTERIZER, |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 895 | delegate.mRasterizer.getSupportMessage(), null, null /*data*/); |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | return rasterizer; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 899 | } |
| 900 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 901 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 902 | /*package*/ static int native_getTextAlign(long native_object) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 903 | // get the delegate from the native int. |
| 904 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 905 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 906 | return 0; |
| 907 | } |
| 908 | |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 909 | return delegate.mTextAlign; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 912 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 913 | /*package*/ static void native_setTextAlign(long native_object, int align) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 914 | // get the delegate from the native int. |
| 915 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 916 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 917 | return; |
| 918 | } |
| 919 | |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 920 | delegate.mTextAlign = align; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 923 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 924 | /*package*/ static void native_setTextLocale(long native_object, String locale) { |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 925 | // get the delegate from the native int. |
| 926 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 927 | if (delegate == null) { |
| 928 | return; |
| 929 | } |
| 930 | |
| 931 | delegate.setTextLocale(locale); |
| 932 | } |
| 933 | |
| 934 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 935 | /*package*/ static int native_getTextWidths(long native_object, char[] text, int index, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 936 | int count, int bidiFlags, float[] widths) { |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 937 | // get the delegate from the native int. |
| 938 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
| 939 | if (delegate == null) { |
| 940 | return 0; |
| 941 | } |
| 942 | |
| 943 | if (delegate.mFonts.size() > 0) { |
| 944 | // FIXME: handle multi-char characters (see measureText) |
| 945 | float totalAdvance = 0; |
| 946 | for (int i = 0; i < count; i++) { |
| 947 | char c = text[i + index]; |
| 948 | boolean found = false; |
| 949 | for (FontInfo info : delegate.mFonts) { |
| 950 | if (info.mFont.canDisplay(c)) { |
| 951 | float adv = info.mMetrics.charWidth(c); |
| 952 | totalAdvance += adv; |
| 953 | if (widths != null) { |
| 954 | widths[i] = adv; |
| 955 | } |
| 956 | |
| 957 | found = true; |
| 958 | break; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | if (found == false) { |
| 963 | // no advance for this char. |
| 964 | if (widths != null) { |
| 965 | widths[i] = 0.f; |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | return (int) totalAdvance; |
| 971 | } |
| 972 | |
Xavier Ducrohet | 1eeaea0 | 2011-02-09 19:39:52 -0800 | [diff] [blame] | 973 | return 0; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 976 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 977 | /*package*/ static int native_getTextWidths(long native_object, String text, int start, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 978 | int end, int bidiFlags, float[] widths) { |
| 979 | return native_getTextWidths(native_object, text.toCharArray(), start, end - start, |
| 980 | bidiFlags, widths); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 981 | } |
| 982 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 983 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 984 | /* package */static int native_getTextGlyphs(long native_object, String text, int start, |
Xavier Ducrohet | 81efa7f | 2011-06-15 14:43:42 -0700 | [diff] [blame] | 985 | int end, int contextStart, int contextEnd, int flags, char[] glyphs) { |
| 986 | // FIXME |
| 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 991 | /*package*/ static float native_getTextRunAdvances(long native_object, |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 992 | char[] text, int index, int count, int contextIndex, int contextCount, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 993 | int flags, float[] advances, int advancesIndex) { |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 994 | |
| 995 | if (advances != null) |
| 996 | for (int i = advancesIndex; i< advancesIndex+count; i++) |
| 997 | advances[i]=0; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 998 | // get the delegate from the native int. |
| 999 | Paint_Delegate delegate = sManager.getDelegate(native_object); |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1000 | if (delegate == null || delegate.mFonts == null || delegate.mFonts.size() == 0) { |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1001 | return 0.f; |
| 1002 | } |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1003 | boolean isRtl = isRtl(flags); |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1004 | |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1005 | int limit = index + count; |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 1006 | RectF bounds = new BidiRenderer(null, delegate, text).renderText( |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1007 | index, limit, isRtl, advances, advancesIndex, false, 0, 0); |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 1008 | return bounds.right - bounds.left; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1009 | } |
| 1010 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1011 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1012 | /*package*/ static float native_getTextRunAdvances(long native_object, |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1013 | String text, int start, int end, int contextStart, int contextEnd, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 1014 | int flags, float[] advances, int advancesIndex) { |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1015 | // FIXME: support contextStart and contextEnd |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1016 | int count = end - start; |
| 1017 | char[] buffer = TemporaryBuffer.obtain(count); |
| 1018 | TextUtils.getChars(text, start, end, buffer, 0); |
| 1019 | |
| 1020 | return native_getTextRunAdvances(native_object, buffer, 0, count, contextStart, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 1021 | contextEnd - contextStart, flags, advances, advancesIndex); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1024 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 1025 | /*package*/ static int native_getTextRunCursor(Paint thisPaint, long native_object, char[] text, |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1026 | int contextStart, int contextLength, int flags, int offset, int cursorOpt) { |
| 1027 | // FIXME |
Xavier Ducrohet | 1eeaea0 | 2011-02-09 19:39:52 -0800 | [diff] [blame] | 1028 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, |
| 1029 | "Paint.getTextRunCursor is not supported.", null, null /*data*/); |
| 1030 | return 0; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1031 | } |
| 1032 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1033 | @LayoutlibDelegate |
Deepanshu Gupta | f9a8235 | 2014-02-21 16:22:10 -0800 | [diff] [blame] | 1034 | /*package*/ static int native_getTextRunCursor(Paint thisPaint, long native_object, String text, |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1035 | int contextStart, int contextEnd, int flags, int offset, int cursorOpt) { |
| 1036 | // FIXME |
Xavier Ducrohet | 1eeaea0 | 2011-02-09 19:39:52 -0800 | [diff] [blame] | 1037 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, |
| 1038 | "Paint.getTextRunCursor is not supported.", null, null /*data*/); |
| 1039 | return 0; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1040 | } |
| 1041 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1042 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1043 | /*package*/ static void native_getTextPath(long native_object, int bidiFlags, |
| 1044 | char[] text, int index, int count, float x, float y, long path) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1045 | // FIXME |
Xavier Ducrohet | 1eeaea0 | 2011-02-09 19:39:52 -0800 | [diff] [blame] | 1046 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, |
| 1047 | "Paint.getTextPath is not supported.", null, null /*data*/); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1048 | } |
| 1049 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1050 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1051 | /*package*/ static void native_getTextPath(long native_object, int bidiFlags, |
| 1052 | String text, int start, int end, float x, float y, long path) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1053 | // FIXME |
Xavier Ducrohet | 1eeaea0 | 2011-02-09 19:39:52 -0800 | [diff] [blame] | 1054 | Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, |
| 1055 | "Paint.getTextPath is not supported.", null, null /*data*/); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1058 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1059 | /*package*/ static void nativeGetStringBounds(long nativePaint, String text, int start, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 1060 | int end, int bidiFlags, Rect bounds) { |
| 1061 | nativeGetCharArrayBounds(nativePaint, text.toCharArray(), start, end - start, bidiFlags, |
| 1062 | bounds); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1065 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1066 | /*package*/ static void nativeGetCharArrayBounds(long nativePaint, char[] text, int index, |
Deepanshu Gupta | c398f18 | 2013-05-23 15:20:04 -0700 | [diff] [blame] | 1067 | int count, int bidiFlags, Rect bounds) { |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 1068 | |
| 1069 | // get the delegate from the native int. |
| 1070 | Paint_Delegate delegate = sManager.getDelegate(nativePaint); |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1071 | if (delegate == null || delegate.mFonts == null || delegate.mFonts.size() == 0) { |
Xavier Ducrohet | f4d52a6 | 2011-02-23 09:53:56 -0800 | [diff] [blame] | 1072 | return; |
| 1073 | } |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 1074 | delegate.measureText(text, index, count, isRtl(bidiFlags)).roundOut(bounds); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
Xavier Ducrohet | 94c80bf | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 1077 | @LayoutlibDelegate |
Narayan Kamath | 633d688 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 1078 | /*package*/ static void finalizer(long nativePaint) { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 1079 | sManager.removeJavaReferenceFor(nativePaint); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | // ---- Private delegate/helper methods ---- |
| 1083 | |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 1084 | /*package*/ Paint_Delegate() { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1085 | reset(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | private Paint_Delegate(Paint_Delegate paint) { |
| 1089 | set(paint); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | private void set(Paint_Delegate paint) { |
| 1093 | mFlags = paint.mFlags; |
| 1094 | mColor = paint.mColor; |
| 1095 | mStyle = paint.mStyle; |
| 1096 | mCap = paint.mCap; |
| 1097 | mJoin = paint.mJoin; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1098 | mTextAlign = paint.mTextAlign; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1099 | mTypeface = paint.mTypeface; |
| 1100 | mStrokeWidth = paint.mStrokeWidth; |
| 1101 | mStrokeMiter = paint.mStrokeMiter; |
| 1102 | mTextSize = paint.mTextSize; |
| 1103 | mTextScaleX = paint.mTextScaleX; |
| 1104 | mTextSkewX = paint.mTextSkewX; |
Xavier Ducrohet | a313b65 | 2010-11-01 18:45:20 -0700 | [diff] [blame] | 1105 | mXfermode = paint.mXfermode; |
| 1106 | mColorFilter = paint.mColorFilter; |
| 1107 | mShader = paint.mShader; |
| 1108 | mPathEffect = paint.mPathEffect; |
| 1109 | mMaskFilter = paint.mMaskFilter; |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 1110 | mRasterizer = paint.mRasterizer; |
Xavier Ducrohet | b6f7f57 | 2011-08-22 13:13:16 -0700 | [diff] [blame] | 1111 | mHintingMode = paint.mHintingMode; |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 1112 | updateFontObject(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | private void reset() { |
| 1116 | mFlags = Paint.DEFAULT_PAINT_FLAGS; |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 1117 | mColor = 0xFF000000; |
Xavier Ducrohet | 6622522 | 2010-12-21 01:33:04 -0800 | [diff] [blame] | 1118 | mStyle = Paint.Style.FILL.nativeInt; |
| 1119 | mCap = Paint.Cap.BUTT.nativeInt; |
| 1120 | mJoin = Paint.Join.MITER.nativeInt; |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1121 | mTextAlign = 0; |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 1122 | mTypeface = Typeface_Delegate.getDelegate(Typeface.sDefaults[0].native_instance); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1123 | mStrokeWidth = 1.f; |
Xavier Ducrohet | cf2030c | 2010-12-21 06:20:28 -0800 | [diff] [blame] | 1124 | mStrokeMiter = 4.f; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1125 | mTextSize = 20.f; |
| 1126 | mTextScaleX = 1.f; |
| 1127 | mTextSkewX = 0.f; |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 1128 | mXfermode = null; |
| 1129 | mColorFilter = null; |
| 1130 | mShader = null; |
| 1131 | mPathEffect = null; |
| 1132 | mMaskFilter = null; |
| 1133 | mRasterizer = null; |
Xavier Ducrohet | 42e2b28 | 2010-12-06 11:08:37 -0800 | [diff] [blame] | 1134 | updateFontObject(); |
Xavier Ducrohet | b6f7f57 | 2011-08-22 13:13:16 -0700 | [diff] [blame] | 1135 | mHintingMode = Paint.HINTING_ON; |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | /** |
| 1139 | * Update the {@link Font} object from the typeface, text size and scaling |
| 1140 | */ |
Xavier Ducrohet | a6e51d5 | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 1141 | @SuppressWarnings("deprecation") |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1142 | private void updateFontObject() { |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 1143 | if (mTypeface != null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1144 | // Get the fonts from the TypeFace object. |
Xavier Ducrohet | 9167279 | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 1145 | List<Font> fonts = mTypeface.getFonts(); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1146 | |
| 1147 | // create new font objects as well as FontMetrics, based on the current text size |
| 1148 | // and skew info. |
| 1149 | ArrayList<FontInfo> infoList = new ArrayList<FontInfo>(fonts.size()); |
| 1150 | for (Font font : fonts) { |
| 1151 | FontInfo info = new FontInfo(); |
| 1152 | info.mFont = font.deriveFont(mTextSize); |
| 1153 | if (mTextScaleX != 1.0 || mTextSkewX != 0) { |
| 1154 | // TODO: support skew |
| 1155 | info.mFont = info.mFont.deriveFont(new AffineTransform( |
Xavier Ducrohet | 8f10910 | 2011-10-04 19:39:18 -0700 | [diff] [blame] | 1156 | mTextScaleX, mTextSkewX, 0, 1, 0, 0)); |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1157 | } |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1158 | // The metrics here don't have anti-aliasing set. |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1159 | info.mMetrics = Toolkit.getDefaultToolkit().getFontMetrics(info.mFont); |
| 1160 | |
| 1161 | infoList.add(info); |
| 1162 | } |
| 1163 | |
| 1164 | mFonts = Collections.unmodifiableList(infoList); |
| 1165 | } |
| 1166 | } |
| 1167 | |
Deepanshu Gupta | eb998d3 | 2014-01-07 11:58:44 -0800 | [diff] [blame] | 1168 | /*package*/ RectF measureText(char[] text, int index, int count, boolean isRtl) { |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1169 | return new BidiRenderer(null, this, text).renderText( |
| 1170 | index, index + count, isRtl, null, 0, false, 0, 0); |
Xavier Ducrohet | 37f2180 | 2010-11-01 16:17:18 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 1173 | private float getFontMetrics(FontMetrics metrics) { |
| 1174 | if (mFonts.size() > 0) { |
| 1175 | java.awt.FontMetrics javaMetrics = mFonts.get(0).mMetrics; |
| 1176 | if (metrics != null) { |
| 1177 | // Android expects negative ascent so we invert the value from Java. |
| 1178 | metrics.top = - javaMetrics.getMaxAscent(); |
| 1179 | metrics.ascent = - javaMetrics.getAscent(); |
| 1180 | metrics.descent = javaMetrics.getDescent(); |
| 1181 | metrics.bottom = javaMetrics.getMaxDescent(); |
| 1182 | metrics.leading = javaMetrics.getLeading(); |
| 1183 | } |
| 1184 | |
| 1185 | return javaMetrics.getHeight(); |
| 1186 | } |
| 1187 | |
| 1188 | return 0; |
| 1189 | } |
| 1190 | |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 1191 | private void setTextLocale(String locale) { |
| 1192 | mLocale = new Locale(locale); |
| 1193 | } |
Xavier Ducrohet | df67eab | 2010-12-13 16:42:01 -0800 | [diff] [blame] | 1194 | |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1195 | private static void setFlag(Paint thisPaint, int flagMask, boolean flagValue) { |
| 1196 | // get the delegate from the native int. |
| 1197 | Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); |
| 1198 | if (delegate == null) { |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1199 | return; |
| 1200 | } |
| 1201 | |
| 1202 | if (flagValue) { |
| 1203 | delegate.mFlags |= flagMask; |
| 1204 | } else { |
| 1205 | delegate.mFlags &= ~flagMask; |
| 1206 | } |
| 1207 | } |
Xavier Ducrohet | 43526ab | 2012-04-23 17:41:37 -0700 | [diff] [blame] | 1208 | |
Deepanshu Gupta | a6b207a | 2013-07-12 11:38:05 -0700 | [diff] [blame] | 1209 | private static boolean isRtl(int flag) { |
| 1210 | switch(flag) { |
| 1211 | case Paint.BIDI_RTL: |
| 1212 | case Paint.BIDI_FORCE_RTL: |
| 1213 | case Paint.BIDI_DEFAULT_RTL: |
| 1214 | return true; |
| 1215 | default: |
| 1216 | return false; |
| 1217 | } |
| 1218 | } |
Xavier Ducrohet | ef44aea | 2010-10-28 11:52:00 -0700 | [diff] [blame] | 1219 | } |