diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2015-06-12 06:41:51 +0300 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2015-06-12 06:41:51 +0300 |
commit | e840ccb85cb3036cd26ea27b8323386294ac9684 (patch) | |
tree | 560913f341c2f97c19dd52309b05eb9eff6837d9 | |
parent | ba26798949b72d258284e14955723acab217b23c (diff) |
early work
-rw-r--r-- | include/painter.h | 26 | ||||
-rw-r--r-- | src/painter.c | 195 |
2 files changed, 219 insertions, 2 deletions
diff --git a/include/painter.h b/include/painter.h index 432023a..301b87c 100644 --- a/include/painter.h +++ b/include/painter.h @@ -39,11 +39,31 @@ struct painter_bitmap char *data; }; -#define PT_ERROR_NONE 0 -#define PT_ERROR_OUT_OF_MEM 1 +#define PT_ERROR_NONE 0 +#define PT_ERROR_OUT_OF_MEM 1 +#define PT_ERROR_PARAM 2 #define PT_LINE_FLAGS_NONE 0 + /* reverse Windows X11 */ + /* polish */ +#define PT_ROP_0 0x00 /* 0 BLACKNESS GXclear */ +#define PT_ROP_DSon 0x11 /* Dson NOTSRCERASE GXnor */ +#define PT_ROP_DSna 0x22 /* DSna GXandInverted */ +#define PT_ROP_Sn 0x33 /* Sn NOTSRCCOPY GXcopyInverted */ +#define PT_ROP_SDna 0x44 /* SDna SRCERASE GXandReverse */ +#define PT_ROP_Dn 0x55 /* Dn DSTINVERT GXinvert */ +#define PT_ROP_DSx 0x66 /* DSx SRCINVERT GXxor */ +#define PT_ROP_DSan 0x77 /* DSan GXnand */ +#define PT_ROP_DSa 0x88 /* DSa SRCAND GXand */ +#define PT_ROP_DSxn 0x99 /* DSxn GXequiv */ +#define PT_ROP_D 0xAA /* D GXnoop */ +#define PT_ROP_DSno 0xBB /* DSno MERGEPAINT GXorInverted */ +#define PT_ROP_S 0xCC /* S SRCCOPY GXcopy */ +#define PT_ROP_SDno 0xDD /* SDno GXorReverse */ +#define PT_ROP_DSo 0xEE /* DSo GXor */ +#define PT_ROP_1 0xFF /* 1 WHITENESS GXset */ + int painter_create(void **handle); int @@ -57,6 +77,8 @@ painter_set_rop(void *handle, int rop); int painter_set_fill_mode(void *handle, int mode); int +painter_set_pattern_origin(void *handle, int x, int y); +int painter_set_clip(void *handle, int x, int y, int cx, int cy); int painter_clear_clip(void *handle); diff --git a/src/painter.c b/src/painter.c new file mode 100644 index 0000000..88a698d --- /dev/null +++ b/src/painter.c @@ -0,0 +1,195 @@ +/** + * painter main header + * + * Copyright 2015 Jay Sorg <jay.sorg@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "painter.h" + +struct painter_rect +{ + short x1; + short y1; + short x2; + short y2; +}; + +struct painter +{ + int rop; + int fgcolor; + int bgcolor; + int fill_mode; + int clip_valid; + struct painter_rect clip; + int origin_x; + int origin_y; +}; + +/*****************************************************************************/ +int +painter_create(void **handle) +{ + struct painter *pt; + + if (handle == NULL) + { + return PT_ERROR_PARAM; + } + *handle = malloc(sizeof(struct painter)); + if (*hanlde == NULL) + { + return PT_ERROR_OUT_OF_MEM; + } + memset(*handle, 0, sizeof(struct painter)); + + pt = (struct painter *) *handle; + pt->rop = PT_ROP_COPY; + + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_delete(void *handle) +{ + if (handle == NULL) + { + return PT_ERROR_NONE; + } + free(handle); + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_fgcolor(void *handle, int color) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->fgcolor = fgcolor; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_bgcolor(void *handle, int color) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->bgcolor = bgcolor; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_rop(void *handle, int rop) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->rop = rop; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_fill_mode(void *handle, int mode) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->fill_mode = fill_mode; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_pattern_origin(void *handle, int x, int y) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->origin_x = x; + pt->origin_y = y; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_set_clip(void *handle, int x, int y, int cx, int cy) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->clip.x1 = x; + pt->clip.y1 = y; + pt->clip.x2 = x + cx; + pt->clip.y2 = y + cy; + pt->clip_valid = 1; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_clear_clip(void *handle) +{ + struct painter *pt; + + pt = (struct painter *) handle; + pt->clip_valid = 0; + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_fill_rect(void *handle, struct painter_bitmap *dst, + int x, int y, int cx, int cy) +{ + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_fill_pattern(void *handle, struct painter_bitmap *dst, + struct painter_bitmap *pat, int patx, int paty, + int x, int y, int cx, int cy) +{ + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_copy(void *handle, struct painter_bitmap *dst, + int x, int y, int cx, int cy, + struct painter_bitmap *src, int srcx, int srcy) +{ + return PT_ERROR_NONE; +} + +/*****************************************************************************/ +int +painter_line(void *handle, struct painter_bitmap *dst, + int x1, int y1, int x2, int y2, int width, int flags) +{ + return PT_ERROR_NONE; +} + |