Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 19 | #include <SkCanvas.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 20 | #include <gtest/gtest.h> |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 21 | |
| 22 | namespace { |
| 23 | |
| 24 | class TestCanvasBase : public SkCanvas { |
| 25 | public: |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 26 | TestCanvasBase(int width, int height) : SkCanvas(width, height) {} |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 27 | void onDrawAnnotation(const SkRect&, const char key[], SkData* value) { |
| 28 | ADD_FAILURE() << "onDrawAnnotation not expected in this test"; |
| 29 | } |
| 30 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) { |
| 31 | ADD_FAILURE() << "onDrawDRRect not expected in this test"; |
| 32 | } |
| 33 | void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 34 | const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 35 | ADD_FAILURE() << "onDrawText not expected in this test"; |
| 36 | } |
| 37 | void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 38 | const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 39 | ADD_FAILURE() << "onDrawPosText not expected in this test"; |
| 40 | } |
| 41 | void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 42 | const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 43 | ADD_FAILURE() << "onDrawPosTextH not expected in this test"; |
| 44 | } |
| 45 | void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 46 | const SkMatrix* matrix, const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 47 | ADD_FAILURE() << "onDrawTextOnPath not expected in this test"; |
| 48 | } |
| 49 | void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 50 | const SkRect* cullRect, const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 51 | ADD_FAILURE() << "onDrawTextRSXform not expected in this test"; |
| 52 | } |
| 53 | void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { |
| 54 | ADD_FAILURE() << "onDrawTextBlob not expected in this test"; |
| 55 | } |
| 56 | void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 57 | SkBlendMode, const SkPaint& paint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 58 | ADD_FAILURE() << "onDrawPatch not expected in this test"; |
| 59 | } |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 60 | void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; } |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 61 | void onDrawRect(const SkRect&, const SkPaint&) { |
| 62 | ADD_FAILURE() << "onDrawRect not expected in this test"; |
| 63 | } |
| 64 | void onDrawRegion(const SkRegion& region, const SkPaint& paint) { |
| 65 | ADD_FAILURE() << "onDrawRegion not expected in this test"; |
| 66 | } |
| 67 | void onDrawOval(const SkRect&, const SkPaint&) { |
| 68 | ADD_FAILURE() << "onDrawOval not expected in this test"; |
| 69 | } |
| 70 | void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 71 | const SkPaint&) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 72 | ADD_FAILURE() << "onDrawArc not expected in this test"; |
| 73 | } |
| 74 | void onDrawRRect(const SkRRect&, const SkPaint&) { |
| 75 | ADD_FAILURE() << "onDrawRRect not expected in this test"; |
| 76 | } |
| 77 | void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) { |
| 78 | ADD_FAILURE() << "onDrawPoints not expected in this test"; |
| 79 | } |
Mike Reed | 871cd2d | 2017-03-17 10:15:52 -0400 | [diff] [blame] | 80 | void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 81 | ADD_FAILURE() << "onDrawVertices not expected in this test"; |
| 82 | } |
| 83 | void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 84 | SkBlendMode, const SkRect* cull, const SkPaint*) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 85 | ADD_FAILURE() << "onDrawAtlas not expected in this test"; |
| 86 | } |
| 87 | void onDrawPath(const SkPath&, const SkPaint&) { |
| 88 | ADD_FAILURE() << "onDrawPath not expected in this test"; |
| 89 | } |
| 90 | void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) { |
| 91 | ADD_FAILURE() << "onDrawImage not expected in this test"; |
| 92 | } |
| 93 | void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 94 | SrcRectConstraint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 95 | ADD_FAILURE() << "onDrawImageRect not expected in this test"; |
| 96 | } |
| 97 | void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) { |
| 98 | ADD_FAILURE() << "onDrawImageNine not expected in this test"; |
| 99 | } |
| 100 | void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 101 | const SkPaint*) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 102 | ADD_FAILURE() << "onDrawImageLattice not expected in this test"; |
| 103 | } |
| 104 | void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) { |
| 105 | ADD_FAILURE() << "onDrawBitmap not expected in this test"; |
| 106 | } |
| 107 | void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 108 | SrcRectConstraint) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 109 | ADD_FAILURE() << "onDrawBitmapRect not expected in this test"; |
| 110 | } |
| 111 | void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 112 | const SkPaint*) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 113 | ADD_FAILURE() << "onDrawBitmapNine not expected in this test"; |
| 114 | } |
| 115 | void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 116 | const SkPaint*) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 117 | ADD_FAILURE() << "onDrawBitmapLattice not expected in this test"; |
| 118 | } |
Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 119 | void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 120 | ADD_FAILURE() << "onClipRRect not expected in this test"; |
| 121 | } |
Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 122 | void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 123 | ADD_FAILURE() << "onClipPath not expected in this test"; |
| 124 | } |
Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 125 | void onClipRegion(const SkRegion& deviceRgn, SkClipOp) { |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 126 | ADD_FAILURE() << "onClipRegion not expected in this test"; |
| 127 | } |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 128 | void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; } |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 129 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) { |
| 130 | ADD_FAILURE() << "onDrawPicture not expected in this test"; |
| 131 | } |
| 132 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 133 | int mDrawCounter = 0; // counts how may draw calls of any kind were made to this canvas |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 134 | }; |
Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 135 | } |