| 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 |  | 
| Kevin Lubick | 856848e | 2022-02-24 16:24:09 +0000 | [diff] [blame] | 22 | class SkRRect; | 
|  | 23 |  | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 24 | namespace { | 
|  | 25 |  | 
|  | 26 | class TestCanvasBase : public SkCanvas { | 
|  | 27 | public: | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 28 | TestCanvasBase(int width, int height) : SkCanvas(width, height) {} | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 29 | void onDrawAnnotation(const SkRect&, const char key[], SkData* value) { | 
|  | 30 | ADD_FAILURE() << "onDrawAnnotation not expected in this test"; | 
|  | 31 | } | 
|  | 32 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) { | 
|  | 33 | ADD_FAILURE() << "onDrawDRRect not expected in this test"; | 
|  | 34 | } | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 35 | void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { | 
|  | 36 | ADD_FAILURE() << "onDrawTextBlob not expected in this test"; | 
|  | 37 | } | 
|  | 38 | 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] | 39 | SkBlendMode, const SkPaint& paint) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 40 | ADD_FAILURE() << "onDrawPatch not expected in this test"; | 
|  | 41 | } | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 42 | void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; } | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 43 | void onDrawRect(const SkRect&, const SkPaint&) { | 
|  | 44 | ADD_FAILURE() << "onDrawRect not expected in this test"; | 
|  | 45 | } | 
|  | 46 | void onDrawRegion(const SkRegion& region, const SkPaint& paint) { | 
|  | 47 | ADD_FAILURE() << "onDrawRegion not expected in this test"; | 
|  | 48 | } | 
|  | 49 | void onDrawOval(const SkRect&, const SkPaint&) { | 
|  | 50 | ADD_FAILURE() << "onDrawOval not expected in this test"; | 
|  | 51 | } | 
|  | 52 | void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 53 | const SkPaint&) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 54 | ADD_FAILURE() << "onDrawArc not expected in this test"; | 
|  | 55 | } | 
|  | 56 | void onDrawRRect(const SkRRect&, const SkPaint&) { | 
|  | 57 | ADD_FAILURE() << "onDrawRRect not expected in this test"; | 
|  | 58 | } | 
|  | 59 | void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) { | 
|  | 60 | ADD_FAILURE() << "onDrawPoints not expected in this test"; | 
|  | 61 | } | 
| Mike Reed | 871cd2d | 2017-03-17 10:15:52 -0400 | [diff] [blame] | 62 | void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 63 | ADD_FAILURE() << "onDrawVertices not expected in this test"; | 
|  | 64 | } | 
| Mike Reed | 2d1279f | 2020-12-30 09:57:25 -0500 | [diff] [blame] | 65 | void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count, | 
|  | 66 | SkBlendMode, const SkSamplingOptions&, const SkRect* cull, const SkPaint*) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 67 | ADD_FAILURE() << "onDrawAtlas not expected in this test"; | 
|  | 68 | } | 
|  | 69 | void onDrawPath(const SkPath&, const SkPaint&) { | 
|  | 70 | ADD_FAILURE() << "onDrawPath not expected in this test"; | 
|  | 71 | } | 
| Mike Reed | 2d1279f | 2020-12-30 09:57:25 -0500 | [diff] [blame] | 72 | void onDrawImage2(const SkImage*, SkScalar dx, SkScalar dy, const SkSamplingOptions&, | 
|  | 73 | const SkPaint*) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 74 | ADD_FAILURE() << "onDrawImage not expected in this test"; | 
|  | 75 | } | 
| Mike Reed | 2d1279f | 2020-12-30 09:57:25 -0500 | [diff] [blame] | 76 | void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&, | 
|  | 77 | const SkPaint*, SrcRectConstraint) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 78 | ADD_FAILURE() << "onDrawImageRect not expected in this test"; | 
|  | 79 | } | 
| Mike Reed | 2d1279f | 2020-12-30 09:57:25 -0500 | [diff] [blame] | 80 | void onDrawImageLattice2(const SkImage*, const Lattice& lattice, const SkRect& dst, | 
|  | 81 | SkFilterMode, const SkPaint*) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 82 | ADD_FAILURE() << "onDrawImageLattice not expected in this test"; | 
|  | 83 | } | 
| Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 84 | void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 85 | ADD_FAILURE() << "onClipRRect not expected in this test"; | 
|  | 86 | } | 
| Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 87 | void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 88 | ADD_FAILURE() << "onClipPath not expected in this test"; | 
|  | 89 | } | 
| Mike Reed | d43eaa9 | 2016-12-13 12:32:37 -0500 | [diff] [blame] | 90 | void onClipRegion(const SkRegion& deviceRgn, SkClipOp) { | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 91 | ADD_FAILURE() << "onClipRegion not expected in this test"; | 
|  | 92 | } | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 93 | void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; } | 
| Stan Iliev | 5277127 | 2016-11-17 09:54:38 -0500 | [diff] [blame] | 94 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) { | 
|  | 95 | ADD_FAILURE() << "onDrawPicture not expected in this test"; | 
|  | 96 | } | 
|  | 97 |  | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 98 | 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] | 99 | }; | 
| Mike Reed | 3682251 | 2018-12-20 12:55:26 -0500 | [diff] [blame] | 100 | } |