#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
+#include "SkColorCubeFilter.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkComposeImageFilter.h"
return bitmap[R(2)];
}
+static SkData* make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
+ int size = 4 << R(5);
+ SkData* data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size);
+ SkColor* pixels = (SkColor*)(data->writable_data());
+ SkAutoMalloc lutMemory(size);
+ SkAutoMalloc invLutMemory(size);
+ uint8_t* lut = (uint8_t*)lutMemory.get();
+ uint8_t* invLut = (uint8_t*)invLutMemory.get();
+ const int maxIndex = size - 1;
+ for (int i = 0; i < size; i++) {
+ lut[i] = (i * 255) / maxIndex;
+ invLut[i] = ((maxIndex - i) * 255) / maxIndex;
+ }
+ for (int r = 0; r < size; ++r) {
+ for (int g = 0; g < size; ++g) {
+ for (int b = 0; b < size; ++b) {
+ pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF,
+ invR ? invLut[r] : lut[r],
+ invG ? invLut[g] : lut[g],
+ invB ? invLut[b] : lut[b]);
+ }
+ }
+ }
+ if (cubeDimension) {
+ *cubeDimension = size;
+ }
+ return data;
+}
+
static void drawSomething(SkCanvas* canvas) {
SkPaint paint;
// Add a 1 in 3 chance to get a NULL input
if (canBeNull && (R(3) == 1)) { return filter; }
- enum { ALPHA_THRESHOLD, MERGE, COLOR, BLUR, MAGNIFIER,
+ enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER,
DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE,
DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS };
filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filter()) : 0;
}
break;
+ case LUT3D:
+ {
+ int cubeDimension;
+ SkAutoDataUnref lut3D(make_3Dlut(&cubeDimension, (R(2) == 1), (R(2) == 1), (R(2) == 1)));
+ SkAutoTUnref<SkColorFilter> cf(SkColorCubeFilter::Create(lut3D, cubeDimension));
+ filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filter()) : 0;
+ }
+ break;
case BLUR:
filter = SkBlurImageFilter::Create(make_scalar(true), make_scalar(true), make_image_filter());
break;