File indexing completed on 2024-06-16 04:17:34
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Ashwin Dhakaita <ashwingpdhakaita@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_MYPAINT_SURFACE_H 0008 #define KIS_MYPAINT_SURFACE_H 0009 0010 #include <QObject> 0011 0012 #include <kis_paint_device.h> 0013 #include <kis_fixed_paint_device.h> 0014 #include <kis_painter.h> 0015 #include <kis_paint_information.h> 0016 #include <kis_lod_transform.h> 0017 #include <KoColor.h> 0018 #include <kis_marker_painter.h> 0019 #include <kis_sequential_iterator.h> 0020 #include <KisOverlayPaintDeviceWrapper.h> 0021 0022 #include <libmypaint/mypaint-brush.h> 0023 #include <libmypaint/mypaint-surface.h> 0024 0025 class KisMyPaintSurface 0026 { 0027 public: 0028 0029 struct MyPaintSurfaceInternal: public MyPaintSurface { 0030 KisMyPaintSurface *m_owner; 0031 KoChannelInfo::enumChannelValueType bitDepth; 0032 }; 0033 0034 public: 0035 KisMyPaintSurface(KisPainter* painter, KisPaintDeviceSP paintNode=nullptr, KisImageSP image = nullptr); 0036 ~KisMyPaintSurface(); 0037 0038 /** 0039 * mypaint_surface_draw_dab: 0040 * 0041 * Draw a dab onto the surface. 0042 */ 0043 static int draw_dab(MyPaintSurface *self, float x, float y, float radius, 0044 float color_r, float color_g, float color_b, float opaque, float hardness, 0045 float color_a, float aspect_ratio, float angle, float lock_alpha, 0046 float colorize); 0047 0048 static void get_color(MyPaintSurface *self, float x, float y, float radius, 0049 float * color_r, float * color_g, float * color_b, float * color_a); 0050 0051 template <typename channelType> 0052 int drawDabImpl(MyPaintSurface *self, float x, float y, float radius, float color_r, float color_g, 0053 float color_b, float opaque, float hardness, float color_a, 0054 float aspect_ratio, float angle, float lock_alpha, float colorize); 0055 0056 template <typename channelType> 0057 void getColorImpl(MyPaintSurface *self, float x, float y, float radius, 0058 float * color_r, float * color_g, float * color_b, float * color_a); 0059 0060 inline float 0061 calculate_rr_antialiased (int xp, int yp, float x, float y, float aspect_ratio, 0062 float sn, float cs, float one_over_radius2, float r_aa_start); 0063 0064 inline float 0065 calculate_alpha_for_rr (float rr, float hardness, float slope1, float slope2); 0066 0067 inline float 0068 calculate_rr (int xp, int yp, float x, float y, float aspect_ratio, 0069 float sn, float cs, float one_over_radius2); 0070 0071 0072 KisPainter* painter(); 0073 void paint(KoColor *color, KoColor* bgColor); 0074 qreal calculateOpacity(float angle, float hardness, float opaque, float x, float y, 0075 float xp, float yp, float aspect_ratio, float radius); 0076 0077 MyPaintSurface* surface(); 0078 0079 private: 0080 KisPainter *m_painter; 0081 KisPaintDeviceSP m_imageDevice; 0082 MyPaintSurfaceInternal *m_surface; 0083 KisImageSP m_image; 0084 KisOverlayPaintDeviceWrapper m_precisePainterWrapper; 0085 KisPaintDeviceSP m_dab; 0086 QScopedPointer<KisPainter> m_tempPainter; 0087 QScopedPointer<KisPainter> m_backgroundPainter; 0088 KisFixedPaintDeviceSP m_blendDevice; 0089 KisFixedPaintDeviceSP m_maskDevice; 0090 0091 }; 0092 0093 #endif // KIS_MYPAINT_SURFACE_H