blob: 2a74afc5bb7a0dee21c90d4fa1d70eed8ba89c69 [file] [log] [blame]
Stan Iliev52771272016-11-17 09:54:38 -05001/*
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 Iliev52771272016-11-17 09:54:38 -050019#include <SkCanvas.h>
John Reck1bcacfd2017-11-03 10:12:19 -070020#include <gtest/gtest.h>
Stan Iliev52771272016-11-17 09:54:38 -050021
22namespace {
23
24class TestCanvasBase : public SkCanvas {
25public:
John Reck1bcacfd2017-11-03 10:12:19 -070026 TestCanvasBase(int width, int height) : SkCanvas(width, height) {}
Stan Iliev52771272016-11-17 09:54:38 -050027 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 }
Stan Iliev52771272016-11-17 09:54:38 -050033 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
34 ADD_FAILURE() << "onDrawTextBlob not expected in this test";
35 }
36 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
John Reck1bcacfd2017-11-03 10:12:19 -070037 SkBlendMode, const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050038 ADD_FAILURE() << "onDrawPatch not expected in this test";
39 }
John Reck1bcacfd2017-11-03 10:12:19 -070040 void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; }
Stan Iliev52771272016-11-17 09:54:38 -050041 void onDrawRect(const SkRect&, const SkPaint&) {
42 ADD_FAILURE() << "onDrawRect not expected in this test";
43 }
44 void onDrawRegion(const SkRegion& region, const SkPaint& paint) {
45 ADD_FAILURE() << "onDrawRegion not expected in this test";
46 }
47 void onDrawOval(const SkRect&, const SkPaint&) {
48 ADD_FAILURE() << "onDrawOval not expected in this test";
49 }
50 void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
John Reck1bcacfd2017-11-03 10:12:19 -070051 const SkPaint&) {
Stan Iliev52771272016-11-17 09:54:38 -050052 ADD_FAILURE() << "onDrawArc not expected in this test";
53 }
54 void onDrawRRect(const SkRRect&, const SkPaint&) {
55 ADD_FAILURE() << "onDrawRRect not expected in this test";
56 }
57 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) {
58 ADD_FAILURE() << "onDrawPoints not expected in this test";
59 }
Mike Reed871cd2d2017-03-17 10:15:52 -040060 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) {
Stan Iliev52771272016-11-17 09:54:38 -050061 ADD_FAILURE() << "onDrawVertices not expected in this test";
62 }
Mike Reed2d1279f2020-12-30 09:57:25 -050063 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
64 SkBlendMode, const SkSamplingOptions&, const SkRect* cull, const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -050065 ADD_FAILURE() << "onDrawAtlas not expected in this test";
66 }
67 void onDrawPath(const SkPath&, const SkPaint&) {
68 ADD_FAILURE() << "onDrawPath not expected in this test";
69 }
Mike Reed2d1279f2020-12-30 09:57:25 -050070 void onDrawImage2(const SkImage*, SkScalar dx, SkScalar dy, const SkSamplingOptions&,
71 const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -050072 ADD_FAILURE() << "onDrawImage not expected in this test";
73 }
Mike Reed2d1279f2020-12-30 09:57:25 -050074 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
75 const SkPaint*, SrcRectConstraint) {
Stan Iliev52771272016-11-17 09:54:38 -050076 ADD_FAILURE() << "onDrawImageRect not expected in this test";
77 }
Mike Reed2d1279f2020-12-30 09:57:25 -050078 void onDrawImageLattice2(const SkImage*, const Lattice& lattice, const SkRect& dst,
79 SkFilterMode, const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -050080 ADD_FAILURE() << "onDrawImageLattice not expected in this test";
81 }
Mike Reedd43eaa92016-12-13 12:32:37 -050082 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
Stan Iliev52771272016-11-17 09:54:38 -050083 ADD_FAILURE() << "onClipRRect not expected in this test";
84 }
Mike Reedd43eaa92016-12-13 12:32:37 -050085 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) {
Stan Iliev52771272016-11-17 09:54:38 -050086 ADD_FAILURE() << "onClipPath not expected in this test";
87 }
Mike Reedd43eaa92016-12-13 12:32:37 -050088 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
Stan Iliev52771272016-11-17 09:54:38 -050089 ADD_FAILURE() << "onClipRegion not expected in this test";
90 }
John Reck1bcacfd2017-11-03 10:12:19 -070091 void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; }
Stan Iliev52771272016-11-17 09:54:38 -050092 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) {
93 ADD_FAILURE() << "onDrawPicture not expected in this test";
94 }
95
John Reck1bcacfd2017-11-03 10:12:19 -070096 int mDrawCounter = 0; // counts how may draw calls of any kind were made to this canvas
Stan Iliev52771272016-11-17 09:54:38 -050097};
Mike Reed36822512018-12-20 12:55:26 -050098}