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" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 } | 155 } |
156 | 156 |
157 static sk_rect_t ToRect(const SkRect& rect) { | 157 static sk_rect_t ToRect(const SkRect& rect) { |
158 return reinterpret_cast<const sk_rect_t&>(rect); | 158 return reinterpret_cast<const sk_rect_t&>(rect); |
159 } | 159 } |
160 | 160 |
161 static const SkRect& AsRect(const sk_rect_t& crect) { | 161 static const SkRect& AsRect(const sk_rect_t& crect) { |
162 return reinterpret_cast<const SkRect&>(crect); | 162 return reinterpret_cast<const SkRect&>(crect); |
163 } | 163 } |
164 | 164 |
165 static const SkRect* AsRect(const sk_rect_t* crect) { | |
166 return reinterpret_cast<const SkRect*>(crect); | |
167 } | |
168 | |
169 static const SkPath& AsPath(const sk_path_t& cpath) { | 165 static const SkPath& AsPath(const sk_path_t& cpath) { |
170 return reinterpret_cast<const SkPath&>(cpath); | 166 return reinterpret_cast<const SkPath&>(cpath); |
171 } | 167 } |
172 | 168 |
173 static SkPath* as_path(sk_path_t* cpath) { | 169 static SkPath* as_path(sk_path_t* cpath) { |
174 return reinterpret_cast<SkPath*>(cpath); | 170 return reinterpret_cast<SkPath*>(cpath); |
175 } | 171 } |
176 | 172 |
177 static const SkImage* AsImage(const sk_image_t* cimage) { | 173 static const SkImage* AsImage(const sk_image_t* cimage) { |
178 return reinterpret_cast<const SkImage*>(cimage); | 174 return reinterpret_cast<const SkImage*>(cimage); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 } | 384 } |
389 | 385 |
390 void sk_canvas_draw_path(sk_canvas_t* ccanvas, const sk_path_t* cpath, const sk_ paint_t* cpaint) { | 386 void sk_canvas_draw_path(sk_canvas_t* ccanvas, const sk_path_t* cpath, const sk_ paint_t* cpaint) { |
391 AsCanvas(ccanvas)->drawPath(AsPath(*cpath), AsPaint(*cpaint)); | 387 AsCanvas(ccanvas)->drawPath(AsPath(*cpath), AsPaint(*cpaint)); |
392 } | 388 } |
393 | 389 |
394 void sk_canvas_draw_image(sk_canvas_t* ccanvas, const sk_image_t* cimage, float x, float y, | 390 void sk_canvas_draw_image(sk_canvas_t* ccanvas, const sk_image_t* cimage, float x, float y, |
395 const sk_paint_t* cpaint) { | 391 const sk_paint_t* cpaint) { |
396 AsCanvas(ccanvas)->drawImage(AsImage(cimage), x, y, AsPaint(cpaint)); | 392 AsCanvas(ccanvas)->drawImage(AsImage(cimage), x, y, AsPaint(cpaint)); |
397 } | 393 } |
398 | 394 |
robertphillips
2015/08/06 17:23:00
Hmmm, we don't want to make the C-api match ?
| |
399 void sk_canvas_draw_image_rect(sk_canvas_t* ccanvas, const sk_image_t* cimage, | 395 void sk_canvas_draw_image_rect(sk_canvas_t* ccanvas, const sk_image_t* cimage, |
400 const sk_rect_t* csrcR, const sk_rect_t* cdstR, | 396 const sk_rect_t* csrcR, const sk_rect_t* cdstR, |
401 const sk_paint_t* cpaint) { | 397 const sk_paint_t* cpaint) { |
402 AsCanvas(ccanvas)->drawImageRect(AsImage(cimage), AsRect(csrcR), AsRect(*cds tR), AsPaint(cpaint)); | 398 SkCanvas* canvas = AsCanvas(ccanvas); |
399 const SkImage* image = AsImage(cimage); | |
400 const SkRect& dst = AsRect(*cdstR); | |
401 const SkPaint* paint = AsPaint(cpaint); | |
402 | |
403 if (csrcR) { | |
404 canvas->drawImageRect(image, AsRect(*csrcR), dst, paint); | |
405 } else { | |
406 canvas->drawImageRect(image, dst, paint); | |
407 } | |
403 } | 408 } |
404 | 409 |
405 void sk_canvas_draw_picture(sk_canvas_t* ccanvas, const sk_picture_t* cpicture, | 410 void sk_canvas_draw_picture(sk_canvas_t* ccanvas, const sk_picture_t* cpicture, |
406 const sk_matrix_t* cmatrix, const sk_paint_t* cpaint ) { | 411 const sk_matrix_t* cmatrix, const sk_paint_t* cpaint ) { |
407 const SkMatrix* matrixPtr = NULL; | 412 const SkMatrix* matrixPtr = NULL; |
408 SkMatrix matrix; | 413 SkMatrix matrix; |
409 if (cmatrix) { | 414 if (cmatrix) { |
410 from_c_matrix(cmatrix, &matrix); | 415 from_c_matrix(cmatrix, &matrix); |
411 matrixPtr = &matrix; | 416 matrixPtr = &matrix; |
412 } | 417 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 | 623 |
619 size_t sk_data_get_size(const sk_data_t* cdata) { | 624 size_t sk_data_get_size(const sk_data_t* cdata) { |
620 return AsData(cdata)->size(); | 625 return AsData(cdata)->size(); |
621 } | 626 } |
622 | 627 |
623 const void* sk_data_get_data(const sk_data_t* cdata) { | 628 const void* sk_data_get_data(const sk_data_t* cdata) { |
624 return AsData(cdata)->data(); | 629 return AsData(cdata)->data(); |
625 } | 630 } |
626 | 631 |
627 //////////////////////////////////////////////////////////////////////////////// /////////// | 632 //////////////////////////////////////////////////////////////////////////////// /////////// |
OLD | NEW |