aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/utils/SkCanvasStateUtils.cpp6
-rw-r--r--tests/CanvasStateTest.cpp9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index cd79a44f50..0cc42c5c1c 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -10,6 +10,7 @@
#include "SkBitmapDevice.h"
#include "SkCanvas.h"
#include "SkCanvasStack.h"
+#include "SkErrorInternals.h"
#include "SkWriter32.h"
#define CANVAS_STATE_VERSION 1
@@ -183,7 +184,8 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
ClipValidator validator;
canvas->replayClips(&validator);
if (validator.failed()) {
- SkDEBUGF(("CaptureCanvasState does not support canvases with antialiased clips.\n"));
+ SkErrorInternals::SetError(kInvalidOperation_SkError,
+ "CaptureCanvasState does not support canvases with antialiased clips.\n");
return NULL;
}
@@ -244,7 +246,7 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
// for now, just ignore any client supplied DrawFilter.
if (canvas->getDrawFilter()) {
- SkDEBUGF(("CaptureCanvasState will ignore the canvases draw filter.\n"));
+// SkDEBUGF(("CaptureCanvasState will ignore the canvases draw filter.\n"));
}
return canvasState.detach();
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 91d369e3f5..7cba71e726 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -11,6 +11,7 @@
#include "SkCanvas.h"
#include "SkCanvasStateUtils.h"
#include "SkDrawFilter.h"
+#include "SkError.h"
#include "SkPaint.h"
#include "SkRect.h"
#include "SkRRect.h"
@@ -205,6 +206,9 @@ static void test_draw_filters(skiatest::Reporter* reporter) {
////////////////////////////////////////////////////////////////////////////////
+// we need this function to prevent SkError from printing to stdout
+static void error_callback(SkError code, void* ctx) {}
+
static void test_soft_clips(skiatest::Reporter* reporter) {
SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 10, 10);
SkCanvas canvas(&device);
@@ -214,8 +218,13 @@ static void test_soft_clips(skiatest::Reporter* reporter) {
canvas.clipRRect(roundRect, SkRegion::kIntersect_Op, true);
+ SkSetErrorCallback(error_callback, NULL);
+
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
REPORTER_ASSERT(reporter, !state);
+
+ REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError());
+ SkClearLastError();
}
////////////////////////////////////////////////////////////////////////////////