Remove support for SK_CROP_RECT_IS_INT, now that it is no longer used in Blink or Chrome.
BUG= R=reed@google.com, reed Review URL: https://codereview.chromium.org/27521002 git-svn-id: http://skia.googlecode.com/svn/trunk@11812 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
6d2533ebd2
commit
8b66abb9bc
@ -133,13 +133,8 @@ protected:
|
||||
|
||||
SkAutoTUnref<SkColorFilter> cf(
|
||||
SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
|
||||
SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10);
|
||||
#else
|
||||
SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge);
|
||||
SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge);
|
||||
#endif
|
||||
|
||||
SkAutoTUnref<SkImageFilter> offset(new SkOffsetImageFilter(
|
||||
SkIntToScalar(-10), SkIntToScalar(-10)));
|
||||
|
@ -85,11 +85,7 @@ protected:
|
||||
SkColor white(0xFFFFFFFF);
|
||||
SkPaint paint;
|
||||
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(20, 10, 60, 65);
|
||||
#else
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65));
|
||||
#endif
|
||||
|
||||
int y = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -70,11 +70,7 @@ protected:
|
||||
{ 24, 24, 25, 25 },
|
||||
};
|
||||
SkPaint paint;
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(25, 20, 100, 80);
|
||||
#else
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(25, 20, 100, 80));
|
||||
#endif
|
||||
|
||||
for (unsigned j = 0; j < 4; ++j) {
|
||||
for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
|
||||
|
@ -92,11 +92,7 @@ protected:
|
||||
y + i * 8,
|
||||
bitmap->width() - i * 8,
|
||||
bitmap->height() - i * 12);
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect rect = cropRect;
|
||||
#else
|
||||
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
|
||||
#endif
|
||||
SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*bitmap)));
|
||||
SkScalar dx = SkIntToScalar(i*5);
|
||||
SkScalar dy = SkIntToScalar(i*10);
|
||||
|
@ -207,11 +207,7 @@ protected:
|
||||
y + offsets[i][1],
|
||||
fBitmap.width() + offsets[i][2],
|
||||
fBitmap.height() + offsets[i][3]);
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect rect = cropRect;
|
||||
#else
|
||||
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
|
||||
#endif
|
||||
mode.reset(SkXfermode::Create(sampledModes[i]));
|
||||
filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
|
||||
(mode, offsetBackground, offsetForeground, &rect)));
|
||||
|
@ -31,9 +31,6 @@ class SK_API SkImageFilter : public SkFlattenable {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkImageFilter)
|
||||
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
typedef SkIRect CropRect;
|
||||
#else
|
||||
struct CropRect {
|
||||
SkRect fRect;
|
||||
uint32_t fFlags;
|
||||
@ -46,12 +43,12 @@ public:
|
||||
};
|
||||
CropRect() {}
|
||||
explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) : fRect(rect), fFlags(flags) {}
|
||||
// Returns true if any of the crop edges have been set.
|
||||
bool isSet() const
|
||||
{
|
||||
return fFlags != 0x0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
class Proxy {
|
||||
public:
|
||||
@ -160,11 +157,7 @@ public:
|
||||
* "offset" parameter in onFilterImage and filterImageGPU(). (The latter
|
||||
* ensures that the resulting buffer is drawn in the correct location.)
|
||||
*/
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
bool cropRectIsSet() const { return !fCropRect.isLargest(); }
|
||||
#else
|
||||
bool cropRectIsSet() const { return fCropRect.isSet(); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL);
|
||||
|
@ -21,11 +21,7 @@ SK_DEFINE_INST_COUNT(SkImageFilter)
|
||||
SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect)
|
||||
: fInputCount(inputCount),
|
||||
fInputs(new SkImageFilter*[inputCount]),
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
|
||||
#else
|
||||
fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)) {
|
||||
#endif
|
||||
for (int i = 0; i < inputCount; ++i) {
|
||||
fInputs[i] = inputs[i];
|
||||
SkSafeRef(fInputs[i]);
|
||||
@ -35,22 +31,14 @@ SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR
|
||||
SkImageFilter::SkImageFilter(SkImageFilter* input, const CropRect* cropRect)
|
||||
: fInputCount(1),
|
||||
fInputs(new SkImageFilter*[1]),
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
|
||||
#else
|
||||
fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)) {
|
||||
#endif
|
||||
fInputs[0] = input;
|
||||
SkSafeRef(fInputs[0]);
|
||||
}
|
||||
|
||||
SkImageFilter::SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect)
|
||||
: fInputCount(2), fInputs(new SkImageFilter*[2]),
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
|
||||
#else
|
||||
fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)) {
|
||||
#endif
|
||||
fInputs[0] = input1;
|
||||
fInputs[1] = input2;
|
||||
SkSafeRef(fInputs[0]);
|
||||
@ -73,12 +61,8 @@ SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer)
|
||||
fInputs[i] = NULL;
|
||||
}
|
||||
}
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
buffer.readIRect(&fCropRect);
|
||||
#else
|
||||
buffer.readRect(&fCropRect.fRect);
|
||||
fCropRect.fFlags = buffer.readUInt();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
|
||||
@ -90,12 +74,8 @@ void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
|
||||
buffer.writeFlattenable(input);
|
||||
}
|
||||
}
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
buffer.writeIRect(fCropRect);
|
||||
#else
|
||||
buffer.writeRect(fCropRect.fRect);
|
||||
buffer.writeUInt(fCropRect.fFlags);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
|
||||
@ -178,16 +158,6 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
|
||||
|
||||
bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
|
||||
SkRect cropRect;
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
matrix.mapRect(&cropRect, SkRect::Make(fCropRect));
|
||||
SkIRect cropRectI;
|
||||
cropRect.roundOut(&cropRectI);
|
||||
// If the original crop rect edges were unset, max out the new crop edges
|
||||
if (fCropRect.fLeft == SK_MinS32) cropRectI.fLeft = SK_MinS32;
|
||||
if (fCropRect.fTop == SK_MinS32) cropRectI.fTop = SK_MinS32;
|
||||
if (fCropRect.fRight == SK_MaxS32) cropRectI.fRight = SK_MaxS32;
|
||||
if (fCropRect.fBottom == SK_MaxS32) cropRectI.fBottom = SK_MaxS32;
|
||||
#else
|
||||
matrix.mapRect(&cropRect, fCropRect.fRect);
|
||||
SkIRect cropRectI;
|
||||
cropRect.roundOut(&cropRectI);
|
||||
@ -196,7 +166,6 @@ bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
|
||||
if (!(fCropRect.fFlags & CropRect::kHasTop_CropEdge)) cropRectI.fTop = SK_MinS32;
|
||||
if (!(fCropRect.fFlags & CropRect::kHasRight_CropEdge)) cropRectI.fRight = SK_MaxS32;
|
||||
if (!(fCropRect.fFlags & CropRect::kHasBottom_CropEdge)) cropRectI.fBottom = SK_MaxS32;
|
||||
#endif
|
||||
return rect->intersect(cropRectI);
|
||||
}
|
||||
|
||||
|
@ -14,20 +14,11 @@
|
||||
|
||||
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) {
|
||||
SkASSERT(s);
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect cropRect;
|
||||
if (rect.width() == 0 || rect.height() == 0) {
|
||||
cropRect = SkIRect::MakeLargest();
|
||||
} else {
|
||||
rect.roundOut(&cropRect);
|
||||
}
|
||||
#else
|
||||
uint32_t flags = CropRect::kHasAll_CropEdge;
|
||||
if (rect.width() == 0 || rect.height() == 0) {
|
||||
flags = 0x0;
|
||||
}
|
||||
CropRect cropRect(rect, flags);
|
||||
#endif
|
||||
return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect));
|
||||
}
|
||||
|
||||
|
@ -109,11 +109,7 @@ public:
|
||||
{
|
||||
// Check that a color filter image filter with a crop rect cannot
|
||||
// be expressed as a color filter.
|
||||
#ifdef SK_CROP_RECT_IS_INT
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
|
||||
#else
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100));
|
||||
#endif
|
||||
SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropRect));
|
||||
REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user