Index: tests/RecordReplaceDrawTest.cpp |
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp |
index 8fc824d8ccb6c664481e07057ed6c5a9d7001731..edd4766c5f5c29d089a97c1a9826bcf509d8bac4 100644 |
--- a/tests/RecordReplaceDrawTest.cpp |
+++ b/tests/RecordReplaceDrawTest.cpp |
@@ -9,6 +9,8 @@ |
#include "Test.h" |
+#include "GrContextFactory.h" |
+#include "GrLayerCache.h" |
#include "GrRecordReplaceDraw.h" |
#include "RecordTestUtils.h" |
#include "SkBBHFactory.h" |
@@ -47,9 +49,8 @@ DEF_TEST(RecordReplaceDraw_Abort, r) { |
SkRecord rerecord; |
SkRecorder canvas(&rerecord, kWidth, kHeight); |
- GrReplacements replacements; |
JustOneDraw callback; |
- GrRecordReplaceDraw(pic, &canvas, &replacements, SkMatrix::I(), &callback); |
+ GrRecordReplaceDraw(pic, &canvas, NULL, SkMatrix::I(), &callback); |
REPORTER_ASSERT(r, 3 == rerecord.count()); |
assert_type<SkRecords::Save>(r, rerecord, 0); |
@@ -74,8 +75,7 @@ DEF_TEST(RecordReplaceDraw_Unbalanced, r) { |
SkRecord rerecord; |
SkRecorder canvas(&rerecord, kWidth, kHeight); |
- GrReplacements replacements; |
- GrRecordReplaceDraw(pic, &canvas, &replacements, SkMatrix::I(), NULL/*callback*/); |
+ GrRecordReplaceDraw(pic, &canvas, NULL, SkMatrix::I(), NULL/*callback*/); |
REPORTER_ASSERT(r, 4 == rerecord.count()); |
assert_type<SkRecords::Save>(r, rerecord, 0); |
@@ -84,20 +84,8 @@ DEF_TEST(RecordReplaceDraw_Unbalanced, r) { |
assert_type<SkRecords::Restore>(r, rerecord, 3); |
} |
-static SkImage* make_image(SkColor color) { |
- const SkPMColor pmcolor = SkPreMultiplyColor(color); |
- const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
- const size_t rowBytes = info.minRowBytes(); |
- const size_t size = rowBytes * info.height(); |
- |
- SkAutoMalloc addr(size); |
- sk_memset32((SkPMColor*)addr.get(), pmcolor, SkToInt(size >> 2)); |
- |
- return SkImage::NewRasterCopy(info, addr.get(), rowBytes); |
-} |
- |
// Test out the layer replacement functionality with and w/o a BBH |
-void test_replacements(skiatest::Reporter* r, bool useBBH) { |
+void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) { |
SkAutoTUnref<const SkPicture> pic; |
{ |
@@ -115,34 +103,53 @@ void test_replacements(skiatest::Reporter* r, bool useBBH) { |
pic.reset(recorder.endRecording()); |
} |
- int key[1] = { 0 }; |
+ unsigned key[1] = { 0 }; |
- GrReplacements replacements; |
- GrReplacements::ReplacementInfo* ri = replacements.newReplacement(pic->uniqueID(), |
- SkMatrix::I(), key, 1); |
- ri->fStop = 2; |
- ri->fPos.set(0, 0); |
- ri->fImage = make_image(SK_ColorRED); |
- ri->fPaint = SkNEW(SkPaint); |
- ri->fSrcRect = SkIRect::MakeWH(kWidth, kHeight); |
+ GrLayerCache* layerCache = context->getLayerCache(); |
+ GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2, |
+ SkIRect::MakeWH(kWidth, kHeight), |
+ SkMatrix::I(), key, 1, SkNEW(SkPaint)); |
+ |
+ GrSurfaceDesc desc; |
+ desc.fConfig = kSkia8888_GrPixelConfig; |
+ desc.fFlags = kRenderTarget_GrSurfaceFlag; |
+ desc.fWidth = kWidth; |
+ desc.fHeight = kHeight; |
+ desc.fSampleCnt = 0; |
+ |
+ SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0)); |
+ layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight)); |
SkAutoTUnref<SkBBoxHierarchy> bbh; |
SkRecord rerecord; |
SkRecorder canvas(&rerecord, kWidth, kHeight); |
- GrRecordReplaceDraw(pic, &canvas, &replacements, SkMatrix::I(), NULL/*callback*/); |
+ GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), NULL/*callback*/); |
REPORTER_ASSERT(r, 7 == rerecord.count()); |
assert_type<SkRecords::Save>(r, rerecord, 0); |
assert_type<SkRecords::Save>(r, rerecord, 1); |
assert_type<SkRecords::SetMatrix>(r, rerecord, 2); |
- assert_type<SkRecords::DrawImageRect>(r, rerecord, 3); |
+ assert_type<SkRecords::DrawBitmapRectToRect>(r, rerecord, 3); |
assert_type<SkRecords::Restore>(r, rerecord, 4); |
assert_type<SkRecords::DrawRect>(r, rerecord, 5); |
assert_type<SkRecords::Restore>(r, rerecord, 6); |
} |
-DEF_TEST(RecordReplaceDraw_Replace, r) { test_replacements(r, false); } |
-DEF_TEST(RecordReplaceDraw_ReplaceWithBBH, r) { test_replacements(r, true); } |
+DEF_GPUTEST(RecordReplaceDraw, r, factory) { |
+ for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
+ GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type); |
+ if (!GrContextFactory::IsRenderingGLContext(glType)) { |
+ continue; |
+ } |
+ GrContext* context = factory->get(glType); |
+ if (NULL == context) { |
+ continue; |
+ } |
+ |
+ test_replacements(r, context, true); |
+ test_replacements(r, context, false); |
+ } |
+} |
#endif |