| Index: src/gpu/SkGpuDevice.cpp
|
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
|
| index 4c9f0e2b7d5569c6915fddca610fa977f9113e46..040cea83561e3abb2c5f277c3f55b34aa4367e74 100644
|
| --- a/src/gpu/SkGpuDevice.cpp
|
| +++ b/src/gpu/SkGpuDevice.cpp
|
| @@ -52,13 +52,13 @@ enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 };
|
|
|
| #if 0
|
| extern bool (*gShouldDrawProc)();
|
| - #define CHECK_SHOULD_DRAW(draw, forceI) \
|
| + #define CHECK_SHOULD_DRAW(draw) \
|
| do { \
|
| if (gShouldDrawProc && !gShouldDrawProc()) return; \
|
| - this->prepareDraw(draw, forceI); \
|
| + this->prepareDraw(draw); \
|
| } while (0)
|
| #else
|
| - #define CHECK_SHOULD_DRAW(draw, forceI) this->prepareDraw(draw, forceI)
|
| + #define CHECK_SHOULD_DRAW(draw) this->prepareDraw(draw)
|
| #endif
|
|
|
| // This constant represents the screen alignment criterion in texels for
|
| @@ -271,18 +271,13 @@ void SkGpuDevice::onDetachFromCanvas() {
|
|
|
| // call this every draw call, to ensure that the context reflects our state,
|
| // and not the state from some other canvas/device
|
| -void SkGpuDevice::prepareDraw(const SkDraw& draw, bool forceIdentity) {
|
| +void SkGpuDevice::prepareDraw(const SkDraw& draw) {
|
| SkASSERT(fClipData.fClipStack);
|
|
|
| fContext->setRenderTarget(fRenderTarget);
|
|
|
| SkASSERT(draw.fClipStack && draw.fClipStack == fClipData.fClipStack);
|
|
|
| - if (forceIdentity) {
|
| - fContext->setIdentityMatrix();
|
| - } else {
|
| - fContext->setMatrix(*draw.fMatrix);
|
| - }
|
| fClipData.fOrigin = this->getOrigin();
|
|
|
| fContext->setClip(&fClipData);
|
| @@ -319,13 +314,13 @@ SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch);
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| - fContext->drawPaint(grPaint);
|
| + fContext->drawPaint(grPaint, *draw.fMatrix);
|
| }
|
|
|
| // must be in SkCanvas::PointMode order
|
| @@ -338,7 +333,7 @@ static const GrPrimitiveType gPointMode2PrimtiveType[] = {
|
| void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
| size_t count, const SkPoint pts[], const SkPaint& paint) {
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| SkScalar width = paint.getStrokeWidth();
|
| if (width < 0) {
|
| @@ -348,12 +343,12 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
| if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) {
|
| GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
| SkPath path;
|
| path.setIsVolatile(true);
|
| path.moveTo(pts[0]);
|
| path.lineTo(pts[1]);
|
| - fContext->drawPath(grPaint, path, strokeInfo);
|
| + fContext->drawPath(grPaint, *draw.fMatrix, path, strokeInfo);
|
| return;
|
| }
|
|
|
| @@ -365,9 +360,10 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
| }
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| fContext->drawVertices(grPaint,
|
| + *draw.fMatrix,
|
| gPointMode2PrimtiveType[mode],
|
| SkToS32(count),
|
| (SkPoint*)pts,
|
| @@ -384,7 +380,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext);
|
|
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| bool doStroke = paint.getStyle() != SkPaint::kFill_Style;
|
| SkScalar width = paint.getStrokeWidth();
|
| @@ -402,14 +398,14 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
|
| usePath = true;
|
| }
|
|
|
| - if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect()) {
|
| + if (!usePath && paint.isAntiAlias() && !draw.fMatrix->rectStaysRect()) {
|
| #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
|
| if (doStroke) {
|
| #endif
|
| usePath = true;
|
| #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
|
| } else {
|
| - usePath = !fContext->getMatrix().preservesRightAngles();
|
| + usePath = !draw.fMatrix->preservesRightAngles();
|
| }
|
| #endif
|
| }
|
| @@ -434,34 +430,34 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
|
| }
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| - fContext->drawRect(grPaint, rect, &strokeInfo);
|
| + fContext->drawRect(grPaint, *draw.fMatrix, rect, &strokeInfo);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
|
| - const SkPaint& paint) {
|
| + const SkPaint& paint) {
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext);
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| GrStrokeInfo strokeInfo(paint);
|
| if (paint.getMaskFilter()) {
|
| // try to hit the fast path for drawing filtered round rects
|
|
|
| SkRRect devRRect;
|
| - if (rect.transform(fContext->getMatrix(), &devRRect)) {
|
| + if (rect.transform(*draw.fMatrix, &devRRect)) {
|
| if (devRRect.allCornersCircular()) {
|
| SkRect maskRect;
|
| if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(),
|
| - draw.fClip->getBounds(),
|
| - fContext->getMatrix(),
|
| - &maskRect)) {
|
| + draw.fClip->getBounds(),
|
| + *draw.fMatrix,
|
| + &maskRect)) {
|
| SkIRect finalIRect;
|
| maskRect.roundOut(&finalIRect);
|
| if (draw.fClip->quickReject(finalIRect)) {
|
| @@ -469,6 +465,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
|
| return;
|
| }
|
| if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint,
|
| + *draw.fMatrix,
|
| strokeInfo.getStrokeRec(),
|
| devRRect)) {
|
| return;
|
| @@ -500,22 +497,22 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
|
| return;
|
| }
|
|
|
| - fContext->drawRRect(grPaint, rect, strokeInfo);
|
| + fContext->drawRRect(grPaint, *draw.fMatrix, rect, strokeInfo);
|
| }
|
|
|
| void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
|
| - const SkRRect& inner, const SkPaint& paint) {
|
| + const SkRRect& inner, const SkPaint& paint) {
|
| SkStrokeRec stroke(paint);
|
| if (stroke.isFillStyle()) {
|
|
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) {
|
| - fContext->drawDRRect(grPaint, outer, inner);
|
| + fContext->drawDRRect(grPaint, *draw.fMatrix, outer, inner);
|
| return;
|
| }
|
| }
|
| @@ -536,7 +533,7 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
|
| const SkPaint& paint) {
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext);
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| GrStrokeInfo strokeInfo(paint);
|
|
|
| @@ -560,9 +557,9 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
|
| }
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| - fContext->drawOval(grPaint, oval, strokeInfo);
|
| + fContext->drawOval(grPaint, *draw.fMatrix, oval, strokeInfo);
|
| }
|
|
|
| #include "SkMaskFilter.h"
|
| @@ -575,10 +572,9 @@ namespace {
|
| // Draw a mask using the supplied paint. Since the coverage/geometry
|
| // is already burnt into the mask this boils down to a rect draw.
|
| // Return true if the mask was successfully drawn.
|
| -bool draw_mask(GrContext* context, const SkRect& maskRect,
|
| +bool draw_mask(GrContext* context, const SkMatrix& viewMatrix, const SkRect& maskRect,
|
| GrPaint* grp, GrTexture* mask) {
|
| - GrContext::AutoMatrix am;
|
| - if (!am.setIdentity(context, grp)) {
|
| + if (!grp->localCoordChangeInverse(viewMatrix)) {
|
| return false;
|
| }
|
|
|
| @@ -587,22 +583,22 @@ bool draw_mask(GrContext* context, const SkRect& maskRect,
|
| matrix.postIDiv(mask->width(), mask->height());
|
|
|
| grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix))->unref();
|
| - context->drawRect(*grp, maskRect);
|
| + context->drawRect(*grp, SkMatrix::I(), maskRect);
|
| return true;
|
| }
|
|
|
| -bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
|
| +bool draw_with_mask_filter(GrContext* context, const SkMatrix& viewMatrix, const SkPath& devPath,
|
| SkMaskFilter* filter, const SkRegion& clip,
|
| GrPaint* grp, SkPaint::Style style) {
|
| SkMask srcM, dstM;
|
|
|
| - if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &context->getMatrix(), &srcM,
|
| + if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &viewMatrix, &srcM,
|
| SkMask::kComputeBoundsAndRenderImage_CreateMode, style)) {
|
| return false;
|
| }
|
| SkAutoMaskFreeImage autoSrc(srcM.fImage);
|
|
|
| - if (!filter->filterMask(&dstM, srcM, context->getMatrix(), NULL)) {
|
| + if (!filter->filterMask(&dstM, srcM, viewMatrix, NULL)) {
|
| return false;
|
| }
|
| // this will free-up dstM when we're done (allocated in filterMask())
|
| @@ -629,7 +625,7 @@ bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
|
|
|
| SkRect maskRect = SkRect::Make(dstM.fBounds);
|
|
|
| - return draw_mask(context, maskRect, grp, texture);
|
| + return draw_mask(context, viewMatrix, maskRect, grp, texture);
|
| }
|
|
|
| // Create a mask of 'devPath' and place the result in 'mask'.
|
| @@ -677,13 +673,10 @@ GrTexture* create_mask_GPU(GrContext* context,
|
| tempPaint.setPorterDuffXPFactory(kOne_GrBlendCoeff, kISC_GrBlendCoeff);
|
| }
|
|
|
| - GrContext::AutoMatrix am;
|
| -
|
| // Draw the mask into maskTexture with the path's top-left at the origin using tempPaint.
|
| SkMatrix translate;
|
| translate.setTranslate(-maskRect.fLeft, -maskRect.fTop);
|
| - am.set(context, translate);
|
| - context->drawPath(tempPaint, devPath, strokeInfo);
|
| + context->drawPath(tempPaint, translate, devPath, strokeInfo);
|
| return mask;
|
| }
|
|
|
| @@ -700,13 +693,13 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
| const SkPaint& paint, const SkMatrix* prePathMatrix,
|
| bool pathIsMutable) {
|
| CHECK_FOR_ANNOTATION(paint);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext);
|
|
|
| SkASSERT(!pathIsMutable || origSrcPath.isVolatile());
|
| -
|
| +
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| // If we have a prematrix, apply it to the path, optimizing for the case
|
| // where the original path can in fact be modified in place (even though
|
| @@ -760,16 +753,16 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
| }
|
|
|
| // transform the path into device space
|
| - pathPtr->transform(fContext->getMatrix(), devPathPtr);
|
| + pathPtr->transform(*draw.fMatrix, devPathPtr);
|
|
|
| SkRect maskRect;
|
| if (paint.getMaskFilter()->canFilterMaskGPU(devPathPtr->getBounds(),
|
| draw.fClip->getBounds(),
|
| - fContext->getMatrix(),
|
| + *draw.fMatrix,
|
| &maskRect)) {
|
| // The context's matrix may change while creating the mask, so save the CTM here to
|
| // pass to filterMaskGPU.
|
| - const SkMatrix ctm = fContext->getMatrix();
|
| + const SkMatrix ctm = *draw.fMatrix;
|
|
|
| SkIRect finalIRect;
|
| maskRect.roundOut(&finalIRect);
|
| @@ -778,7 +771,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
| return;
|
| }
|
|
|
| - if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
|
| + if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, *draw.fMatrix,
|
| stroke, *devPathPtr)) {
|
| // the mask filter was able to draw itself directly, so there's nothing
|
| // left to do.
|
| @@ -795,7 +788,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
| if (paint.getMaskFilter()->filterMaskGPU(mask, ctm, maskRect, &filtered, true)) {
|
| // filterMaskGPU gives us ownership of a ref to the result
|
| SkAutoTUnref<GrTexture> atu(filtered);
|
| - if (draw_mask(fContext, maskRect, &grPaint, filtered)) {
|
| + if (draw_mask(fContext, *draw.fMatrix, maskRect, &grPaint, filtered)) {
|
| // This path is completely drawn
|
| return;
|
| }
|
| @@ -807,12 +800,12 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
| // GPU path fails
|
| SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style :
|
| SkPaint::kFill_Style;
|
| - draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(),
|
| + draw_with_mask_filter(fContext, *draw.fMatrix, *devPathPtr, paint.getMaskFilter(),
|
| *draw.fClip, &grPaint, style);
|
| return;
|
| }
|
|
|
| - fContext->drawPath(grPaint, *pathPtr, strokeInfo);
|
| + fContext->drawPath(grPaint, *draw.fMatrix, *pathPtr, strokeInfo);
|
| }
|
|
|
| static const int kBmpSmallTileSize = 1 << 10;
|
| @@ -844,13 +837,14 @@ static int determine_tile_size(const SkBitmap& bitmap, const SkIRect& src, int m
|
| // Given a bitmap, an optional src rect, and a context with a clip and matrix determine what
|
| // pixels from the bitmap are necessary.
|
| static void determine_clipped_src_rect(const GrContext* context,
|
| + const SkMatrix& viewMatrix,
|
| const SkBitmap& bitmap,
|
| const SkRect* srcRectPtr,
|
| SkIRect* clippedSrcIRect) {
|
| const GrClipData* clip = context->getClip();
|
| clip->getConservativeBounds(context->getRenderTarget(), clippedSrcIRect, NULL);
|
| SkMatrix inv;
|
| - if (!context->getMatrix().invert(&inv)) {
|
| + if (!viewMatrix.invert(&inv)) {
|
| clippedSrcIRect->setEmpty();
|
| return;
|
| }
|
| @@ -872,6 +866,7 @@ static void determine_clipped_src_rect(const GrContext* context,
|
| }
|
|
|
| bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
|
| + const SkMatrix& viewMatrix,
|
| const GrTextureParams& params,
|
| const SkRect* srcRectPtr,
|
| int maxTileSize,
|
| @@ -884,7 +879,7 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
|
|
|
| // if it's larger than the max tile size, then we have no choice but tiling.
|
| if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) {
|
| - determine_clipped_src_rect(fContext, bitmap, srcRectPtr, clippedSrcRect);
|
| + determine_clipped_src_rect(fContext, viewMatrix, bitmap, srcRectPtr, clippedSrcRect);
|
| *tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize);
|
| return true;
|
| }
|
| @@ -913,7 +908,7 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
|
| }
|
|
|
| // Figure out how much of the src we will need based on the src rect and clipping.
|
| - determine_clipped_src_rect(fContext, bitmap, srcRectPtr, clippedSrcRect);
|
| + determine_clipped_src_rect(fContext, viewMatrix, bitmap, srcRectPtr, clippedSrcRect);
|
| *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile.
|
| size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) *
|
| kBmpSmallTileSize * kBmpSmallTileSize;
|
| @@ -1041,7 +1036,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| const SkSize* dstSizePtr,
|
| const SkPaint& paint,
|
| SkCanvas::DrawBitmapRectFlags flags) {
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| SkRect srcRect;
|
| SkSize dstSize;
|
| @@ -1077,12 +1072,12 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
|
|
| // we check whether dst rect are pixel aligned
|
| if (!directDraw) {
|
| - bool staysRect = fContext->getMatrix().rectStaysRect();
|
| + bool staysRect = draw.fMatrix->rectStaysRect();
|
|
|
| if (staysRect) {
|
| SkRect rect;
|
| SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHeight);
|
| - fContext->getMatrix().mapRect(&rect, dstRect);
|
| + draw.fMatrix->mapRect(&rect, dstRect);
|
| const SkScalar *scalars = rect.asScalars();
|
| bool isDstPixelAligned = true;
|
| for (int i = 0; i < 4; i++) {
|
| @@ -1145,7 +1140,8 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| SkMatrix m;
|
| m.setScale(dstSize.fWidth / srcRect.width(),
|
| dstSize.fHeight / srcRect.height());
|
| - fContext->concatMatrix(m);
|
| + SkMatrix viewM = *draw.fMatrix;
|
| + viewM.preConcat(m);
|
|
|
| GrTextureParams params;
|
| SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
|
| @@ -1161,7 +1157,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| textureFilterMode = GrTextureParams::kBilerp_FilterMode;
|
| break;
|
| case SkPaint::kMedium_FilterLevel:
|
| - if (fContext->getMatrix().getMinScale() < SK_Scalar1) {
|
| + if (viewM.getMinScale() < SK_Scalar1) {
|
| textureFilterMode = GrTextureParams::kMipMap_FilterMode;
|
| } else {
|
| // Don't trigger MIP level generation unnecessarily.
|
| @@ -1171,7 +1167,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| case SkPaint::kHigh_FilterLevel:
|
| // Minification can look bad with the bicubic effect.
|
| doBicubic =
|
| - GrBicubicEffect::ShouldUseBicubic(fContext->getMatrix(), &textureFilterMode);
|
| + GrBicubicEffect::ShouldUseBicubic(viewM, &textureFilterMode);
|
| break;
|
| default:
|
| SkErrorInternals::SetError( kInvalidPaint_SkError,
|
| @@ -1196,18 +1192,19 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| int tileSize;
|
|
|
| SkIRect clippedSrcRect;
|
| - if (this->shouldTileBitmap(bitmap, params, srcRectPtr, maxTileSize, &tileSize,
|
| + if (this->shouldTileBitmap(bitmap, viewM, params, srcRectPtr, maxTileSize, &tileSize,
|
| &clippedSrcRect)) {
|
| - this->drawTiledBitmap(bitmap, srcRect, clippedSrcRect, params, paint, flags, tileSize,
|
| - doBicubic);
|
| + this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, paint, flags,
|
| + tileSize, doBicubic);
|
| } else {
|
| // take the simple case
|
| bool needsTextureDomain = needs_texture_domain(bitmap,
|
| srcRect,
|
| params,
|
| - fContext->getMatrix(),
|
| + viewM,
|
| doBicubic);
|
| this->internalDrawBitmap(bitmap,
|
| + viewM,
|
| srcRect,
|
| params,
|
| paint,
|
| @@ -1220,6 +1217,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| // Break 'bitmap' into several tiles to draw it since it has already
|
| // been determined to be too large to fit in VRAM
|
| void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
|
| + const SkMatrix& viewMatrix,
|
| const SkRect& srcRect,
|
| const SkIRect& clippedSrcIRect,
|
| const GrTextureParams& params,
|
| @@ -1259,10 +1257,10 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
|
| SkIntToScalar(iTileR.fTop));
|
|
|
| // Adjust the context matrix to draw at the right x,y in device space
|
| + SkMatrix viewM = viewMatrix;
|
| SkMatrix tmpM;
|
| - GrContext::AutoMatrix am;
|
| tmpM.setTranslate(offset.fX - srcRect.fLeft, offset.fY - srcRect.fTop);
|
| - am.setPreConcat(fContext, tmpM);
|
| + viewM.preConcat(tmpM);
|
|
|
| if (GrTextureParams::kNone_FilterMode != params.filterMode() || bicubic) {
|
| SkIRect iClampRect;
|
| @@ -1288,9 +1286,10 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
|
| bool needsTextureDomain = needs_texture_domain(bitmap,
|
| srcRect,
|
| paramsTemp,
|
| - fContext->getMatrix(),
|
| + viewM,
|
| bicubic);
|
| this->internalDrawBitmap(tmpB,
|
| + viewM,
|
| tileR,
|
| paramsTemp,
|
| paint,
|
| @@ -1311,6 +1310,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
|
| * and that non-texture portion of the GrPaint has already been setup.
|
| */
|
| void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
| + const SkMatrix& viewMatrix,
|
| const SkRect& srcRect,
|
| const GrTextureParams& params,
|
| const SkPaint& paint,
|
| @@ -1359,10 +1359,10 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
| fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDomain));
|
| } else {
|
| fp.reset(GrTextureDomainEffect::Create(texture,
|
| - SkMatrix::I(),
|
| - textureDomain,
|
| - GrTextureDomain::kClamp_Mode,
|
| - params.filterMode()));
|
| + SkMatrix::I(),
|
| + textureDomain,
|
| + GrTextureDomain::kClamp_Mode,
|
| + params.filterMode()));
|
| }
|
| } else if (bicubic) {
|
| SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
|
| @@ -1381,7 +1381,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
| SkColor2GrColor(paint.getColor());
|
| SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint);
|
|
|
| - fContext->drawRectToRect(grPaint, dstRect, paintRect);
|
| + fContext->drawRectToRect(grPaint, viewMatrix, dstRect, paintRect);
|
| }
|
|
|
| bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
|
| @@ -1407,7 +1407,7 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
|
| void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
| int left, int top, const SkPaint& paint) {
|
| // drawSprite is defined to be in device coords.
|
| - CHECK_SHOULD_DRAW(draw, true);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| SkAutoLockPixels alp(bitmap, !bitmap.getTexture());
|
| if (!bitmap.getTexture() && !bitmap.readyToDraw()) {
|
| @@ -1453,6 +1453,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
| false, &grPaint);
|
|
|
| fContext->drawRectToRect(grPaint,
|
| + SkMatrix::I(),
|
| SkRect::MakeXYWH(SkIntToScalar(left),
|
| SkIntToScalar(top),
|
| SkIntToScalar(w),
|
| @@ -1520,7 +1521,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
| }
|
|
|
| // drawDevice is defined to be in device coords.
|
| - CHECK_SHOULD_DRAW(draw, true);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| GrRenderTarget* devRT = dev->accessRenderTarget();
|
| GrTexture* devTex;
|
| @@ -1573,7 +1574,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
| SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
|
| SK_Scalar1 * h / devTex->height());
|
|
|
| - fContext->drawRectToRect(grPaint, dstRect, srcRect);
|
| + fContext->drawRectToRect(grPaint, SkMatrix::I(), dstRect, srcRect);
|
| }
|
|
|
| bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
|
| @@ -1616,8 +1617,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
| SkXfermode* xmode,
|
| const uint16_t indices[], int indexCount,
|
| const SkPaint& paint) {
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| -
|
| + CHECK_SHOULD_DRAW(draw);
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawVertices", fContext);
|
|
|
| const uint16_t* outIndices;
|
| @@ -1678,7 +1678,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
| SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.getColor()),
|
| NULL == colors, &grPaint);
|
| } else {
|
| - SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, NULL == colors, &grPaint);
|
| }
|
| }
|
|
|
| @@ -1706,6 +1706,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
| colors = convertedColors.get();
|
| }
|
| fContext->drawVertices(grPaint,
|
| + *draw.fMatrix,
|
| primType,
|
| vertexCount,
|
| vertices,
|
| @@ -1718,17 +1719,18 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
|
| - size_t byteLength, SkScalar x, SkScalar y,
|
| - const SkPaint& paint) {
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + size_t byteLength, SkScalar x, SkScalar y,
|
| + const SkPaint& paint) {
|
| + CHECK_SHOULD_DRAW(draw);
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - if (!fTextContext->drawText(grPaint, paint, (const char *)text, byteLength, x, y)) {
|
| + if (!fTextContext->drawText(grPaint, paint, *draw.fMatrix, (const char *)text, byteLength, x,
|
| + y)) {
|
| // this will just call our drawPath()
|
| draw.drawText_asPaths((const char*)text, byteLength, x, y, paint);
|
| }
|
| @@ -1738,24 +1740,24 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
|
| const SkScalar pos[], int scalarsPerPos,
|
| const SkPoint& offset, const SkPaint& paint) {
|
| GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| GrPaint grPaint;
|
| - SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
|
| + SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
|
|
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - if (!fTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
|
| - scalarsPerPos, offset)) {
|
| + if (!fTextContext->drawPosText(grPaint, paint, *draw.fMatrix, (const char *)text, byteLength,
|
| + pos, scalarsPerPos, offset)) {
|
| // this will just call our drawPath()
|
| draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
|
| }
|
| }
|
|
|
| void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text,
|
| - size_t len, const SkPath& path,
|
| - const SkMatrix* m, const SkPaint& paint) {
|
| - CHECK_SHOULD_DRAW(draw, false);
|
| + size_t len, const SkPath& path,
|
| + const SkMatrix* m, const SkPaint& paint) {
|
| + CHECK_SHOULD_DRAW(draw);
|
|
|
| SkASSERT(draw.fDevice == this);
|
| draw.drawTextOnPath((const char*)text, len, path, m, paint);
|
|
|