| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /* Description: | 9 /* Description: |
| 10 * This test defines a series of elementatry test steps that perform | 10 * This test defines a series of elementatry test steps that perform |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "SkPDFDocument.h" | 54 #include "SkPDFDocument.h" |
| 55 #include "SkPaint.h" | 55 #include "SkPaint.h" |
| 56 #include "SkPath.h" | 56 #include "SkPath.h" |
| 57 #include "SkPicture.h" | 57 #include "SkPicture.h" |
| 58 #include "SkPictureRecord.h" | 58 #include "SkPictureRecord.h" |
| 59 #include "SkProxyCanvas.h" | 59 #include "SkProxyCanvas.h" |
| 60 #include "SkRect.h" | 60 #include "SkRect.h" |
| 61 #include "SkRegion.h" | 61 #include "SkRegion.h" |
| 62 #include "SkShader.h" | 62 #include "SkShader.h" |
| 63 #include "SkStream.h" | 63 #include "SkStream.h" |
| 64 #include "SkSurface.h" |
| 64 #include "SkTDArray.h" | 65 #include "SkTDArray.h" |
| 65 #include "Test.h" | 66 #include "Test.h" |
| 66 | 67 |
| 67 class Canvas2CanvasClipVisitor : public SkCanvas::ClipVisitor { | 68 class Canvas2CanvasClipVisitor : public SkCanvas::ClipVisitor { |
| 68 public: | 69 public: |
| 69 Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {} | 70 Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {} |
| 70 | 71 |
| 71 virtual void clipRect(const SkRect& r, SkRegion::Op op, bool aa) { | 72 virtual void clipRect(const SkRect& r, SkRegion::Op op, bool aa) { |
| 72 fTarget->clipRect(r, op, aa); | 73 fTarget->clipRect(r, op, aa); |
| 73 } | 74 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 "test step %s, SkNWayCanvas indirect canvas 2 state consistency"; | 134 "test step %s, SkNWayCanvas indirect canvas 2 state consistency"; |
| 134 static const char* const kPdfAssertMessageFormat = | 135 static const char* const kPdfAssertMessageFormat = |
| 135 "PDF sanity check failed %s"; | 136 "PDF sanity check failed %s"; |
| 136 | 137 |
| 137 static void createBitmap(SkBitmap* bm, SkBitmap::Config config, SkColor color) { | 138 static void createBitmap(SkBitmap* bm, SkBitmap::Config config, SkColor color) { |
| 138 bm->setConfig(config, kWidth, kHeight); | 139 bm->setConfig(config, kWidth, kHeight); |
| 139 bm->allocPixels(); | 140 bm->allocPixels(); |
| 140 bm->eraseColor(color); | 141 bm->eraseColor(color); |
| 141 } | 142 } |
| 142 | 143 |
| 144 static SkSurface* createSurface(SkColor color) { |
| 145 SkSurface* surface = SkSurface::NewRasterPMColor(kWidth, kHeight); |
| 146 surface->getCanvas()->clear(color); |
| 147 return surface; |
| 148 } |
| 149 |
| 143 class CanvasTestStep; | 150 class CanvasTestStep; |
| 144 static SkTDArray<CanvasTestStep*>& testStepArray() { | 151 static SkTDArray<CanvasTestStep*>& testStepArray() { |
| 145 static SkTDArray<CanvasTestStep*> theTests; | 152 static SkTDArray<CanvasTestStep*> theTests; |
| 146 return theTests; | 153 return theTests; |
| 147 } | 154 } |
| 148 | 155 |
| 149 class CanvasTestStep { | 156 class CanvasTestStep { |
| 150 public: | 157 public: |
| 151 CanvasTestStep(bool fEnablePdfTesting = true) { | 158 CanvasTestStep(bool fEnablePdfTesting = true) { |
| 152 *testStepArray().append() = this; | 159 *testStepArray().append() = this; |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 749 |
| 743 // The following class groups static functions that need to access | 750 // The following class groups static functions that need to access |
| 744 // the privates members of SkDeferredCanvas | 751 // the privates members of SkDeferredCanvas |
| 745 class SkDeferredCanvasTester { | 752 class SkDeferredCanvasTester { |
| 746 public: | 753 public: |
| 747 static void TestDeferredCanvasStateConsistency( | 754 static void TestDeferredCanvasStateConsistency( |
| 748 skiatest::Reporter* reporter, | 755 skiatest::Reporter* reporter, |
| 749 CanvasTestStep* testStep, | 756 CanvasTestStep* testStep, |
| 750 const SkCanvas& referenceCanvas, bool silent) { | 757 const SkCanvas& referenceCanvas, bool silent) { |
| 751 | 758 |
| 752 SkBitmap deferredStore; | 759 SkAutoTUnref<SkSurface> surface(createSurface(0xFFFFFFFF)); |
| 753 createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); | 760 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(s
urface.get())); |
| 754 SkBitmapDevice deferredDevice(deferredStore); | 761 |
| 755 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(&
deferredDevice)); | |
| 756 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); | 762 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); |
| 757 testStep->draw(deferredCanvas, reporter); | 763 testStep->draw(deferredCanvas, reporter); |
| 758 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); | 764 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); |
| 759 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas, | 765 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas, |
| 760 testStep); | 766 testStep); |
| 761 | 767 |
| 762 if (silent) { | 768 if (silent) { |
| 763 deferredCanvas->silentFlush(); | 769 deferredCanvas->silentFlush(); |
| 764 } else { | 770 } else { |
| 765 deferredCanvas->flush(); | 771 deferredCanvas->flush(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 SkPictureTester::TestPictureFlattenedObjectReuse(reporter, | 901 SkPictureTester::TestPictureFlattenedObjectReuse(reporter, |
| 896 testStepArray()[testStep], 0); | 902 testStepArray()[testStep], 0); |
| 897 if (testStepArray()[testStep]->enablePdfTesting()) { | 903 if (testStepArray()[testStep]->enablePdfTesting()) { |
| 898 TestPdfDevice(reporter, testStepArray()[testStep]); | 904 TestPdfDevice(reporter, testStepArray()[testStep]); |
| 899 } | 905 } |
| 900 } | 906 } |
| 901 | 907 |
| 902 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) | 908 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) |
| 903 kTestBitmap.reset(); | 909 kTestBitmap.reset(); |
| 904 } | 910 } |
| OLD | NEW |