• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "SkGLDevice_SWLayer.h"
2 #include "SkRegion.h"
3 
SkGLDevice_SWLayer(const SkBitmap & bitmap)4 SkGLDevice_SWLayer::SkGLDevice_SWLayer(const SkBitmap& bitmap)
5         : SkGLDevice(bitmap, true) {
6     fTextureID = 0;
7 
8     SkASSERT(bitmap.getPixels());
9 }
10 
~SkGLDevice_SWLayer()11 SkGLDevice_SWLayer::~SkGLDevice_SWLayer() {
12     if (fTextureID) {
13         glDeleteTextures(1, &fTextureID);
14     }
15 }
16 
bindDeviceAsTexture()17 SkGLDevice::TexOrientation SkGLDevice_SWLayer::bindDeviceAsTexture() {
18     const SkBitmap& bitmap = this->accessBitmap(false);
19 
20     if (0 == fTextureID) {
21         fTextureID = SkGL::BindNewTexture(bitmap, NULL);
22     }
23     return kTopToBottom_TexOrientation;
24 }
25 
26 ///////////////////////////////////////////////////////////////////////////////
27 
28 #include "SkDraw.h"
29 
drawPaint(const SkDraw & draw,const SkPaint & paint)30 void SkGLDevice_SWLayer::drawPaint(const SkDraw& draw, const SkPaint& paint) {
31     draw.drawPaint(paint);
32 }
33 
drawPoints(const SkDraw & draw,SkCanvas::PointMode mode,size_t count,const SkPoint pts[],const SkPaint & paint)34 void SkGLDevice_SWLayer::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
35                           const SkPoint pts[], const SkPaint& paint) {
36     draw.drawPoints(mode, count, pts, paint);
37 }
38 
drawRect(const SkDraw & draw,const SkRect & r,const SkPaint & paint)39 void SkGLDevice_SWLayer::drawRect(const SkDraw& draw, const SkRect& r,
40                         const SkPaint& paint) {
41     draw.drawRect(r, paint);
42 }
43 
drawPath(const SkDraw & draw,const SkPath & path,const SkPaint & paint)44 void SkGLDevice_SWLayer::drawPath(const SkDraw& draw, const SkPath& path,
45                         const SkPaint& paint) {
46     draw.drawPath(path, paint);
47 }
48 
drawBitmap(const SkDraw & draw,const SkBitmap & bitmap,const SkMatrix & matrix,const SkPaint & paint)49 void SkGLDevice_SWLayer::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
50                           const SkMatrix& matrix, const SkPaint& paint) {
51     draw.drawBitmap(bitmap, matrix, paint);
52 }
53 
drawSprite(const SkDraw & draw,const SkBitmap & bitmap,int x,int y,const SkPaint & paint)54 void SkGLDevice_SWLayer::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
55                           int x, int y, const SkPaint& paint) {
56     draw.drawSprite(bitmap, x, y, paint);
57 }
58 
drawText(const SkDraw & draw,const void * text,size_t len,SkScalar x,SkScalar y,const SkPaint & paint)59 void SkGLDevice_SWLayer::drawText(const SkDraw& draw, const void* text, size_t len,
60                         SkScalar x, SkScalar y, const SkPaint& paint) {
61     draw.drawText((const char*)text, len, x, y, paint);
62 }
63 
drawPosText(const SkDraw & draw,const void * text,size_t len,const SkScalar xpos[],SkScalar y,int scalarsPerPos,const SkPaint & paint)64 void SkGLDevice_SWLayer::drawPosText(const SkDraw& draw, const void* text, size_t len,
65                            const SkScalar xpos[], SkScalar y,
66                            int scalarsPerPos, const SkPaint& paint) {
67     draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint);
68 }
69 
drawTextOnPath(const SkDraw & draw,const void * text,size_t len,const SkPath & path,const SkMatrix * matrix,const SkPaint & paint)70 void SkGLDevice_SWLayer::drawTextOnPath(const SkDraw& draw, const void* text,
71                               size_t len, const SkPath& path,
72                               const SkMatrix* matrix,
73                               const SkPaint& paint) {
74     draw.drawTextOnPath((const char*)text, len, path, matrix, paint);
75 }
76 
drawVertices(const SkDraw & draw,SkCanvas::VertexMode vmode,int vertexCount,const SkPoint verts[],const SkPoint textures[],const SkColor colors[],SkXfermode * xmode,const uint16_t indices[],int indexCount,const SkPaint & paint)77 void SkGLDevice_SWLayer::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
78                             int vertexCount,
79                             const SkPoint verts[], const SkPoint textures[],
80                             const SkColor colors[], SkXfermode* xmode,
81                             const uint16_t indices[], int indexCount,
82                             const SkPaint& paint) {
83     draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode,
84                       indices, indexCount, paint);
85 }
86 
drawDevice(const SkDraw & draw,SkDevice * dev,int x,int y,const SkPaint & paint)87 void SkGLDevice_SWLayer::drawDevice(const SkDraw& draw, SkDevice* dev,
88                                     int x, int y, const SkPaint& paint) {
89     this->SkDevice::drawDevice(draw, dev, x, y, paint);
90 }
91 
92