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 19 #include <SkCanvas.h> 20 #include <gtest/gtest.h> 21 22 namespace { 23 24 class TestCanvasBase : public SkCanvas { 25 public: 26 TestCanvasBase(int width, int height) : SkCanvas(width, height) {} 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, 34 const SkPaint& paint) { 35 ADD_FAILURE() << "onDrawText not expected in this test"; 36 } 37 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 38 const SkPaint& paint) { 39 ADD_FAILURE() << "onDrawPosText not expected in this test"; 40 } 41 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, 42 const SkPaint& paint) { 43 ADD_FAILURE() << "onDrawPosTextH not expected in this test"; 44 } 45 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 46 const SkMatrix* matrix, const SkPaint& paint) { 47 ADD_FAILURE() << "onDrawTextOnPath not expected in this test"; 48 } 49 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], 50 const SkRect* cullRect, const SkPaint& paint) { 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], 57 SkBlendMode, const SkPaint& paint) { 58 ADD_FAILURE() << "onDrawPatch not expected in this test"; 59 } 60 void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; } 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, 71 const SkPaint&) { 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 } 80 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) { 81 ADD_FAILURE() << "onDrawVertices not expected in this test"; 82 } 83 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count, 84 SkBlendMode, const SkRect* cull, const SkPaint*) { 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*, 94 SrcRectConstraint) { 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, 101 const SkPaint*) { 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*, 108 SrcRectConstraint) { 109 ADD_FAILURE() << "onDrawBitmapRect not expected in this test"; 110 } 111 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 112 const SkPaint*) { 113 ADD_FAILURE() << "onDrawBitmapNine not expected in this test"; 114 } 115 void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst, 116 const SkPaint*) { 117 ADD_FAILURE() << "onDrawBitmapLattice not expected in this test"; 118 } 119 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) { 120 ADD_FAILURE() << "onClipRRect not expected in this test"; 121 } 122 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) { 123 ADD_FAILURE() << "onClipPath not expected in this test"; 124 } 125 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) { 126 ADD_FAILURE() << "onClipRegion not expected in this test"; 127 } 128 void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; } 129 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) { 130 ADD_FAILURE() << "onDrawPicture not expected in this test"; 131 } 132 133 int mDrawCounter = 0; // counts how may draw calls of any kind were made to this canvas 134 }; 135 }