aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2014-08-18 18:35:16 -0400
committerGravatar Mike Klein <mtklein@google.com>2014-08-18 18:35:16 -0400
commit27dc17c2972421ce9c6331662fee6389b1e795a7 (patch)
tree2a1faac45bd4acc561303aa4f6a8b0ad74dc7f38 /tests
parentcaa80b9a46ea00a7b582d96d73302939aa21b5ee (diff)
Revert "Move the code over using the same template type approach previously used for willPlayBackBitmaps in http://skbug.com/2702."
Diffstat (limited to 'tests')
-rw-r--r--tests/PictureTest.cpp85
-rw-r--r--tests/RecordTest.cpp33
2 files changed, 38 insertions, 80 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 6f62d18538..61cc5021fc 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -578,44 +578,6 @@ static void test_gatherpixelrefs(skiatest::Reporter* reporter) {
}
}
-#define GENERATE_CANVAS(recorder, x) \
- (x) ? recorder.EXPERIMENTAL_beginRecording(100, 100) \
- : recorder.beginRecording(100,100);
-
-/* Hit a few SkPicture::Analysis cases not handled elsewhere. */
-static void test_analysis(skiatest::Reporter* reporter, bool useNewPath) {
- SkPictureRecorder recorder;
-
- SkCanvas* canvas = GENERATE_CANVAS(recorder, useNewPath);
- {
- canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ());
- }
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps());
-
- canvas = GENERATE_CANVAS(recorder, useNewPath);
- {
- SkPaint paint;
- // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader
- // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here.
- SkBitmap bitmap;
- bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2));
- bitmap.eraseColor(SK_ColorBLUE);
- *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN;
- SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
- paint.setShader(shader)->unref();
- REPORTER_ASSERT(reporter,
- shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefault_BitmapType);
-
- canvas->drawRect(SkRect::MakeWH(10, 10), paint);
- }
- picture.reset(recorder.endRecording());
- REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
-}
-
-#undef GENERATE_CANVAS
-
static void test_gatherpixelrefsandrects(skiatest::Reporter* reporter) {
const int IW = 32;
const int IH = IW;
@@ -744,16 +706,11 @@ static void rand_op(SkCanvas* canvas, SkRandom& rand) {
}
#if SK_SUPPORT_GPU
-#define GENERATE_CANVAS(recorder, x) \
- (x) ? recorder.EXPERIMENTAL_beginRecording(100, 100) \
- : recorder.beginRecording(100,100);
-
-static void test_gpu_veto(skiatest::Reporter* reporter,
- bool useNewPath) {
+static void test_gpu_veto(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
- SkCanvas* canvas = GENERATE_CANVAS(recorder, useNewPath);
+ SkCanvas* canvas = recorder.beginRecording(100, 100);
{
SkPath path;
path.moveTo(0, 0);
@@ -775,7 +732,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL, &reason));
REPORTER_ASSERT(reporter, NULL != reason);
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPath path;
@@ -797,7 +754,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter,
// A lot of AA concave paths currently render an SkPicture undesireable for GPU rendering
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPath path;
@@ -820,37 +777,8 @@ static void test_gpu_veto(skiatest::Reporter* reporter,
picture.reset(recorder.endRecording());
// hairline stroked AA concave paths are fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL));
-
- canvas = GENERATE_CANVAS(recorder, useNewPath);
- {
- SkPaint paint;
- SkScalar intervals [] = { 10, 20 };
- SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
- paint.setPathEffect(pe)->unref();
-
- SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
- canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
- }
- picture.reset(recorder.endRecording());
- // fast-path dashed effects are fine for GPU rendering ...
- REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL));
-
- canvas = GENERATE_CANVAS(recorder, useNewPath);
- {
- SkPaint paint;
- SkScalar intervals [] = { 10, 20 };
- SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
- paint.setPathEffect(pe)->unref();
-
- canvas->drawRect(SkRect::MakeWH(10, 10), paint);
- }
- picture.reset(recorder.endRecording());
- // ... but only when applied to drawPoint() calls
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
}
-#undef GENERATE_CANVAS
-
static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
GrContextFactory* factory) {
for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
@@ -1689,12 +1617,9 @@ DEF_TEST(Picture, reporter) {
test_unbalanced_save_restores(reporter);
test_peephole();
#if SK_SUPPORT_GPU
- test_gpu_veto(reporter, false);
- test_gpu_veto(reporter, true);
+ test_gpu_veto(reporter);
#endif
test_has_text(reporter);
- test_analysis(reporter, false);
- test_analysis(reporter, true);
test_gatherpixelrefs(reporter);
test_gatherpixelrefsandrects(reporter);
test_bitmap_with_encoded_data(reporter);
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp
index 2240ae9858..2fcc1e9c53 100644
--- a/tests/RecordTest.cpp
+++ b/tests/RecordTest.cpp
@@ -11,6 +11,7 @@
#include "SkImageInfo.h"
#include "SkShader.h"
#include "SkRecord.h"
+#include "SkRecordAnalysis.h"
#include "SkRecords.h"
// Sums the area of any DrawRect command it sees.
@@ -76,5 +77,37 @@ DEF_TEST(Record, r) {
REPORTER_ASSERT(r, summer.area() == 500);
}
+DEF_TEST(RecordAnalysis, r) {
+ SkRecord record;
+
+ SkRect rect = SkRect::MakeWH(10, 10);
+ SkPaint paint;
+ APPEND(record, SkRecords::DrawRect, paint, rect);
+ REPORTER_ASSERT(r, !SkRecordWillPlaybackBitmaps(record));
+
+ SkBitmap bitmap;
+ APPEND(record, SkRecords::DrawBitmap, &paint, bitmap, 0.0f, 0.0f);
+ REPORTER_ASSERT(r, SkRecordWillPlaybackBitmaps(record));
+
+ SkNEW_PLACEMENT_ARGS(record.replace<SkRecords::DrawRect>(1),
+ SkRecords::DrawRect, (paint, rect));
+ REPORTER_ASSERT(r, !SkRecordWillPlaybackBitmaps(record));
+
+ SkPaint paint2;
+ // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader
+ // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here.
+ SkBitmap bitmap2;
+ bitmap2.allocPixels(SkImageInfo::MakeN32Premul(2, 2));
+ bitmap2.eraseColor(SK_ColorBLUE);
+ *(bitmap2.getAddr32(0, 0)) = SK_ColorGREEN;
+ SkShader* shader = SkShader::CreateBitmapShader(bitmap2, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode);
+ paint2.setShader(shader)->unref();
+ REPORTER_ASSERT(r, shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefault_BitmapType);
+
+ APPEND(record, SkRecords::DrawRect, paint2, rect);
+ REPORTER_ASSERT(r, SkRecordWillPlaybackBitmaps(record));
+}
+
#undef APPEND