Commit 129d9ef6 authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Clean all #includes in headers

* Remove all but two of the subdirs in krita/core in preparation for more
  file shuffling -- I will take Jesper Pedersen's lessons to heart and
  separate interface and implementation for core and plugins
* Remove all necessity for plugins to include headers from the tiles 
  directory (tested for performance consequences, the current scheme
  is even slightly faster)
* clean up convolution by removing the old matrix class
* clean up Makefile.am's by only linking with the necessary libs, not
  always with kofficecore and kopainter.

svn path=/trunk/koffice/; revision=467944
parent 6abe2d21
# all_includes must remain last!
INCLUDES = \
-I$(srcdir)/../sdk \
-I$(srcdir)/resources \
-I$(srcdir)/visitors \
-I$(srcdir)/tool \
-I$(srcdir)/paintop \
-I$(srcdir)/color_strategy \
-I$(srcdir)/tiles \
-I$(srcdir)/../ui \
-I$(srcdir)/../kopalette \
-I../ui \
-I../kopalette \
-I$(srcdir)/../ui/ \
-I../ui/ \
$(KOFFICE_INCLUDES) \
-I$(interfacedir) \
$(KOPAINTER_INCLUDES) \
-I$(srcdir)/strategy \
-I$(srcdir)/color_strategy \
$(all_includes)
#CXXFLAGS = -shared -fPIC
......@@ -24,11 +15,7 @@ INCLUDES = \
noinst_LTLIBRARIES = libkritacore.la
libkritacore_la_LIBADD = tiles/libkistile.la \
strategy/libkisstrategy.la \
color_strategy/libkiscolor_strategy.la \
resources/libkisresources.la \
paintop/libkispaintop.la \
tool/libkistool.la \
$(LIB_KOPAINTER)
libkritacore_la_SOURCES = kis_color.cc kis_paint_device_impl.cc kis_layer.cc \
......@@ -42,7 +29,27 @@ libkritacore_la_SOURCES = kis_color.cc kis_paint_device_impl.cc kis_layer.cc \
kis_clipboard.cc kis_filter.cc kis_filter_registry.cc kis_filter_strategy.cc \
kis_part_layer.cc kis_filter_manager.cc kis_tool_manager.cc \
kis_paint_device_iface.cc kis_paint_device_iface.skel kis_histogram.cc \
kis_boundary.cc kis_histogram_producer.cc
kis_boundary.cc kis_histogram_producer.cc kis_paintop.cc kis_paintop_registry.cc \
kis_strategy_move.cc \
kis_tool.cc \
kis_tool_dummy.cc \
kis_tool_freehand.cc \
kis_tool_non_paint.cc \
kis_tool_paint.cc \
kis_tool_registry.cc \
kis_tool_shape.cc \
kis_alpha_mask.cc \
kis_autobrush_resource.cc \
kis_autogradient_resource.cc \
kis_brush.cc \
kis_gradient.cc \
kis_imagepipe_brush.cc \
kis_palette.cc \
kis_pattern.cc \
kis_profile.cc \
kis_resource.cc \
kis_resourceserver.cc \
kis_iterator.cc
noinst_HEADERS = kis_paint_device_impl.h kis_layer.h kis_image.h kis_doc.h \
......@@ -50,10 +57,31 @@ noinst_HEADERS = kis_paint_device_impl.h kis_layer.h kis_image.h kis_doc.h \
kis_command.h kis_background.h kis_config.h \
kis_transaction.h kis_vec.h kis_rect.h \
kis_iteratorpixeltrait.h kis_iterators_pixel.h kis_view_iface.h kis_doc_iface.h kis_image_iface.h \
kis_matrix.h kis_selection_manager.h kis_scale_visitor.h kis_rotate_visitor.h \
kis_selection_manager.h kis_scale_visitor.h kis_rotate_visitor.h \
kis_filter.h kis_filter_registry.h kis_part_layer.h \
kis_filter_manager.h kis_tool_manager.h kis_histogram.h \
kis_paint_device_iface.h kis_boundary.h kis_histogram_producer.h
kis_paint_device_iface.h kis_boundary.h kis_histogram_producer.h kis_paintop_registry.h kis_paintop.h \
kis_strategy_move.h \
kis_tool_shape.h \
kis_tool_registry.h \
kis_tool_paint.h \
kis_tool_non_paint.h \
kis_tool_freehand.h \
kis_tool_factory.h \
kis_tool_dummy.h \
kis_tool_controller.h \
kis_tool.h \
kis_resourceserver.h \
kis_resource.h \
kis_profile.h \
kis_pattern.h \
kis_palette.h \
kis_imagepipe_brush.h \
kis_gradient.h \
kis_brush.h \
kis_autogradient_resource.h \
kis_autobrush_resource.h \
kis_alpha_mask.h kis_datamanager.h kis_iterator.h
libkritacore_la_METASOURCES = AUTO
......@@ -64,5 +92,5 @@ if include_kunittest_tests
TESTSDIR = tests
endif
SUBDIRS = tiles strategy color_strategy paintop resources tool . $(TESTSDIR)
SUBDIRS = tiles color_strategy . $(TESTSDIR)
......@@ -25,7 +25,6 @@
#include <qpair.h>
#include "kis_global.h"
#include "kis_types.h"
#include "kis_channelinfo.h"
#include "kis_profile.h"
#include "kis_id.h"
......
......@@ -23,7 +23,6 @@
#include <qcolor.h>
#include "kis_global.h"
#include "kis_abstract_colorspace.h"
#include "kis_u8_base_colorspace.h"
#include "kis_pixel.h"
......
......@@ -32,7 +32,6 @@
#include "kis_u16_base_colorspace.h"
#include "kis_image.h"
#include "kis_xyz_colorspace.h"
#include "kis_iterators_pixel.h"
#include "kis_integer_maths.h"
#define downscale(quantum) (quantum) //((unsigned char) ((quantum)/257UL))
......
......@@ -15,11 +15,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_AUTOBRUSH_RESOURCE_H_
#define _KIS_AUTOBRUSH_RESOURCE_H_
#include <qobject.h>
#include "kis_brush.h"
class KisAutobrushShape {
......
......@@ -18,7 +18,6 @@
#ifndef KIS_BACKGROUND_H_
#define KIS_BACKGROUND_H_
#include "kis_types.h"
#include "kis_paint_device_impl.h"
#include "kis_layer.h"
......
......@@ -21,12 +21,12 @@
#include <qvaluelist.h>
#include <qpair.h>
#include <koffice_export.h>
#include "kis_paint_device_impl.h"
#include "kis_point.h"
class QPixmap;
class QPainter;
class KisPaintDeviceImpl;
/**
* Generates an 'outline' for a paint device. It should look a bit like the outline of a
* marching ants selection. You can use it to paint the outline of a KisBrush while painting.
......
......@@ -40,6 +40,7 @@
#include <kdebug.h>
#include <klocale.h>
#include "kis_layer.h"
#include "kis_global.h"
#include "kis_brush.h"
#include "kis_alpha_mask.h"
......@@ -99,7 +100,7 @@ KisBrush::KisBrush(const QString& filename,
dataPos += m_header_size + (width() * height() * m_bytes);
}
KisBrush::~KisBrush()
{
m_scaledBrushes.clear();
......@@ -145,7 +146,7 @@ bool KisBrush::init()
}
else {
bh.spacing = ntohl(bh.spacing);
if (bh.spacing > 1000) {
return false;
}
......@@ -746,13 +747,13 @@ QImage KisBrush::scaleImage(const QImage& srcImage, int width, int height)
+ a * (1 - b) * qRed(bottomLeft) * qAlpha(bottomLeft)
+ (1 - a) * b * qRed(topRight) * qAlpha(topRight)
+ (1 - a) * (1 - b) * qRed(bottomRight) * qAlpha(bottomRight) + 0.5);
green = static_cast<int>(a * b * qGreen(topLeft) * qAlpha(topLeft)
+ a * (1 - b) * qGreen(bottomLeft) * qAlpha(bottomLeft)
+ (1 - a) * b * qGreen(topRight) * qAlpha(topRight)
green = static_cast<int>(a * b * qGreen(topLeft) * qAlpha(topLeft)
+ a * (1 - b) * qGreen(bottomLeft) * qAlpha(bottomLeft)
+ (1 - a) * b * qGreen(topRight) * qAlpha(topRight)
+ (1 - a) * (1 - b) * qGreen(bottomRight) * qAlpha(bottomRight) + 0.5);
blue = static_cast<int>(a * b * qBlue(topLeft) * qAlpha(topLeft)
+ a * (1 - b) * qBlue(bottomLeft) * qAlpha(bottomLeft)
+ (1 - a) * b * qBlue(topRight) * qAlpha(topRight)
blue = static_cast<int>(a * b * qBlue(topLeft) * qAlpha(topLeft)
+ a * (1 - b) * qBlue(bottomLeft) * qAlpha(bottomLeft)
+ (1 - a) * b * qBlue(topRight) * qAlpha(topRight)
+ (1 - a) * (1 - b) * qBlue(bottomRight) * qAlpha(bottomRight) + 0.5);
alpha = static_cast<int>(a * b * qAlpha(topLeft)
+ a * (1 - b) * qAlpha(bottomLeft)
......
......@@ -28,13 +28,12 @@
#include <kio/job.h>
#include "kis_resource.h"
#include "kis_global.h"
#include "kis_layer.h"
#include "kis_types.h"
#include "kis_point.h"
#include "kis_alpha_mask.h"
#include "koffice_export.h"
#include "kis_boundary.h"
#include "paintop/kis_paintop.h"
#include "kis_paintop.h"
class QPoint;
class QPixmap;
......@@ -54,10 +53,10 @@ class KRITACORE_EXPORT KisBrush : public KisResource {
public:
KisBrush(const QString& filename);
KisBrush(const QString& filename,
KisBrush(const QString& filename,
const QByteArray & data,
Q_UINT32 & dataPos);
virtual ~KisBrush();
virtual bool load();
......@@ -96,7 +95,7 @@ public:
QImage outline(double pressure = PRESSURE_DEFAULT);
virtual KisBoundary boundary();
/**
* Returns true if this brush can return something useful for the info. This is used
* by Pipe Brushes that can't paint sometimes
......@@ -145,7 +144,7 @@ private:
// Find the scaled brush(es) nearest to the given scale.
void findScaledBrushes(double scale, const ScaledBrush **aboveBrush, const ScaledBrush **belowBrush) const;
// Initialize our boundary
void generateBoundary();
......@@ -167,7 +166,7 @@ private:
Q_UINT32 m_magic_number; /* GIMP brush magic number */
enumBrushType m_brushType;
KisBoundary* m_boundary;
};
......
......@@ -36,8 +36,8 @@ class KRITACORE_EXPORT KisColor {
public:
// Create an empty KisColor. It will be valid, but also black and transparent
KisColor();
KisColor();
virtual ~KisColor();
// Create a KisColor on the basis of a QColor, assuming an sRGB profile for the result
......@@ -51,11 +51,11 @@ public:
// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
// is assumed to have the current monitor profile.
KisColor(const QColor & color, KisColorSpace * colorSpace);
// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
// is assumed to have the current monitor profile.
// is assumed to have the current monitor profile.
KisColor(const QColor & color, Q_UINT8 alpha, KisColorSpace * colorSpace);
// Create a KisColor using a native color strategy. The data is copied.
KisColor(const Q_UINT8 * data, KisColorSpace * colorSpace);
......@@ -70,16 +70,16 @@ public:
// For easy memcpy'ing etc.
Q_UINT8 * data() const { return m_data; }
KisColorSpace * colorSpace() const { return m_colorSpace; }
KisProfile * profile() const { return m_colorSpace -> getProfile(); }
KisProfile * profile() const { return m_colorSpace -> getProfile(); }
// Convert this KisColor to the specified colorspace. If the specified colorspace is the
// same as the original colorspace, do nothing. Returns the converted KisColor.
void convertTo(KisColorSpace * cs);
// Replace the existing color data, and colorspace with the specified data.
// Replace the existing color data, and colorspace with the specified data.
void setColor(Q_UINT8 * data, KisColorSpace * colorSpace = 0);
// To save the user the trouble of doing color->colorSpace()->toQColor(color->data(), &c, &a
......@@ -87,17 +87,13 @@ public:
void toQColor(QColor *c, Q_UINT8 *opacity) const;
QColor toQColor() const;
void dump() const;
#if 0
// XXX (bsar): Do we need these?
void toLab(float * l, float * a, float * b, float * alpha, KisProfile * profile = 0);
void fromLab(float l, float a, float b, float alpha, KisProfile * profile = 0);
#endif
private:
Q_UINT8 * m_data;
KisColorSpace * m_colorSpace;
};
......
......@@ -56,6 +56,7 @@
#include "kis_convolution_painter.h"
KisConvolutionPainter::KisConvolutionPainter()
: super()
{
......@@ -65,25 +66,6 @@ KisConvolutionPainter::KisConvolutionPainter(KisPaintDeviceImplSP device) : supe
{
}
void KisConvolutionPainter::applyMatrix(KisMatrix3x3* matrix, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
{
KisKernel * kernel = new KisKernel();
kernel -> width = 3;
kernel -> height = 3;
kernel -> factor = matrix->factor();
kernel -> offset = matrix->offset();
kernel->data = new Q_INT32[9];
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 3; ++col) {
kernel -> data[row * 3 + col] = matrix[0][col][row];
}
}
applyMatrix(kernel, x, y, w, h);
}
void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h,
KisConvolutionBorderOp borderOp,
enumChannelFlags channelFlags )
......@@ -108,16 +90,16 @@ void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y
kw = kernel->width;
kh = kernel->height;
kd = (kw - 1) / 2;
// Don't try to convolve on an area smaller than the kernel, or with a kernel that is not square or has no center pixel.
if (w < kw || h < kh || kw != kh || kw&1 == 0 ) return;
m_cancelRequested = false;
int lastProgressPercent = 0;
emit notifyProgress(this, 0);
KisColorSpace * cs = m_device->colorSpace();
// Determine whether we convolve border pixels, or not.
switch (borderOp) {
case BORDER_DEFAULT_FILL :
......@@ -131,7 +113,7 @@ void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y
w -= kw - 1;
h -= kh - 1;
}
// Iterate over all pixels in our rect, create a cache of pixels around the current pixel and convolve them in the colorstrategy.
QMemArray<Q_UINT8 *> pixelPtrCache(kw * kh);
......@@ -141,22 +123,22 @@ void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y
for (int row = y; row < y + h; ++row) {
// col = the x position of the pixel we want to change
int col = x;
int col = x;
KisHLineIteratorPixel hit = m_device -> createHLineIterator(x, row, w, true);
while (!hit.isDone()) {
if (hit.isSelected()) {
// Iterate over all contributing pixels that are covered by the kernel
// krow = the y position in the kernel matrix
Q_INT32 i = 0;
for (Q_INT32 krow = 0; krow < kh; ++krow) {
// col - kd = the left starting point of the kernel as centered on our pixel
// krow - kd = the offset for the top of the kernel as centered on our pixel
// kw = the width of the kernel
// Fill the cache with pointers to the pixels under the kernel
KisHLineIteratorPixel kit = m_device -> createHLineIterator(col - kd, (row - kd) + krow, kw, false);
while (!kit.isDone()) {
......@@ -174,7 +156,7 @@ void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y
}
int progressPercent = 100 - ((((y + h) - row) * 100) / h);
if (progressPercent > lastProgressPercent) {
emit notifyProgress(this, progressPercent);
lastProgressPercent = progressPercent;
......@@ -182,8 +164,8 @@ void KisConvolutionPainter::applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y
if (m_cancelRequested) {
return;
}
}
}
}
addDirtyRect(QRect(x, y, w, h));
......
......@@ -18,31 +18,9 @@
#ifndef KIS_CONVOLUTION_PAINTER_H_
#define KIS_CONVOLUTION_PAINTER_H_
#include <qbrush.h>
#include <qcolor.h>
#include <qfontinfo.h>
#include <qfontmetrics.h>
#include <qpen.h>
#include <qregion.h>
#include <qwmatrix.h>
#include <qimage.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qpointarray.h>
#include <qstring.h>
#include <qpainter.h>
#include <qvaluevector.h>
#include <kcommand.h>
#include "kis_global.h"
#include "kis_types.h"
#include "kis_paint_device_impl.h"
#include "kis_point.h"
#include "kis_matrix.h"
#include "kis_progress_subject.h"
#include "kis_channelinfo.h"
#include "kis_painter.h"
#include "koffice_export.h"
enum KisConvolutionBorderOp {
......@@ -69,14 +47,8 @@ class KRITACORE_EXPORT KisConvolutionPainter : public KisPainter
public:
KisConvolutionPainter();
KisConvolutionPainter(KisPaintDeviceImplSP device);
/**
* Convolve all channels in the current paint device using the specified matrix. Only the first matrix of the array is
* used.
*/
void applyMatrix(KisMatrix3x3* matrix, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
KisConvolutionPainter();
KisConvolutionPainter(KisPaintDeviceImplSP device);
/**
* Convolve all channels in src using the specified kernel; there is only one kernel for all
......@@ -92,8 +64,8 @@ public:
* Note that we do not (currently) support different kernels for different channels _or_ channel types.
*/
void applyMatrix(KisKernel * kernel, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h,
KisConvolutionBorderOp borderOp = BORDER_AVOID,
enumChannelFlags channelFlags = FLAG_COLOR);
KisConvolutionBorderOp borderOp = BORDER_AVOID,
enumChannelFlags channelFlags = FLAG_COLOR);
......
......@@ -26,7 +26,7 @@ class KoStore;
// Change the following two lines to switch (at compiletime) to another datamanager
#include "kis_tileddatamanager.h"
#include "tiles/kis_tileddatamanager.h"
#define ACTUAL_DATAMGR KisTiledDataManager
......
......@@ -52,6 +52,7 @@
#include <kocommandhistory.h>
// Local
#include "kis_annotation.h"
#include "kis_types.h"
#include "kis_config.h"
#include "kis_global.h"
......@@ -62,6 +63,7 @@
#include "kis_layer.h"
#include "kis_nameserver.h"
#include "kis_painter.h"
#include "kis_selection.h"
#include "kis_fill_painter.h"
#include "kis_command.h"
#include "kis_view.h"
......@@ -391,7 +393,7 @@ KisImageSP KisDoc::loadImage(const QDomElement& element)
if ((colorspacename = element.attribute("colorspacename")).isNull())
{
// An old file: take a reasonable default.
// An old file: take a reasonable default.
// Krita didn't support anything else in those
// days anyway.
colorspacename = "RGBA";
......@@ -1028,6 +1030,11 @@ void KisDoc::prepareForImport()
}
KisImageSP KisDoc::currentImage()
{
return m_currentImage;
}
void KisDoc::setCurrentImage(KisImageSP image)
{
m_currentImage = image;
......
......@@ -24,11 +24,8 @@
#include <koDocument.h>
#include "kis_global.h"
#include "kis_types.h"
#include "kis_image.h"
#include "kis_undo_adapter.h"
#include "kis_composite_op.h"
#include <koffice_export.h>
......@@ -41,6 +38,7 @@ class KCommand;
class KoCommandHistory;
class KMacroCommand;
class KisProfile;
class KisView;
class KisNameServer;
class KisChildDoc;
......@@ -73,13 +71,13 @@ public:
* by Krita because we appear to be doing our zooming
* elsewhere. This may affect KOffice compatibility.
*/