| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_canvas.h" | 8 #include "sk_canvas.h" |
| 9 #include "sk_data.h" | 9 #include "sk_data.h" |
| 10 #include "sk_image.h" | 10 #include "sk_image.h" |
| 11 #include "sk_paint.h" | 11 #include "sk_paint.h" |
| 12 #include "sk_path.h" | 12 #include "sk_path.h" |
| 13 #include "sk_surface.h" | 13 #include "sk_surface.h" |
| 14 #include "sk_types_priv.h" |
| 14 | 15 |
| 15 #include "SkCanvas.h" | 16 #include "SkCanvas.h" |
| 16 #include "SkData.h" | 17 #include "SkData.h" |
| 17 #include "SkImage.h" | 18 #include "SkImage.h" |
| 18 #include "SkMaskFilter.h" | 19 #include "SkMaskFilter.h" |
| 19 #include "SkMatrix.h" | 20 #include "SkMatrix.h" |
| 20 #include "SkPaint.h" | 21 #include "SkPaint.h" |
| 21 #include "SkPath.h" | 22 #include "SkPath.h" |
| 22 #include "SkPictureRecorder.h" | 23 #include "SkPictureRecorder.h" |
| 23 #include "SkSurface.h" | 24 #include "SkSurface.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 151 } |
| 151 | 152 |
| 152 static const SkImage* AsImage(const sk_image_t* cimage) { | 153 static const SkImage* AsImage(const sk_image_t* cimage) { |
| 153 return reinterpret_cast<const SkImage*>(cimage); | 154 return reinterpret_cast<const SkImage*>(cimage); |
| 154 } | 155 } |
| 155 | 156 |
| 156 static sk_image_t* ToImage(SkImage* cimage) { | 157 static sk_image_t* ToImage(SkImage* cimage) { |
| 157 return reinterpret_cast<sk_image_t*>(cimage); | 158 return reinterpret_cast<sk_image_t*>(cimage); |
| 158 } | 159 } |
| 159 | 160 |
| 160 static const SkPaint& AsPaint(const sk_paint_t& cpaint) { | |
| 161 return reinterpret_cast<const SkPaint&>(cpaint); | |
| 162 } | |
| 163 | |
| 164 static const SkPaint* AsPaint(const sk_paint_t* cpaint) { | |
| 165 return reinterpret_cast<const SkPaint*>(cpaint); | |
| 166 } | |
| 167 | |
| 168 static SkPaint* AsPaint(sk_paint_t* cpaint) { | |
| 169 return reinterpret_cast<SkPaint*>(cpaint); | |
| 170 } | |
| 171 | |
| 172 static sk_canvas_t* ToCanvas(SkCanvas* canvas) { | 161 static sk_canvas_t* ToCanvas(SkCanvas* canvas) { |
| 173 return reinterpret_cast<sk_canvas_t*>(canvas); | 162 return reinterpret_cast<sk_canvas_t*>(canvas); |
| 174 } | 163 } |
| 175 | 164 |
| 176 static SkCanvas* AsCanvas(sk_canvas_t* ccanvas) { | 165 static SkCanvas* AsCanvas(sk_canvas_t* ccanvas) { |
| 177 return reinterpret_cast<SkCanvas*>(ccanvas); | 166 return reinterpret_cast<SkCanvas*>(ccanvas); |
| 178 } | 167 } |
| 179 | 168 |
| 180 static SkMaskFilter* AsMaskFilter(sk_maskfilter_t* cfilter) { | |
| 181 return reinterpret_cast<SkMaskFilter*>(cfilter); | |
| 182 } | |
| 183 | |
| 184 static sk_maskfilter_t* ToMaskFilter(SkMaskFilter* filter) { | |
| 185 return reinterpret_cast<sk_maskfilter_t*>(filter); | |
| 186 } | |
| 187 | |
| 188 static SkShader* AsShader(sk_shader_t* cshader) { | |
| 189 return reinterpret_cast<SkShader*>(cshader); | |
| 190 } | |
| 191 | |
| 192 static SkPictureRecorder* AsPictureRecorder(sk_picture_recorder_t* crec) { | 169 static SkPictureRecorder* AsPictureRecorder(sk_picture_recorder_t* crec) { |
| 193 return reinterpret_cast<SkPictureRecorder*>(crec); | 170 return reinterpret_cast<SkPictureRecorder*>(crec); |
| 194 } | 171 } |
| 195 | 172 |
| 196 static sk_picture_recorder_t* ToPictureRecorder(SkPictureRecorder* rec) { | 173 static sk_picture_recorder_t* ToPictureRecorder(SkPictureRecorder* rec) { |
| 197 return reinterpret_cast<sk_picture_recorder_t*>(rec); | 174 return reinterpret_cast<sk_picture_recorder_t*>(rec); |
| 198 } | 175 } |
| 199 | 176 |
| 200 static const SkPicture* AsPicture(const sk_picture_t* cpic) { | 177 static const SkPicture* AsPicture(const sk_picture_t* cpic) { |
| 201 return reinterpret_cast<const SkPicture*>(cpic); | 178 return reinterpret_cast<const SkPicture*>(cpic); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 int sk_image_get_height(const sk_image_t* cimage) { | 230 int sk_image_get_height(const sk_image_t* cimage) { |
| 254 return AsImage(cimage)->height(); | 231 return AsImage(cimage)->height(); |
| 255 } | 232 } |
| 256 | 233 |
| 257 uint32_t sk_image_get_unique_id(const sk_image_t* cimage) { | 234 uint32_t sk_image_get_unique_id(const sk_image_t* cimage) { |
| 258 return AsImage(cimage)->uniqueID(); | 235 return AsImage(cimage)->uniqueID(); |
| 259 } | 236 } |
| 260 | 237 |
| 261 ////////////////////////////////////////////////////////////////////////////////
/////////// | 238 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 262 | 239 |
| 263 sk_paint_t* sk_paint_new() { | |
| 264 return (sk_paint_t*)SkNEW(SkPaint); | |
| 265 } | |
| 266 | |
| 267 void sk_paint_delete(sk_paint_t* cpaint) { | |
| 268 SkDELETE(AsPaint(cpaint)); | |
| 269 } | |
| 270 | |
| 271 bool sk_paint_is_antialias(const sk_paint_t* cpaint) { | |
| 272 return AsPaint(*cpaint).isAntiAlias(); | |
| 273 } | |
| 274 | |
| 275 void sk_paint_set_antialias(sk_paint_t* cpaint, bool aa) { | |
| 276 AsPaint(cpaint)->setAntiAlias(aa); | |
| 277 } | |
| 278 | |
| 279 sk_color_t sk_paint_get_color(const sk_paint_t* cpaint) { | |
| 280 return AsPaint(*cpaint).getColor(); | |
| 281 } | |
| 282 | |
| 283 void sk_paint_set_color(sk_paint_t* cpaint, sk_color_t c) { | |
| 284 AsPaint(cpaint)->setColor(c); | |
| 285 } | |
| 286 | |
| 287 void sk_paint_set_shader(sk_paint_t* cpaint, sk_shader_t* cshader) { | |
| 288 AsPaint(cpaint)->setShader(AsShader(cshader)); | |
| 289 } | |
| 290 | |
| 291 void sk_paint_set_maskfilter(sk_paint_t* cpaint, sk_maskfilter_t* cfilter) { | |
| 292 AsPaint(cpaint)->setMaskFilter(AsMaskFilter(cfilter)); | |
| 293 } | |
| 294 | |
| 295 ////////////////////////////////////////////////////////////////////////////////
/////////// | |
| 296 | |
| 297 sk_path_t* sk_path_new() { | 240 sk_path_t* sk_path_new() { |
| 298 return (sk_path_t*)SkNEW(SkPath); | 241 return (sk_path_t*)SkNEW(SkPath); |
| 299 } | 242 } |
| 300 | 243 |
| 301 void sk_path_delete(sk_path_t* cpath) { | 244 void sk_path_delete(sk_path_t* cpath) { |
| 302 SkDELETE(as_path(cpath)); | 245 SkDELETE(as_path(cpath)); |
| 303 } | 246 } |
| 304 | 247 |
| 305 void sk_path_move_to(sk_path_t* cpath, float x, float y) { | 248 void sk_path_move_to(sk_path_t* cpath, float x, float y) { |
| 306 as_path(cpath)->moveTo(x, y); | 249 as_path(cpath)->moveTo(x, y); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); | 623 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); |
| 681 | 624 |
| 682 // HERE WE CROSS THE C..C++ boundary | 625 // HERE WE CROSS THE C..C++ boundary |
| 683 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); | 626 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); |
| 684 | 627 |
| 685 sk_path_delete(cpath); | 628 sk_path_delete(cpath); |
| 686 sk_paint_delete(cpaint); | 629 sk_paint_delete(cpaint); |
| 687 sk_image_unref(cimage); | 630 sk_image_unref(cimage); |
| 688 sk_surface_unref(csurface); | 631 sk_surface_unref(csurface); |
| 689 } | 632 } |
| OLD | NEW |