Home | History | Annotate | Download | only in utils
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 #include "SkProxyCanvas.h"
      9 
     10 SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) {
     11     SkSafeRef(fProxy);
     12 }
     13 
     14 SkProxyCanvas::~SkProxyCanvas() {
     15     SkSafeUnref(fProxy);
     16 }
     17 
     18 void SkProxyCanvas::setProxy(SkCanvas* proxy) {
     19     SkRefCnt_SafeAssign(fProxy, proxy);
     20 }
     21 
     22 ///////////////////////////////// Overrides ///////////
     23 
     24 void SkProxyCanvas::willSave(SaveFlags flags) {
     25     fProxy->save(flags);
     26     this->INHERITED::willSave(flags);
     27 }
     28 
     29 SkCanvas::SaveLayerStrategy SkProxyCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,
     30                                                          SaveFlags flags) {
     31     fProxy->saveLayer(bounds, paint, flags);
     32     this->INHERITED::willSaveLayer(bounds, paint, flags);
     33     // No need for a layer.
     34     return kNoLayer_SaveLayerStrategy;
     35 }
     36 
     37 void SkProxyCanvas::willRestore() {
     38     fProxy->restore();
     39     this->INHERITED::willRestore();
     40 }
     41 
     42 void SkProxyCanvas::didConcat(const SkMatrix& matrix) {
     43     fProxy->concat(matrix);
     44     this->INHERITED::didConcat(matrix);
     45 }
     46 
     47 void SkProxyCanvas::didSetMatrix(const SkMatrix& matrix) {
     48     fProxy->setMatrix(matrix);
     49     this->INHERITED::didSetMatrix(matrix);
     50 }
     51 
     52 void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
     53     fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
     54 }
     55 
     56 void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
     57     fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
     58 }
     59 
     60 void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
     61     fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
     62 }
     63 
     64 void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
     65     fProxy->clipRegion(deviceRgn, op);
     66 }
     67 
     68 void SkProxyCanvas::drawPaint(const SkPaint& paint) {
     69     fProxy->drawPaint(paint);
     70 }
     71 
     72 void SkProxyCanvas::drawPoints(PointMode mode, size_t count,
     73                                const SkPoint pts[], const SkPaint& paint) {
     74     fProxy->drawPoints(mode, count, pts, paint);
     75 }
     76 
     77 void SkProxyCanvas::drawOval(const SkRect& rect, const SkPaint& paint) {
     78     fProxy->drawOval(rect, paint);
     79 }
     80 
     81 void SkProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
     82     fProxy->drawRect(rect, paint);
     83 }
     84 
     85 void SkProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
     86     fProxy->drawRRect(rrect, paint);
     87 }
     88 
     89 void SkProxyCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
     90                                  const SkPaint& paint) {
     91     fProxy->drawDRRect(outer, inner, paint);
     92 }
     93 
     94 void SkProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
     95     fProxy->drawPath(path, paint);
     96 }
     97 
     98 void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
     99                                const SkPaint* paint) {
    100     fProxy->drawBitmap(bitmap, x, y, paint);
    101 }
    102 
    103 void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
    104                                    const SkRect& dst, const SkPaint* paint,
    105                                    DrawBitmapRectFlags flags) {
    106     fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
    107 }
    108 
    109 void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
    110                                      const SkPaint* paint) {
    111     fProxy->drawBitmapMatrix(bitmap, m, paint);
    112 }
    113 
    114 void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
    115                                const SkPaint* paint) {
    116     fProxy->drawSprite(bitmap, x, y, paint);
    117 }
    118 
    119 void SkProxyCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
    120                                const SkPaint& paint) {
    121     fProxy->drawText(text, byteLength, x, y, paint);
    122 }
    123 
    124 void SkProxyCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
    125                                   const SkPaint& paint) {
    126     fProxy->drawPosText(text, byteLength, pos, paint);
    127 }
    128 
    129 void SkProxyCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
    130                                    SkScalar constY, const SkPaint& paint) {
    131     fProxy->drawPosTextH(text, byteLength, xpos, constY, paint);
    132 }
    133 
    134 void SkProxyCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
    135                                      const SkMatrix* matrix, const SkPaint& paint) {
    136     fProxy->drawTextOnPath(text, byteLength, path, matrix, paint);
    137 }
    138 
    139 void SkProxyCanvas::onDrawPicture(const SkPicture* picture) {
    140     fProxy->drawPicture(picture);
    141 }
    142 
    143 void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount,
    144                                  const SkPoint vertices[], const SkPoint texs[],
    145                                  const SkColor colors[], SkXfermode* xmode,
    146                                  const uint16_t indices[], int indexCount,
    147                                  const SkPaint& paint) {
    148     fProxy->drawVertices(vmode, vertexCount, vertices, texs, colors,
    149                                      xmode, indices, indexCount, paint);
    150 }
    151 
    152 void SkProxyCanvas::drawData(const void* data, size_t length) {
    153     fProxy->drawData(data, length);
    154 }
    155 
    156 void SkProxyCanvas::beginCommentGroup(const char* description) {
    157     fProxy->beginCommentGroup(description);
    158 }
    159 
    160 void SkProxyCanvas::addComment(const char* kywd, const char* value) {
    161     fProxy->addComment(kywd, value);
    162 }
    163 
    164 void SkProxyCanvas::endCommentGroup() {
    165     fProxy->endCommentGroup();
    166 }
    167 
    168 SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) {
    169     return fProxy->setDrawFilter(filter);
    170 }
    171