/** * Sets up a scratch GC for fbFill, and saves other parameters for the * ephyrSolid implementation. */ static Bool ephyrPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) { ScreenPtr pScreen = pPix->drawable.pScreen; KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = screen->driver; EphyrFakexaPriv *fakexa = scrpriv->fakexa; CARD32 tmpval[3]; ephyrPreparePipelinedAccess(pPix, EXA_PREPARE_DEST); fakexa->pDst = pPix; fakexa->pGC = GetScratchGC(pPix->drawable.depth, pScreen); tmpval[0] = alu; tmpval[1] = pm; tmpval[2] = fg; ChangeGC(fakexa->pGC, GCFunction | GCPlaneMask | GCForeground, tmpval); ValidateGC(&pPix->drawable, fakexa->pGC); TRACE_DRAW(); return TRUE; }
/** * Sets up a scratch GC for fbCopyArea, and saves other parameters for the * ephyrCopy implementation. */ static Bool ephyrPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm) { ScreenPtr pScreen = pDst->drawable.pScreen; KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = screen->driver; EphyrFakexaPriv *fakexa = scrpriv->fakexa; CARD32 tmpval[2]; ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST); ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC); fakexa->pSrc = pSrc; fakexa->pDst = pDst; fakexa->pGC = GetScratchGC(pDst->drawable.depth, pScreen); tmpval[0] = alu; tmpval[1] = pm; ChangeGC (fakexa->pGC, GCFunction | GCPlaneMask, tmpval); ValidateGC(&pDst->drawable, fakexa->pGC); TRACE_DRAW(); return TRUE; }
/** * Saves off the parameters for ephyrComposite. */ static Bool ephyrPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) { KdScreenPriv(pDst->drawable.pScreen); KdScreenInfo *screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = screen->driver; EphyrFakexaPriv *fakexa = scrpriv->fakexa; ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST); ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC); if (pMask != NULL) ephyrPreparePipelinedAccess(pMask, EXA_PREPARE_MASK); fakexa->op = op; fakexa->pSrcPicture = pSrcPicture; fakexa->pMaskPicture = pMaskPicture; fakexa->pDstPicture = pDstPicture; fakexa->pSrc = pSrc; fakexa->pMask = pMask; fakexa->pDst = pDst; TRACE_DRAW(); return TRUE; }
void SkGLDevice::drawPath(const SkDraw& draw, const SkPath& path, const SkPaint& paint) { TRACE_DRAW("coreDrawPath", this, draw); if (paint.getStyle() == SkPaint::kStroke_Style) { return; } AutoPaintShader shader(this, paint); SkGL::FillPath(path, paint, shader.useTex(), this->updateMatrixClip()); }
void SkGLDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, int left, int top, const SkPaint& paint) { TRACE_DRAW("coreDrawSprite", this, draw); SkAutoLockPixels alp(bitmap); if (!bitmap.readyToDraw()) { return; } SkGLClipIter* iter = this->updateMatrixClip(); SkPoint max; GLuint name; SkAutoLockTexCache(bitmap, &name, &max); gl_drawSprite(left, top, bitmap.width(), bitmap.height(), max, paint, iter); }
void SkGLDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { TRACE_DRAW("coreDrawPoints", this, draw); SkScalar width = paint.getStrokeWidth(); if (width < 0) { return; } /* We should really only use drawverts for hairlines, since gl and skia treat the thickness differently... */ AutoPaintShader shader(this, paint); if (width <= 0) { width = SK_Scalar1; } if (SkCanvas::kPoints_PointMode == mode) { glPointSize(SkScalarToFloat(width)); } else { glLineWidth(SkScalarToFloat(width)); } const SkGLVertex* verts; #if GLSCALAR_IS_SCALAR verts = (const SkGLVertex*)pts; #else SkAutoSTMalloc<32, SkGLVertex> storage(count); SkGLVertex* v = storage.get(); v->setPoints(pts, count); verts = v; #endif const SkGLVertex* texs = shader.useTex() ? verts : NULL; SkGL::DrawVertices(count, gPointMode2GL[mode], verts, texs, NULL, NULL, this->updateMatrixClip()); }
void SkGLDevice::drawDevice(const SkDraw& draw, SkDevice* dev, int x, int y, const SkPaint& paint) { TRACE_DRAW("coreDrawDevice", this, draw); SkGLDevice::TexOrientation to = ((SkGLDevice*)dev)->bindDeviceAsTexture(); if (SkGLDevice::kNo_TexOrientation != to) { SkGLClipIter* iter = this->updateMatrixClip(); const SkBitmap& bm = dev->accessBitmap(false); int w = bm.width(); int h = bm.height(); SkPoint max; max.set(SkFixedToScalar(w << (16 - SkNextLog2(bm.rowBytesAsPixels()))), SkFixedToScalar(h << (16 - SkNextLog2(h)))); if (SkGLDevice::kBottomToTop_TexOrientation == to) { h = -h; } gl_drawSprite(x, y, w, h, max, paint, iter); } }
void SkGLDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { TRACE_DRAW("coreDrawPaint", this, draw); AutoPaintShader shader(this, paint); SkGLVertex vertex[4]; const SkGLVertex* texs = shader.useTex() ? vertex : NULL; // set vert to be big enough to fill the space, but not super-huge, to we // don't overflow fixed-point implementations { SkRect r; r.set(this->clip().getBounds()); SkMatrix inverse; if (draw.fMatrix->invert(&inverse)) { inverse.mapRect(&r); } vertex->setRectFan(r); } SkGL::DrawVertices(4, GL_TRIANGLE_FAN, vertex, texs, NULL, NULL, this->updateMatrixClip()); }
void SkGLDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, const SkMatrix& m, const SkPaint& paint) { TRACE_DRAW("coreDrawBitmap", this, draw); SkAutoLockPixels alp(bitmap); if (!bitmap.readyToDraw()) { return; } SkGLClipIter* iter = this->updateMatrixClip(); SkPoint max; GLenum name; SkAutoLockTexCache(bitmap, &name, &max); // the lock has already called glBindTexture for us SkGL::SetTexParamsClamp(paint.isFilterBitmap()); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); SkGL::MultMatrix(m); SkGLVertex pts[4], tex[4]; pts->setIRectFan(0, 0, bitmap.width(), bitmap.height()); tex->setRectFan(0, 0, max.fX, max.fY); // now draw the mesh SkGL::SetPaintAlpha(paint); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); SkGL::DrawVertices(4, GL_TRIANGLE_FAN, pts, tex, NULL, NULL, iter); glPopMatrix(); }
void SkGLDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint& paint) { TRACE_DRAW("coreDrawRect", this, draw); if (paint.getStyle() == SkPaint::kStroke_Style) { return; } if (paint.getStrokeJoin() != SkPaint::kMiter_Join) { SkPath path; path.addRect(rect); this->drawPath(draw, path, paint); return; } AutoPaintShader shader(this, paint); SkGLVertex vertex[4]; vertex->setRectFan(rect); const SkGLVertex* texs = shader.useTex() ? vertex : NULL; SkGL::DrawVertices(4, GL_TRIANGLE_FAN, vertex, texs, NULL, NULL, this->updateMatrixClip()); }