1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/utils/SkProxyCanvas.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,196 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 +#include "SkProxyCanvas.h" 1.12 + 1.13 +SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) { 1.14 + SkSafeRef(fProxy); 1.15 +} 1.16 + 1.17 +SkProxyCanvas::~SkProxyCanvas() { 1.18 + SkSafeUnref(fProxy); 1.19 +} 1.20 + 1.21 +void SkProxyCanvas::setProxy(SkCanvas* proxy) { 1.22 + SkRefCnt_SafeAssign(fProxy, proxy); 1.23 +} 1.24 + 1.25 +///////////////////////////////// Overrides /////////// 1.26 + 1.27 +void SkProxyCanvas::willSave(SaveFlags flags) { 1.28 + fProxy->save(flags); 1.29 + this->INHERITED::willSave(flags); 1.30 +} 1.31 + 1.32 +SkCanvas::SaveLayerStrategy SkProxyCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, 1.33 + SaveFlags flags) { 1.34 + fProxy->saveLayer(bounds, paint, flags); 1.35 + this->INHERITED::willSaveLayer(bounds, paint, flags); 1.36 + // No need for a layer. 1.37 + return kNoLayer_SaveLayerStrategy; 1.38 +} 1.39 + 1.40 +void SkProxyCanvas::willRestore() { 1.41 + fProxy->restore(); 1.42 + this->INHERITED::willRestore(); 1.43 +} 1.44 + 1.45 +void SkProxyCanvas::didTranslate(SkScalar dx, SkScalar dy) { 1.46 + fProxy->translate(dx, dy); 1.47 + this->INHERITED::didTranslate(dx, dy); 1.48 +} 1.49 + 1.50 +void SkProxyCanvas::didScale(SkScalar sx, SkScalar sy) { 1.51 + fProxy->scale(sx, sy); 1.52 + this->INHERITED::didScale(sx, sy); 1.53 +} 1.54 + 1.55 +void SkProxyCanvas::didRotate(SkScalar degrees) { 1.56 + fProxy->rotate(degrees); 1.57 + this->INHERITED::didRotate(degrees); 1.58 +} 1.59 + 1.60 +void SkProxyCanvas::didSkew(SkScalar sx, SkScalar sy) { 1.61 + fProxy->skew(sx, sy); 1.62 + this->INHERITED::didSkew(sx, sy); 1.63 +} 1.64 + 1.65 +void SkProxyCanvas::didConcat(const SkMatrix& matrix) { 1.66 + fProxy->concat(matrix); 1.67 + this->INHERITED::didConcat(matrix); 1.68 +} 1.69 + 1.70 +void SkProxyCanvas::didSetMatrix(const SkMatrix& matrix) { 1.71 + fProxy->setMatrix(matrix); 1.72 + this->INHERITED::didSetMatrix(matrix); 1.73 +} 1.74 + 1.75 +void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.76 + fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); 1.77 +} 1.78 + 1.79 +void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.80 + fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); 1.81 +} 1.82 + 1.83 +void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.84 + fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); 1.85 +} 1.86 + 1.87 +void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 1.88 + fProxy->clipRegion(deviceRgn, op); 1.89 +} 1.90 + 1.91 +void SkProxyCanvas::drawPaint(const SkPaint& paint) { 1.92 + fProxy->drawPaint(paint); 1.93 +} 1.94 + 1.95 +void SkProxyCanvas::drawPoints(PointMode mode, size_t count, 1.96 + const SkPoint pts[], const SkPaint& paint) { 1.97 + fProxy->drawPoints(mode, count, pts, paint); 1.98 +} 1.99 + 1.100 +void SkProxyCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { 1.101 + fProxy->drawOval(rect, paint); 1.102 +} 1.103 + 1.104 +void SkProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { 1.105 + fProxy->drawRect(rect, paint); 1.106 +} 1.107 + 1.108 +void SkProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 1.109 + fProxy->drawRRect(rrect, paint); 1.110 +} 1.111 + 1.112 +void SkProxyCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 1.113 + const SkPaint& paint) { 1.114 + fProxy->drawDRRect(outer, inner, paint); 1.115 +} 1.116 + 1.117 +void SkProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 1.118 + fProxy->drawPath(path, paint); 1.119 +} 1.120 + 1.121 +void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, 1.122 + const SkPaint* paint) { 1.123 + fProxy->drawBitmap(bitmap, x, y, paint); 1.124 +} 1.125 + 1.126 +void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 1.127 + const SkRect& dst, const SkPaint* paint, 1.128 + DrawBitmapRectFlags flags) { 1.129 + fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags); 1.130 +} 1.131 + 1.132 +void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 1.133 + const SkPaint* paint) { 1.134 + fProxy->drawBitmapMatrix(bitmap, m, paint); 1.135 +} 1.136 + 1.137 +void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 1.138 + const SkPaint* paint) { 1.139 + fProxy->drawSprite(bitmap, x, y, paint); 1.140 +} 1.141 + 1.142 +void SkProxyCanvas::drawText(const void* text, size_t byteLength, SkScalar x, 1.143 + SkScalar y, const SkPaint& paint) { 1.144 + fProxy->drawText(text, byteLength, x, y, paint); 1.145 +} 1.146 + 1.147 +void SkProxyCanvas::drawPosText(const void* text, size_t byteLength, 1.148 + const SkPoint pos[], const SkPaint& paint) { 1.149 + fProxy->drawPosText(text, byteLength, pos, paint); 1.150 +} 1.151 + 1.152 +void SkProxyCanvas::drawPosTextH(const void* text, size_t byteLength, 1.153 + const SkScalar xpos[], SkScalar constY, 1.154 + const SkPaint& paint) { 1.155 + fProxy->drawPosTextH(text, byteLength, xpos, constY, paint); 1.156 +} 1.157 + 1.158 +void SkProxyCanvas::drawTextOnPath(const void* text, size_t byteLength, 1.159 + const SkPath& path, const SkMatrix* matrix, 1.160 + const SkPaint& paint) { 1.161 + fProxy->drawTextOnPath(text, byteLength, path, matrix, paint); 1.162 +} 1.163 + 1.164 +void SkProxyCanvas::drawPicture(SkPicture& picture) { 1.165 + fProxy->drawPicture(picture); 1.166 +} 1.167 + 1.168 +void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount, 1.169 + const SkPoint vertices[], const SkPoint texs[], 1.170 + const SkColor colors[], SkXfermode* xmode, 1.171 + const uint16_t indices[], int indexCount, 1.172 + const SkPaint& paint) { 1.173 + fProxy->drawVertices(vmode, vertexCount, vertices, texs, colors, 1.174 + xmode, indices, indexCount, paint); 1.175 +} 1.176 + 1.177 +void SkProxyCanvas::drawData(const void* data, size_t length) { 1.178 + fProxy->drawData(data, length); 1.179 +} 1.180 + 1.181 +void SkProxyCanvas::beginCommentGroup(const char* description) { 1.182 + fProxy->beginCommentGroup(description); 1.183 +} 1.184 + 1.185 +void SkProxyCanvas::addComment(const char* kywd, const char* value) { 1.186 + fProxy->addComment(kywd, value); 1.187 +} 1.188 + 1.189 +void SkProxyCanvas::endCommentGroup() { 1.190 + fProxy->endCommentGroup(); 1.191 +} 1.192 + 1.193 +SkBounder* SkProxyCanvas::setBounder(SkBounder* bounder) { 1.194 + return fProxy->setBounder(bounder); 1.195 +} 1.196 + 1.197 +SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) { 1.198 + return fProxy->setDrawFilter(filter); 1.199 +}