diff options
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index eb9e8e870f..93414ed06b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -118,12 +118,11 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted, static SkImageInfo make_info(GrRenderTargetContext* context, int w, int h, bool opaque) { SkColorType colorType; - if (!GrPixelConfigToColorType(context->config(), &colorType)) { + if (!GrPixelConfigToColorType(context->colorSpaceInfo().config(), &colorType)) { colorType = kUnknown_SkColorType; } - return SkImageInfo::Make(w, h, colorType, - opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, - context->refColorSpace()); + return SkImageInfo::Make(w, h, colorType, opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, + context->colorSpaceInfo().refColorSpace()); } SkGpuDevice::SkGpuDevice(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext, @@ -179,7 +178,8 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg, matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top); sk_sp<SkImageFilterCache> cache(this->getImageFilterCache()); - SkImageFilter::OutputProperties outputProperties(fRenderTargetContext->getColorSpace()); + SkImageFilter::OutputProperties outputProperties( + fRenderTargetContext->colorSpaceInfo().colorSpace()); SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties); return filter->filterImage(srcImg, ctx, offset); @@ -272,8 +272,8 @@ void SkGpuDevice::drawPaint(const SkPaint& paint) { GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext.get()); GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -299,8 +299,8 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode, if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) { GrStyle style(paint, SkPaint::kStroke_Style); GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } SkPath path; @@ -344,8 +344,8 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode, #endif GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, *viewMatrix, - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + *viewMatrix, &grPaint)) { return; } @@ -374,8 +374,8 @@ void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) { } GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -390,8 +390,8 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) { ASSERT_SINGLE_OWNER GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext.get()); GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -455,8 +455,8 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer, if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) { GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -488,8 +488,8 @@ void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) { } GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -517,8 +517,8 @@ void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) { } GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -536,8 +536,8 @@ void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle, return; } GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), paint, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), &grPaint)) { return; } @@ -592,7 +592,8 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2], m.postConcat(this->ctm()); GrPaint grPaint; - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), newPaint, m, &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), newPaint, m, + &grPaint)) { return; } @@ -1022,11 +1023,11 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, } fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), - fRenderTargetContext->getColorSpace()); + fRenderTargetContext->colorSpaceInfo().colorSpace()); GrPaint grPaint; - if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint, viewMatrix, - std::move(fp), kAlpha_8_SkColorType == bitmap.colorType(), - &grPaint)) { + if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, + viewMatrix, std::move(fp), + kAlpha_8_SkColorType == bitmap.colorType(), &grPaint)) { return; } @@ -1088,7 +1089,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I()); fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), - fRenderTargetContext->getColorSpace()); + fRenderTargetContext->colorSpaceInfo().colorSpace()); if (GrPixelConfigIsAlphaOnly(config)) { fp = GrFragmentProcessor::MakeInputPremulAndMulByOutput(std::move(fp)); } else { @@ -1096,8 +1097,8 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const } GrPaint grPaint; - if (!SkPaintToGrPaintReplaceShader(this->context(), fRenderTargetContext.get(), tmpUnfiltered, - std::move(fp), &grPaint)) { + if (!SkPaintToGrPaintReplaceShader(this->context(), fRenderTargetContext->colorSpaceInfo(), + tmpUnfiltered, std::move(fp), &grPaint)) { return; } @@ -1287,7 +1288,7 @@ void SkGpuDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, const if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint, paint.getFilterQuality(), viewMatrix, SkMatrix::I())) { // only support tiling as bitmap at the moment, so force raster-version - if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorSpaceInfo().colorSpace())) { return; } this->drawBitmap(bm, x, y, paint); @@ -1299,7 +1300,7 @@ void SkGpuDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint); return; } - if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorSpaceInfo().colorSpace())) { GrBitmapTextureMaker maker(fContext.get(), bm); this->drawTextureMaker(&maker, image->width(), image->height(), nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint); @@ -1325,7 +1326,7 @@ void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const S if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), this->ctm(), srcToDstRect)) { // only support tiling as bitmap at the moment, so force raster-version - if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorSpaceInfo().colorSpace())) { return; } this->drawBitmapRect(bm, src, dst, paint, constraint); @@ -1337,7 +1338,7 @@ void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const S this->ctm(), paint); return; } - if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorSpaceInfo().colorSpace())) { GrBitmapTextureMaker maker(fContext.get(), bm); this->drawTextureMaker(&maker, image->width(), image->height(), src, &dst, constraint, this->ctm(), paint); @@ -1368,12 +1369,12 @@ void SkGpuDevice::drawProducerNine(GrTextureProducer* producer, auto fp = producer->createFragmentProcessor( SkMatrix::I(), SkRect::MakeIWH(producer->width(), producer->height()), GrTextureProducer::kNo_FilterConstraint, true, &kMode, - fRenderTargetContext->getColorSpace()); + fRenderTargetContext->colorSpaceInfo().colorSpace()); if (!fp) { return; } GrPaint grPaint; - if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint, + if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, this->ctm(), std::move(fp), producer->isAlphaOnly(), &grPaint)) { return; @@ -1400,7 +1401,8 @@ void SkGpuDevice::drawImageNine(const SkImage* image, if (image->isLazyGenerated()) { GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint); this->drawProducerNine(&maker, center, dst, paint); - } else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + } else if (as_IB(image)->getROPixels(&bm, + fRenderTargetContext->colorSpaceInfo().colorSpace())) { this->drawBitmapNine(bm, center, dst, paint); } } @@ -1422,12 +1424,12 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer, std::unique_ptr<GrFragmentProcessor> fp(producer->createFragmentProcessor( SkMatrix::I(), SkRect::MakeIWH(producer->width(), producer->height()), GrTextureProducer::kNo_FilterConstraint, true, &kMode, - fRenderTargetContext->getColorSpace())); + fRenderTargetContext->colorSpaceInfo().colorSpace())); if (!fp) { return; } GrPaint grPaint; - if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint, + if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, this->ctm(), std::move(fp), producer->isAlphaOnly(), &grPaint)) { return; @@ -1455,7 +1457,8 @@ void SkGpuDevice::drawImageLattice(const SkImage* image, if (image->isLazyGenerated()) { GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint); this->drawProducerLattice(&maker, lattice, dst, paint); - } else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + } else if (as_IB(image)->getROPixels(&bm, + fRenderTargetContext->colorSpaceInfo().colorSpace())) { this->drawBitmapLattice(bm, lattice, dst, paint); } } @@ -1469,26 +1472,26 @@ void SkGpuDevice::drawBitmapLattice(const SkBitmap& bitmap, this->drawProducerLattice(&maker, lattice, dst, paint); } -static bool init_vertices_paint(GrContext* context, GrRenderTargetContext* rtc, - const SkPaint& skPaint, - const SkMatrix& matrix, SkBlendMode bmode, +static bool init_vertices_paint(GrContext* context, const GrColorSpaceInfo& colorSpaceInfo, + const SkPaint& skPaint, const SkMatrix& matrix, SkBlendMode bmode, bool hasTexs, bool hasColors, GrPaint* grPaint) { if (hasTexs && skPaint.getShader()) { if (hasColors) { // When there are texs and colors the shader and colors are combined using bmode. - return SkPaintToGrPaintWithXfermode(context, rtc, skPaint, matrix, bmode, grPaint); + return SkPaintToGrPaintWithXfermode(context, colorSpaceInfo, skPaint, matrix, bmode, + grPaint); } else { // We have a shader, but no colors to blend it against. - return SkPaintToGrPaint(context, rtc, skPaint, matrix, grPaint); + return SkPaintToGrPaint(context, colorSpaceInfo, skPaint, matrix, grPaint); } } else { if (hasColors) { // We have colors, but either have no shader or no texture coords (which implies that // we should ignore the shader). - return SkPaintToGrPaintWithPrimitiveColor(context, rtc, skPaint, grPaint); + return SkPaintToGrPaintWithPrimitiveColor(context, colorSpaceInfo, skPaint, grPaint); } else { // No colors and no shaders. Just draw with the paint color. - return SkPaintToGrPaintNoShader(context, rtc, skPaint, grPaint); + return SkPaintToGrPaintNoShader(context, colorSpaceInfo, skPaint, grPaint); } } } @@ -1506,7 +1509,8 @@ void SkGpuDevice::wireframeVertices(SkVertices::VertexMode vmode, int vertexCoun GrPaint grPaint; // we ignore the shader since we have no texture coordinates. - if (!SkPaintToGrPaintNoShader(this->context(), fRenderTargetContext.get(), copy, &grPaint)) { + if (!SkPaintToGrPaintNoShader(this->context(), fRenderTargetContext->colorSpaceInfo(), copy, + &grPaint)) { return; } @@ -1566,8 +1570,8 @@ void SkGpuDevice::drawVertices(const SkVertices* vertices, SkBlendMode mode, con mode, vertices->indices(), vertices->indexCount(), paint); return; } - if (!init_vertices_paint(fContext.get(), fRenderTargetContext.get(), paint, this->ctm(), - mode, hasTexs, hasColors, &grPaint)) { + if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorSpaceInfo(), paint, + this->ctm(), mode, hasTexs, hasColors, &grPaint)) { return; } fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(), @@ -1606,13 +1610,13 @@ void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[], GrPaint grPaint; if (colors) { - if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext.get(), p, - this->ctm(), (SkBlendMode)mode, &grPaint)) { + if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext->colorSpaceInfo(), + p, this->ctm(), (SkBlendMode)mode, &grPaint)) { return; } } else { - if (!SkPaintToGrPaint(this->context(), fRenderTargetContext.get(), p, this->ctm(), - &grPaint)) { + if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), p, + this->ctm(), &grPaint)) { return; } } @@ -1695,14 +1699,10 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint : SkBackingFit::kExact; sk_sp<GrRenderTargetContext> rtc(fContext->makeDeferredRenderTargetContext( - fit, - cinfo.fInfo.width(), cinfo.fInfo.height(), - fRenderTargetContext->config(), - fRenderTargetContext->refColorSpace(), - fRenderTargetContext->numStencilSamples(), - false, - kBottomLeft_GrSurfaceOrigin, - &props)); + fit, cinfo.fInfo.width(), cinfo.fInfo.height(), + fRenderTargetContext->colorSpaceInfo().config(), + fRenderTargetContext->colorSpaceInfo().refColorSpace(), + fRenderTargetContext->numStencilSamples(), false, kBottomLeft_GrSurfaceOrigin, &props)); if (!rtc) { return nullptr; } |