Lines Matching +full:set +full:- +full:image
4 * Use of this source code is governed by a BSD-style license that can be
30 #include "src/image/SkImage_Base.h"
31 #include "src/image/SkImage_Gpu.h"
46 …if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - transformedRect.left()) < kColorBl… in has_aligned_samples()
47 …SkScalarAbs(SkScalarRoundToScalar(transformedRect.top()) - transformedRect.top()) < kColorBleedT… in has_aligned_samples()
48 SkScalarAbs(transformedRect.width() - srcRect.width()) < kColorBleedTolerance && in has_aligned_samples()
49 SkScalarAbs(transformedRect.height() - srcRect.height()) < kColorBleedTolerance) { in has_aligned_samples()
88 // sampling is axis-aligned in can_ignore_linear_filtering_subset()
106 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; in get_tile_count()
107 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; in get_tile_count()
137 SkIRect clippedSrcIRect = clip ? clip->getConservativeBounds() in determine_clipped_src_rect()
179 // If the image would only produce 4 tiles of the smaller size, don't bother tiling it. in should_tile_image_id()
191 // Instead, we will just upload the entire image to be on the safe side and not tile. in should_tile_image_id()
192 auto direct = context->asDirectContext(); in should_tile_image_id()
200 size_t cacheSize = direct->getResourceCacheLimit(); in should_tile_image_id()
218 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner
222 iRect->outset(outset, outset); in clamped_outset_with_offset()
224 int leftClampDelta = clamp.fLeft - iRect->fLeft; in clamped_outset_with_offset()
226 offset->fX -= outset - leftClampDelta; in clamped_outset_with_offset()
227 iRect->fLeft = clamp.fLeft; in clamped_outset_with_offset()
229 offset->fX -= outset; in clamped_outset_with_offset()
232 int topClampDelta = clamp.fTop - iRect->fTop; in clamped_outset_with_offset()
234 offset->fY -= outset - topClampDelta; in clamped_outset_with_offset()
235 iRect->fTop = clamp.fTop; in clamped_outset_with_offset()
237 offset->fY -= outset; in clamped_outset_with_offset()
240 if (iRect->fRight > clamp.fRight) { in clamped_outset_with_offset()
241 iRect->fRight = clamp.fRight; in clamped_outset_with_offset()
243 if (iRect->fBottom > clamp.fBottom) { in clamped_outset_with_offset()
244 iRect->fBottom = clamp.fBottom; in clamped_outset_with_offset()
249 // Helper functions for drawing an image with v1::SurfaceDrawContext
252 // Src and dst have been restricted to the image content. May need to clamp, no need to decal.
257 // Src or dst are empty, or do not intersect the image content so don't draw anything.
262 * Optimize the src rect sampling area within an image (sized 'width' x 'height') such that
263 * 'outSrcRect' will be completely contained in the image's bounds. The corresponding rect
267 * If 'origSrcRect' is null, implicitly use the image bounds. If 'origDstRect' is null, use the
270 ImageDrawMode optimize_sample_area(const SkISize& image, const SkRect* origSrcRect, in optimize_sample_area() argument
274 SkRect srcBounds = SkRect::MakeIWH(image.fWidth, image.fHeight); in optimize_sample_area()
286 srcToDst->setIdentity(); in optimize_sample_area()
293 srcToDst->mapRect(&dst, src); in optimize_sample_area()
311 // The original src and dst were fully contained in the image, or there was no dst clip to in optimize_sample_area()
361 const GrColorInfo& dstInfo = sdc->colorInfo(); in draw_texture()
362 auto textureXform = GrColorSpaceXform::Make(srcColorInfo, sdc->colorInfo()); in draw_texture()
366 if (constraint != SkCanvas::kStrict_SrcRectConstraint && !proxy->isFunctionallyExact()) { in draw_texture()
371 SkRect safeBounds = proxy->getBoundsRect(); in draw_texture()
384 sdc->drawTextureQuad(clip, in draw_texture()
405 sdc->drawTexture(clip, in draw_texture()
433 const SkImage_Base& image, in draw_texture() argument
445 !image.isYUVA() && in draw_texture()
449 auto [view, ct] = image.asView(rContext, GrMipmapped::kNo); in draw_texture()
453 GrColorInfo info(image.imageInfo().colorInfo()); in draw_texture()
469 image.getSupportOpaqueOpt()); in draw_texture()
481 bool canUseTextureCoordsAsLocalCoords = !use_shader(image.isAlphaOnly(), paint) && !mf; in draw_texture()
487 if (mf && as_MFB(mf)->hasFragmentProcessor()) { in draw_texture()
499 // TODO: Just rely on image to handle this. in draw_texture()
505 !image.isYUVA()) { in draw_texture()
508 if (can_ignore_linear_filtering_subset(src, combinedMatrix, sdc->numSamples())) { in draw_texture()
524 std::unique_ptr<GrFragmentProcessor> fp = image.asFragmentProcessor(rContext, in draw_texture()
531 image.imageInfo().colorInfo(), in draw_texture()
532 sdc->colorInfo()); in draw_texture()
533 if (image.isAlphaOnly()) { in draw_texture()
535 auto shaderFP = shader->asFragmentProcessor( in draw_texture()
536 GrFPArgs(rContext, matrixProvider, &sdc->colorInfo())); in draw_texture()
550 rContext, sdc->colorInfo(), paint, matrixProvider, std::move(fp), &grPaint)) { in draw_texture()
555 // Can draw the image directly (any mask filter on the paint was converted to an FP already) in draw_texture()
564 sdc->fillQuadWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dstClip, srcClip); in draw_texture()
567 sdc->fillRectWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dst, in draw_texture()
571 // Must draw the mask filter as a GrStyledShape. For now, this loses the per-edge AA in draw_texture()
636 // In texture-domain/clamp mode we only want to expand the in draw_texture()
646 // Image subsets always make a copy of the pixels and lose the association with the in draw_texture()
649 auto image = SkMakeImageFromRasterBitmap(subsetBmp, kNever_SkCopyPixelsMode); in draw_texture() local
651 SkASSERT(image->width() <= rContext->priv().caps()->maxTextureSize() && in draw_texture()
652 image->height() <= rContext->priv().caps()->maxTextureSize()); in draw_texture()
656 // If the entire bitmap was anti-aliased, turn on AA for the outside tile edges. in draw_texture()
672 tileR.offset(-offset.fX, -offset.fY); in draw_texture()
680 *as_IB(image.get()), in draw_texture()
709 // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until in draw_texture()
713 // Want: 0 = log2(1/s) - 0.5 in draw_texture()
733 SkASSERT(special->isTextureBacked()); in drawSpecial()
735 SkRect src = SkRect::Make(special->subset()); in drawSpecial()
736 SkRect dst = SkRect::MakeWH(special->width(), special->height()); in drawSpecial()
740 GrAA aa = fSurfaceDrawContext->chooseAA(paint); in drawSpecial()
743 SkColorInfo colorInfo(special->colorType(), in drawSpecial()
744 special->alphaType(), in drawSpecial()
745 sk_ref_sp(special->getColorSpace())); in drawSpecial()
747 GrSurfaceProxyView view = special->view(this->recordingContext()); in drawSpecial()
748 SkImage_Gpu image(sk_ref_sp(special->getContext()), in drawSpecial() local
749 special->uniqueID(), in drawSpecial()
753 // alpha-only texture+shader, or a high filter quality. in drawSpecial()
754 SkOverrideDeviceMatrixProvider matrixProvider(this->asMatrixProvider(), localToDevice); in drawSpecial()
757 this->clip(), in drawSpecial()
760 image, in drawSpecial()
771 void Device::drawImageQuad(const SkImage* image, in drawImageQuad() argument
784 ImageDrawMode mode = optimize_sample_area(SkISize::Make(image->width(), image->height()), in drawImageQuad()
791 if (fContext->isPidAbnormal()) { in drawImageQuad()
795 if (src.contains(image->bounds())) { in drawImageQuad()
798 // Depending on the nature of image, it can flow through more or less optimal pipelines in drawImageQuad()
802 SkPreConcatMatrixProvider matrixProvider(this->asMatrixProvider(), in drawImageQuad()
807 bool sharpenMM = fContext->priv().options().fSharpenMipmappedTextures; in drawImageQuad()
811 auto clip = this->clip(); in drawImageQuad()
813 if (!image->isTextureBacked() && !as_IB(image)->isPinnedOnContext(fContext.get())) { in drawImageQuad()
822 int maxTileSize = fContext->priv().caps()->maxTextureSize() - 2*tileFilterPad; in drawImageQuad()
826 fSurfaceDrawContext->dimensions(), in drawImageQuad()
828 image->unique(), in drawImageQuad()
829 image->dimensions(), in drawImageQuad()
838 if (SkBitmap bm; as_IB(image)->getROPixels(nullptr, &bm)) { in drawImageQuad()
864 *as_IB(image), in drawImageQuad()
876 void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count, in drawEdgeAAImageSet() argument
886 SkASSERT(!set[i].fHasClip || dstClips); in drawEdgeAAImageSet()
887 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices); in drawEdgeAAImageSet()
890 if (set[i].fAlpha != 1.f) { in drawEdgeAAImageSet()
892 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha); in drawEdgeAAImageSet()
895 this->drawImageQuad( in drawEdgeAAImageSet()
896 set[i].fImage.get(), &set[i].fSrcRect, &set[i].fDstRect, in drawEdgeAAImageSet()
897 set[i].fHasClip ? dstClips + dstClipIndex : nullptr, GrAA::kYes, in drawEdgeAAImageSet()
898 SkToGrQuadAAFlags(set[i].fAAFlags), in drawEdgeAAImageSet()
899 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex, in drawEdgeAAImageSet()
901 dstClipIndex += 4 * set[i].fHasClip; in drawEdgeAAImageSet()
918 auto textureXform = GrColorSpaceXform::Make(set[base].fImage->imageInfo().colorInfo(), in drawEdgeAAImageSet()
919 fSurfaceDrawContext->colorInfo()); in drawEdgeAAImageSet()
920 fSurfaceDrawContext->drawTextureSet(this->clip(), in drawEdgeAAImageSet()
929 this->localToDevice(), in drawEdgeAAImageSet()
938 SkASSERT(!set[i].fHasClip || dstClips); in drawEdgeAAImageSet()
939 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices); in drawEdgeAAImageSet()
943 const SkPoint* clip = set[i].fHasClip ? dstClips + dstClipIndex : nullptr; in drawEdgeAAImageSet()
944 dstClipIndex += 4 * set[i].fHasClip; in drawEdgeAAImageSet()
947 // non-sorted src rects. TODO: Decide this is OK or make sure we handle it. in drawEdgeAAImageSet()
948 if (!set[i].fSrcRect.isSorted()) { in drawEdgeAAImageSet()
954 const SkImage_Base* image = as_IB(set[i].fImage.get()); in drawEdgeAAImageSet() local
955 // Extract view from image, but skip YUV images so they get processed through in drawEdgeAAImageSet()
957 if (!image->isYUVA()) { in drawEdgeAAImageSet()
958 std::tie(view, std::ignore) = image->asView(this->recordingContext(), GrMipmapped::kNo); in drawEdgeAAImageSet()
959 if (image->isAlphaOnly()) { in drawEdgeAAImageSet()
966 // This image can't go through the texture op, send through general image pipeline in drawEdgeAAImageSet()
970 if (set[i].fAlpha != 1.f) { in drawEdgeAAImageSet()
972 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha); in drawEdgeAAImageSet()
974 this->drawImageQuad( in drawEdgeAAImageSet()
975 image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes, in drawEdgeAAImageSet()
976 SkToGrQuadAAFlags(set[i].fAAFlags), in drawEdgeAAImageSet()
977 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex, in drawEdgeAAImageSet()
983 textures[i].fSrcAlphaType = image->alphaType(); in drawEdgeAAImageSet()
984 textures[i].fSrcRect = set[i].fSrcRect; in drawEdgeAAImageSet()
985 textures[i].fDstRect = set[i].fDstRect; in drawEdgeAAImageSet()
988 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex; in drawEdgeAAImageSet()
989 textures[i].fColor = texture_color(paint.getColor4f(), set[i].fAlpha, in drawEdgeAAImageSet()
990 SkColorTypeToGrColorType(image->colorType()), in drawEdgeAAImageSet()
991 fSurfaceDrawContext->colorInfo()); in drawEdgeAAImageSet()
992 textures[i].fAAFlags = SkToGrQuadAAFlags(set[i].fAAFlags); in drawEdgeAAImageSet()
999 set[i].fImage->alphaType() != set[base].fImage->alphaType() || in drawEdgeAAImageSet()
1000 !SkColorSpace::Equals(set[i].fImage->colorSpace(), set[base].fImage->colorSpace()))) { in drawEdgeAAImageSet()
1004 // set being accumulated so increment n, and increment p if proxies are different. in drawEdgeAAImageSet()
1006 if (n == 1 || textures[i - 1].fProxyView.proxy() != textures[i].fProxyView.proxy()) { in drawEdgeAAImageSet()
1008 // to i - 1). in drawEdgeAAImageSet()