comparison src/graph_engine_skia.cpp @ 513:6394a1e33b2f Android_Skia

Rewind/reset path and subpath. In previously, only path was reseted for a new path. But, subpath should also be reseted/rewinded for first relative moveto.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 01 Dec 2009 22:55:27 +0800
parents d186d1e24458
children 663d361eb3b8
comparison
equal deleted inserted replaced
512:d186d1e24458 513:6394a1e33b2f
582 int mbe_in_stroke(mbe_t *canvas, co_aix x, co_aix y) { 582 int mbe_in_stroke(mbe_t *canvas, co_aix x, co_aix y) {
583 return 0; 583 return 0;
584 } 584 }
585 585
586 void mbe_new_path(mbe_t *canvas) { 586 void mbe_new_path(mbe_t *canvas) {
587 canvas->subpath->reset(); 587 canvas->subpath->rewind();
588 canvas->path->rewind();
588 } 589 }
589 590
590 void mbe_curve_to(mbe_t *canvas, co_aix x1, co_aix y1, 591 void mbe_curve_to(mbe_t *canvas, co_aix x1, co_aix y1,
591 co_aix x2, co_aix y2, 592 co_aix x2, co_aix y2,
592 co_aix x3, co_aix y3) { 593 co_aix x3, co_aix y3) {
648 649
649 canvas->canvas->drawPath(*path, *paint); 650 canvas->canvas->drawPath(*path, *paint);
650 651
651 _finish_paint(canvas); 652 _finish_paint(canvas);
652 653
653 path->reset(); 654 path->rewind();
655 canvas->subpath->rewind();
654 } 656 }
655 657
656 /*! \brief Create a mbe from a SkCanvas. 658 /*! \brief Create a mbe from a SkCanvas.
657 * 659 *
658 * It is only used for Android JNI. It is used to create mbe_t from a 660 * It is only used for Android JNI. It is used to create mbe_t from a
769 canvas->states = states; 771 canvas->states = states;
770 } 772 }
771 773
772 void mbe_fill(mbe_t *canvas) { 774 void mbe_fill(mbe_t *canvas) {
773 mbe_fill_preserve(canvas); 775 mbe_fill_preserve(canvas);
774 canvas->path->reset(); 776 canvas->path->rewind();
777 canvas->subpath->rewind();
775 } 778 }
776 779
777 void mbe_clip(mbe_t *canvas) { 780 void mbe_clip(mbe_t *canvas) {
778 if(!canvas->subpath->isEmpty()) 781 if(!canvas->subpath->isEmpty())
779 _update_path(canvas); 782 _update_path(canvas);
780 783
781 canvas->canvas->clipPath(*canvas->path, SkRegion::kIntersect_Op); 784 canvas->canvas->clipPath(*canvas->path, SkRegion::kIntersect_Op);
782 canvas->path->reset(); 785 canvas->path->rewind();
786 canvas->subpath->rewind();
783 } 787 }
784 788
785 mbe_font_face_t * mbe_query_font_face(const char *family, 789 mbe_font_face_t * mbe_query_font_face(const char *family,
786 int slant, int weight) {} 790 int slant, int weight) {}
787 void mbe_free_font_face(mbe_font_face_t *face) {} 791 void mbe_free_font_face(mbe_font_face_t *face) {}
792 canvas->canvas->drawColor(color, SkPorterDuff::kClear_Mode); 796 canvas->canvas->drawColor(color, SkPorterDuff::kClear_Mode);
793 } 797 }
794 798
795 void mbe_copy_source(mbe_t *src, mbe_t *dst) { 799 void mbe_copy_source(mbe_t *src, mbe_t *dst) {
796 SkPaint *paint = dst->paint; 800 SkPaint *paint = dst->paint;
797 SkShader *shader; 801 const SkBitmap *bmap;
798 SkBitmap *bmap;
799 SkXfermode *mode; 802 SkXfermode *mode;
800 803
801 _prepare_paint(dst, SkPaint::kFill_Style); 804 /* _prepare_paint(dst, SkPaint::kFill_Style); */
802 mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kSrc_Mode); 805 mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kSrc_Mode);
803 paint->setXfermode(mode); 806 paint->setXfermode(mode);
807 bmap = &src->canvas->getDevice()->accessBitmap(false);
808
809 dst->canvas->drawBitmap(*bmap, 0, 0, paint);
810
811 paint->reset();
804 mode->unref(); 812 mode->unref();
805 bmap = &src->canvas->getDevice()->accessBitmap(false); 813 /* _finish_paint(dst); */
806 shader = SkShader::CreateBitmapShader(*bmap,
807 SkShader::kClamp_TileMode ,
808 SkShader::kClamp_TileMode);
809 paint->setShader(shader);
810 shader->unref();
811
812 dst->canvas->drawPaint(*paint);
813
814 _finish_paint(canvas);
815 } 814 }
816 815
817 void mbe_transform(mbe_t *mbe, co_aix matrix[6]) { 816 void mbe_transform(mbe_t *mbe, co_aix matrix[6]) {
818 _update_path(mbe); 817 _update_path(mbe);
819 818