nr-filter-displacement-map.cpp revision 833c08758cda30e603c640ef35ba2da894caef77
0N/A#include "display/nr-filter-displacement-map.h"
0N/A#include "display/nr-filter-types.h"
0N/A#include "display/nr-filter-units.h"
0N/A#include "libnr/nr-pixops.h"
0N/A return new FilterDisplacementMap();
0N/A if ( x < pb->area.x0 || x >= pb->area.x1 || y < pb->area.y0 || y >= pb->area.y1 ) return pixel_t::blank(); // This assumes anything outside the defined range is (0,0,0,0)
0N/Atemplate<bool PREMULTIPLIED>
0N/A unsigned int xf = static_cast<unsigned int>(floor(sf*(x-xi)+.5)), yf = static_cast<unsigned int>(floor(sf*(y-yi)+.5));
0N/A if (PREMULTIPLIED) {
0N/A // If these two colors are interpolated the expected result would be greenish pixels containing no red.
0N/A unsigned int c00 = p00[i]*p00[3], c01 = p01[i]*p01[3], c10 = p10[i]*p10[3], c11 = p11[i]*p11[3]; // range [0,255*a]
0N/Astatic void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map, int Xchannel, int Ychannel, NRPixBlock* out, double scalex, double scaley) {
0N/A out_data[(xout-out->area.x0) + (out->area.x1-out->area.x0)*(yout-out->area.y0)] = interpolatePixels<DATA_PREMULTIPLIED>(texture, xtex, ytex);
0N/A if (texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8N && texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) {
0N/A g_warning("Source images without an alpha channel are not supported by feDisplacementMap at the moment.");
0N/A nr_pixblock_setup_fast(out, texture->mode, out->area.x0, out->area.y0, out->area.x1, out->area.y1, true);
0N/A bool free_map_on_exit = false;
0N/A free_map_on_exit = true;
0N/A } else if (data_premultiplied) {
0N/A if (free_map_on_exit) {
0N/Avoid FilterDisplacementMap::set_channel_selector(int s, FilterDisplacementMapChannelSelector channel) {
0N/A return TRAIT_PARALLER;