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 <gtest/gtest.h> 20 #include <SkCanvas.h> 21 22 namespace { 23 24 class TestCanvasBase : public SkCanvas { 25 public: TestCanvasBase(int width,int height)26 TestCanvasBase(int width, int height) : SkCanvas(width, height) { 27 } onDrawAnnotation(const SkRect &,const char key[],SkData * value)28 void onDrawAnnotation(const SkRect&, const char key[], SkData* value) { 29 ADD_FAILURE() << "onDrawAnnotation not expected in this test"; 30 } onDrawDRRect(const SkRRect &,const SkRRect &,const SkPaint &)31 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) { 32 ADD_FAILURE() << "onDrawDRRect not expected in this test"; 33 } onDrawText(const void * text,size_t byteLength,SkScalar x,SkScalar y,const SkPaint & paint)34 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 35 const SkPaint& paint) { 36 ADD_FAILURE() << "onDrawText not expected in this test"; 37 } onDrawPosText(const void * text,size_t byteLength,const SkPoint pos[],const SkPaint & paint)38 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 39 const SkPaint& paint) { 40 ADD_FAILURE() << "onDrawPosText not expected in this test"; 41 } onDrawPosTextH(const void * text,size_t byteLength,const SkScalar xpos[],SkScalar constY,const SkPaint & paint)42 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, 43 const SkPaint& paint) { 44 ADD_FAILURE() << "onDrawPosTextH not expected in this test"; 45 } onDrawTextOnPath(const void * text,size_t byteLength,const SkPath & path,const SkMatrix * matrix,const SkPaint & paint)46 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 47 const SkMatrix* matrix, const SkPaint& paint) { 48 ADD_FAILURE() << "onDrawTextOnPath not expected in this test"; 49 } onDrawTextRSXform(const void * text,size_t byteLength,const SkRSXform[],const SkRect * cullRect,const SkPaint & paint)50 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], 51 const SkRect* cullRect, const SkPaint& paint) { 52 ADD_FAILURE() << "onDrawTextRSXform not expected in this test"; 53 } onDrawTextBlob(const SkTextBlob * blob,SkScalar x,SkScalar y,const SkPaint & paint)54 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { 55 ADD_FAILURE() << "onDrawTextBlob not expected in this test"; 56 } onDrawPatch(const SkPoint cubics[12],const SkColor colors[4],const SkPoint texCoords[4],SkBlendMode,const SkPaint & paint)57 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], 58 SkBlendMode, const SkPaint& paint) { 59 ADD_FAILURE() << "onDrawPatch not expected in this test"; 60 } onDrawPaint(const SkPaint &)61 void onDrawPaint(const SkPaint&) { 62 ADD_FAILURE() << "onDrawPaint not expected in this test"; 63 } onDrawRect(const SkRect &,const SkPaint &)64 void onDrawRect(const SkRect&, const SkPaint&) { 65 ADD_FAILURE() << "onDrawRect not expected in this test"; 66 } onDrawRegion(const SkRegion & region,const SkPaint & paint)67 void onDrawRegion(const SkRegion& region, const SkPaint& paint) { 68 ADD_FAILURE() << "onDrawRegion not expected in this test"; 69 } onDrawOval(const SkRect &,const SkPaint &)70 void onDrawOval(const SkRect&, const SkPaint&) { 71 ADD_FAILURE() << "onDrawOval not expected in this test"; 72 } onDrawArc(const SkRect &,SkScalar startAngle,SkScalar sweepAngle,bool useCenter,const SkPaint &)73 void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, 74 const SkPaint&) { 75 ADD_FAILURE() << "onDrawArc not expected in this test"; 76 } onDrawRRect(const SkRRect &,const SkPaint &)77 void onDrawRRect(const SkRRect&, const SkPaint&) { 78 ADD_FAILURE() << "onDrawRRect not expected in this test"; 79 } onDrawPoints(PointMode,size_t count,const SkPoint pts[],const SkPaint &)80 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) { 81 ADD_FAILURE() << "onDrawPoints not expected in this test"; 82 } onDrawVerticesObject(const SkVertices *,SkBlendMode,const SkPaint &)83 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) { 84 ADD_FAILURE() << "onDrawVertices not expected in this test"; 85 } onDrawAtlas(const SkImage *,const SkRSXform[],const SkRect[],const SkColor[],int count,SkBlendMode,const SkRect * cull,const SkPaint *)86 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count, 87 SkBlendMode, const SkRect* cull, const SkPaint*) { 88 ADD_FAILURE() << "onDrawAtlas not expected in this test"; 89 } onDrawPath(const SkPath &,const SkPaint &)90 void onDrawPath(const SkPath&, const SkPaint&) { 91 ADD_FAILURE() << "onDrawPath not expected in this test"; 92 } onDrawImage(const SkImage *,SkScalar dx,SkScalar dy,const SkPaint *)93 void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) { 94 ADD_FAILURE() << "onDrawImage not expected in this test"; 95 } onDrawImageRect(const SkImage *,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)96 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, 97 SrcRectConstraint) { 98 ADD_FAILURE() << "onDrawImageRect not expected in this test"; 99 } onDrawImageNine(const SkImage *,const SkIRect & center,const SkRect & dst,const SkPaint *)100 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) { 101 ADD_FAILURE() << "onDrawImageNine not expected in this test"; 102 } onDrawImageLattice(const SkImage *,const Lattice & lattice,const SkRect & dst,const SkPaint *)103 void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst, 104 const SkPaint*) { 105 ADD_FAILURE() << "onDrawImageLattice not expected in this test"; 106 } onDrawBitmap(const SkBitmap &,SkScalar dx,SkScalar dy,const SkPaint *)107 void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) { 108 ADD_FAILURE() << "onDrawBitmap not expected in this test"; 109 } onDrawBitmapRect(const SkBitmap &,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)110 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, 111 SrcRectConstraint) { 112 ADD_FAILURE() << "onDrawBitmapRect not expected in this test"; 113 } onDrawBitmapNine(const SkBitmap &,const SkIRect & center,const SkRect & dst,const SkPaint *)114 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 115 const SkPaint*) { 116 ADD_FAILURE() << "onDrawBitmapNine not expected in this test"; 117 } onDrawBitmapLattice(const SkBitmap &,const Lattice & lattice,const SkRect & dst,const SkPaint *)118 void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst, 119 const SkPaint*) { 120 ADD_FAILURE() << "onDrawBitmapLattice not expected in this test"; 121 } onClipRRect(const SkRRect & rrect,SkClipOp,ClipEdgeStyle)122 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) { 123 ADD_FAILURE() << "onClipRRect not expected in this test"; 124 } onClipPath(const SkPath & path,SkClipOp,ClipEdgeStyle)125 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) { 126 ADD_FAILURE() << "onClipPath not expected in this test"; 127 } onClipRegion(const SkRegion & deviceRgn,SkClipOp)128 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) { 129 ADD_FAILURE() << "onClipRegion not expected in this test"; 130 } onDiscard()131 void onDiscard() { 132 ADD_FAILURE() << "onDiscard not expected in this test"; 133 } onDrawPicture(const SkPicture *,const SkMatrix *,const SkPaint *)134 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) { 135 ADD_FAILURE() << "onDrawPicture not expected in this test"; 136 } 137 138 int mDrawCounter = 0; //counts how may draw calls of any kind were made to this canvas 139 }; 140 141 }