| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 State fState; | 88 State fState; |
| 89 | 89 |
| 90 // Factory method for ressurecting a StrokeDrawLooper. | 90 // Factory method for ressurecting a StrokeDrawLooper. |
| 91 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { | 91 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { |
| 92 return SkNEW_ARGS(StrokeDrawLooper, (buffer)); } | 92 return SkNEW_ARGS(StrokeDrawLooper, (buffer)); } |
| 93 | 93 |
| 94 typedef SkDrawLooper INHERITED; | 94 typedef SkDrawLooper INHERITED; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 StrokeDrawLooper::StrokeDrawLooper(SkScalar radius, SkColor color) | 97 StrokeDrawLooper::StrokeDrawLooper(SkScalar radius, SkColor color) |
| 98 : fColor(color), fRadius(radius) { | 98 : fRadius(radius), fColor(color) { |
| 99 } | 99 } |
| 100 | 100 |
| 101 void StrokeDrawLooper::init(SkCanvas* canvas, SkPaint* paint) { | 101 void StrokeDrawLooper::init(SkCanvas* canvas, SkPaint* paint) { |
| 102 fState = kBeforeEdge; | 102 fState = kBeforeEdge; |
| 103 fCanvas = canvas; | 103 fCanvas = canvas; |
| 104 fPaint = paint; | 104 fPaint = paint; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool StrokeDrawLooper::next() { | 107 bool StrokeDrawLooper::next() { |
| 108 switch (fState) { | 108 switch (fState) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return SkPaint::kRight_Align; | 168 return SkPaint::kRight_Align; |
| 169 default: | 169 default: |
| 170 return SkPaint::kLeft_Align; | 170 return SkPaint::kLeft_Align; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 CanvasPaint::CanvasPaint(ServiceLocator* service_locator) | 174 CanvasPaint::CanvasPaint(ServiceLocator* service_locator) |
| 175 : ParamObject(service_locator), | 175 : ParamObject(service_locator), |
| 176 shader_(NULL), | 176 shader_(NULL), |
| 177 needs_update_(true), | 177 needs_update_(true), |
| 178 text_align_(LEFT), |
| 178 color_(Float4(0, 0, 0, 1)), | 179 color_(Float4(0, 0, 0, 1)), |
| 179 text_align_(LEFT), | |
| 180 text_size_(10), | 180 text_size_(10), |
| 181 text_typeface_(""), |
| 182 text_style_(NORMAL), |
| 183 outline_radius_(0), |
| 184 outline_color_(Float4(0, 0, 0, 1)), |
| 181 shadow_radius_(0), | 185 shadow_radius_(0), |
| 182 shadow_color_(Float4(0, 0, 0, 1)), | |
| 183 shadow_offset_x_(0), | 186 shadow_offset_x_(0), |
| 184 shadow_offset_y_(0), | 187 shadow_offset_y_(0), |
| 185 outline_radius_(0), | 188 shadow_color_(Float4(0, 0, 0, 1)) { |
| 186 outline_color_(Float4(0, 0, 0, 1)), | |
| 187 text_style_(NORMAL), | |
| 188 text_typeface_("") { | |
| 189 sk_paint_.setAntiAlias(true); | 189 sk_paint_.setAntiAlias(true); |
| 190 } | 190 } |
| 191 | 191 |
| 192 CanvasPaint::~CanvasPaint() { | 192 CanvasPaint::~CanvasPaint() { |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Updates the native paint object with the current values of all the settings. | 195 // Updates the native paint object with the current values of all the settings. |
| 196 void CanvasPaint::UpdateNativePaint() { | 196 void CanvasPaint::UpdateNativePaint() { |
| 197 if (needs_update_) { | 197 if (needs_update_) { |
| 198 sk_paint_.setColor(Float4ToSkColor(color_)); | 198 sk_paint_.setColor(Float4ToSkColor(color_)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 #endif | 280 #endif |
| 281 } | 281 } |
| 282 | 282 |
| 283 ObjectBase::Ref CanvasPaint::Create(ServiceLocator* service_locator) { | 283 ObjectBase::Ref CanvasPaint::Create(ServiceLocator* service_locator) { |
| 284 return ObjectBase::Ref(new CanvasPaint(service_locator)); | 284 return ObjectBase::Ref(new CanvasPaint(service_locator)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 | 288 |
| 289 } // namespace o3d | 289 } // namespace o3d |
| OLD | NEW |