Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/c/sk_surface.cpp

Issue 1261953006: C API: remove dead code, simplify boilerplate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/c/sk_types.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 size_t sk_data_get_size(const sk_data_t* cdata) { 619 size_t sk_data_get_size(const sk_data_t* cdata) {
620 return AsData(cdata)->size(); 620 return AsData(cdata)->size();
621 } 621 }
622 622
623 const void* sk_data_get_data(const sk_data_t* cdata) { 623 const void* sk_data_get_data(const sk_data_t* cdata) {
624 return AsData(cdata)->data(); 624 return AsData(cdata)->data();
625 } 625 }
626 626
627 //////////////////////////////////////////////////////////////////////////////// /////////// 627 //////////////////////////////////////////////////////////////////////////////// ///////////
628 //////////////////////////////////////////////////////////////////////////////// ///////////
629
630 void sk_test_capi(SkCanvas* canvas) {
631 sk_imageinfo_t cinfo;
632 cinfo.width = 100;
633 cinfo.height = 100;
634 cinfo.colorType = (sk_colortype_t)kN32_SkColorType;
635 cinfo.alphaType = (sk_alphatype_t)kPremul_SkAlphaType;
636
637 sk_surfaceprops_t surfaceprops;
638 surfaceprops.pixelGeometry = UNKNOWN_SK_PIXELGEOMETRY;
639
640 sk_surface_t* csurface = sk_surface_new_raster(&cinfo, &surfaceprops);
641 sk_canvas_t* ccanvas = sk_surface_get_canvas(csurface);
642
643 sk_paint_t* cpaint = sk_paint_new();
644 sk_paint_set_antialias(cpaint, true);
645 sk_paint_set_color(cpaint, 0xFFFF0000);
646
647 sk_rect_t cr = { 5, 5, 95, 95 };
648 sk_canvas_draw_oval(ccanvas, &cr, cpaint);
649
650 cr.left += 25;
651 cr.top += 25;
652 cr.right -= 25;
653 cr.bottom -= 25;
654 sk_paint_set_color(cpaint, 0xFF00FF00);
655 sk_canvas_draw_rect(ccanvas, &cr, cpaint);
656
657 sk_path_t* cpath = sk_path_new();
658 sk_path_move_to(cpath, 50, 50);
659 sk_path_line_to(cpath, 100, 100);
660 sk_path_line_to(cpath, 50, 100);
661 sk_path_close(cpath);
662
663 sk_canvas_draw_path(ccanvas, cpath, cpaint);
664
665 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface);
666
667 // HERE WE CROSS THE C..C++ boundary
668 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL);
669
670 sk_path_delete(cpath);
671 sk_paint_delete(cpaint);
672 sk_image_unref(cimage);
673 sk_surface_unref(csurface);
674 }
OLDNEW
« no previous file with comments | « include/c/sk_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698