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()
356 const GrColorInfo& dstInfo = sdc->colorInfo(); in draw_texture()
357 auto textureXform = GrColorSpaceXform::Make(srcColorInfo, sdc->colorInfo()); in draw_texture()
361 if (constraint != SkCanvas::kStrict_SrcRectConstraint && !proxy->isFunctionallyExact()) { in draw_texture()
366 SkRect safeBounds = proxy->getBoundsRect(); in draw_texture()
379 sdc->drawTextureQuad(clip, in draw_texture()
395 sdc->drawTexture(clip, in draw_texture()
418 const SkImage_Base& image, in draw_image() argument
430 !image.isYUVA() && in draw_image()
434 auto [view, ct] = image.asView(rContext, GrMipmapped::kNo); in draw_image()
438 GrColorInfo info(image.imageInfo().colorInfo()); in draw_image()
461 bool canUseTextureCoordsAsLocalCoords = !use_shader(image.isAlphaOnly(), paint) && !mf; in draw_image()
467 if (mf && as_MFB(mf)->hasFragmentProcessor()) { in draw_image()
479 // TODO: Just rely on image to handle this. in draw_image()
485 !image.isYUVA()) { in draw_image()
488 if (can_ignore_linear_filtering_subset(src, combinedMatrix, sdc->numSamples())) { in draw_image()
504 std::unique_ptr<GrFragmentProcessor> fp = image.asFragmentProcessor(rContext, in draw_image()
511 image.imageInfo().colorInfo(), in draw_image()
512 sdc->colorInfo()); in draw_image()
513 if (image.isAlphaOnly()) { in draw_image()
515 auto shaderFP = shader->asFragmentProcessor( in draw_image()
516 GrFPArgs(rContext, matrixProvider, &sdc->colorInfo())); in draw_image()
530 rContext, sdc->colorInfo(), paint, matrixProvider, std::move(fp), &grPaint)) { in draw_image()
535 // Can draw the image directly (any mask filter on the paint was converted to an FP already) in draw_image()
544 sdc->fillQuadWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dstClip, srcClip); in draw_image()
547 sdc->fillRectWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dst, in draw_image()
551 // Must draw the mask filter as a GrStyledShape. For now, this loses the per-edge AA in draw_image()
616 // In texture-domain/clamp mode we only want to expand the in draw_tiled_bitmap()
626 // Image subsets always make a copy of the pixels and lose the association with the in draw_tiled_bitmap()
629 auto image = SkMakeImageFromRasterBitmap(subsetBmp, kNever_SkCopyPixelsMode); in draw_tiled_bitmap() local
631 SkASSERT(image->width() <= rContext->priv().caps()->maxTextureSize() && in draw_tiled_bitmap()
632 image->height() <= rContext->priv().caps()->maxTextureSize()); in draw_tiled_bitmap()
636 // If the entire bitmap was anti-aliased, turn on AA for the outside tile edges. in draw_tiled_bitmap()
652 tileR.offset(-offset.fX, -offset.fY); in draw_tiled_bitmap()
660 *as_IB(image.get()), in draw_tiled_bitmap()
689 // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until in can_disable_mipmap()
693 // Want: 0 = log2(1/s) - 0.5 in can_disable_mipmap()
713 SkASSERT(special->isTextureBacked()); in drawSpecial()
715 SkRect src = SkRect::Make(special->subset()); in drawSpecial()
716 SkRect dst = SkRect::MakeWH(special->width(), special->height()); in drawSpecial()
720 GrAA aa = fSurfaceDrawContext->chooseAA(paint); in drawSpecial()
723 SkColorInfo colorInfo(special->colorType(), in drawSpecial()
724 special->alphaType(), in drawSpecial()
725 sk_ref_sp(special->getColorSpace())); in drawSpecial()
727 GrSurfaceProxyView view = special->view(this->recordingContext()); in drawSpecial()
728 SkImage_Gpu image(sk_ref_sp(special->getContext()), in drawSpecial() local
729 special->uniqueID(), in drawSpecial()
733 // alpha-only texture+shader, or a high filter quality. in drawSpecial()
734 SkOverrideDeviceMatrixProvider matrixProvider(this->asMatrixProvider(), localToDevice); in drawSpecial()
737 this->clip(), in drawSpecial()
740 image, in drawSpecial()
751 void Device::drawImageQuad(const SkImage* image, in drawImageQuad() argument
764 ImageDrawMode mode = optimize_sample_area(SkISize::Make(image->width(), image->height()), in drawImageQuad()
771 if (fContext->isPidAbnormal()) { in drawImageQuad()
775 if (src.contains(image->bounds())) { in drawImageQuad()
778 // Depending on the nature of image, it can flow through more or less optimal pipelines in drawImageQuad()
782 SkPreConcatMatrixProvider matrixProvider(this->asMatrixProvider(), in drawImageQuad()
787 bool sharpenMM = fContext->priv().options().fSharpenMipmappedTextures; in drawImageQuad()
791 auto clip = this->clip(); in drawImageQuad()
793 if (!image->isTextureBacked() && !as_IB(image)->isPinnedOnContext(fContext.get())) { in drawImageQuad()
802 int maxTileSize = fContext->priv().caps()->maxTextureSize() - 2*tileFilterPad; in drawImageQuad()
806 fSurfaceDrawContext->dimensions(), in drawImageQuad()
808 image->unique(), in drawImageQuad()
809 image->dimensions(), in drawImageQuad()
818 if (SkBitmap bm; as_IB(image)->getROPixels(nullptr, &bm)) { in drawImageQuad()
844 *as_IB(image), in drawImageQuad()
856 void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count, in drawEdgeAAImageSet() argument
866 SkASSERT(!set[i].fHasClip || dstClips); in drawEdgeAAImageSet()
867 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices); in drawEdgeAAImageSet()
870 if (set[i].fAlpha != 1.f) { in drawEdgeAAImageSet()
872 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha); in drawEdgeAAImageSet()
875 this->drawImageQuad( in drawEdgeAAImageSet()
876 set[i].fImage.get(), &set[i].fSrcRect, &set[i].fDstRect, in drawEdgeAAImageSet()
877 set[i].fHasClip ? dstClips + dstClipIndex : nullptr, GrAA::kYes, in drawEdgeAAImageSet()
878 SkToGrQuadAAFlags(set[i].fAAFlags), in drawEdgeAAImageSet()
879 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex, in drawEdgeAAImageSet()
881 dstClipIndex += 4 * set[i].fHasClip; in drawEdgeAAImageSet()
898 auto textureXform = GrColorSpaceXform::Make(set[base].fImage->imageInfo().colorInfo(), in drawEdgeAAImageSet()
899 fSurfaceDrawContext->colorInfo()); in drawEdgeAAImageSet()
900 fSurfaceDrawContext->drawTextureSet(this->clip(), in drawEdgeAAImageSet()
909 this->localToDevice(), in drawEdgeAAImageSet()
918 SkASSERT(!set[i].fHasClip || dstClips); in drawEdgeAAImageSet()
919 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices); in drawEdgeAAImageSet()
923 const SkPoint* clip = set[i].fHasClip ? dstClips + dstClipIndex : nullptr; in drawEdgeAAImageSet()
924 dstClipIndex += 4 * set[i].fHasClip; in drawEdgeAAImageSet()
927 // non-sorted src rects. TODO: Decide this is OK or make sure we handle it. in drawEdgeAAImageSet()
928 if (!set[i].fSrcRect.isSorted()) { in drawEdgeAAImageSet()
934 const SkImage_Base* image = as_IB(set[i].fImage.get()); in drawEdgeAAImageSet() local
935 // Extract view from image, but skip YUV images so they get processed through in drawEdgeAAImageSet()
937 if (!image->isYUVA()) { in drawEdgeAAImageSet()
938 std::tie(view, std::ignore) = image->asView(this->recordingContext(), GrMipmapped::kNo); in drawEdgeAAImageSet()
939 if (image->isAlphaOnly()) { in drawEdgeAAImageSet()
946 // This image can't go through the texture op, send through general image pipeline in drawEdgeAAImageSet()
950 if (set[i].fAlpha != 1.f) { in drawEdgeAAImageSet()
952 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha); in drawEdgeAAImageSet()
954 this->drawImageQuad( in drawEdgeAAImageSet()
955 image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes, in drawEdgeAAImageSet()
956 SkToGrQuadAAFlags(set[i].fAAFlags), in drawEdgeAAImageSet()
957 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex, in drawEdgeAAImageSet()
963 textures[i].fSrcAlphaType = image->alphaType(); in drawEdgeAAImageSet()
964 textures[i].fSrcRect = set[i].fSrcRect; in drawEdgeAAImageSet()
965 textures[i].fDstRect = set[i].fDstRect; in drawEdgeAAImageSet()
968 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex; in drawEdgeAAImageSet()
969 textures[i].fColor = texture_color(paint.getColor4f(), set[i].fAlpha, in drawEdgeAAImageSet()
970 SkColorTypeToGrColorType(image->colorType()), in drawEdgeAAImageSet()
971 fSurfaceDrawContext->colorInfo()); in drawEdgeAAImageSet()
972 textures[i].fAAFlags = SkToGrQuadAAFlags(set[i].fAAFlags); in drawEdgeAAImageSet()
979 set[i].fImage->alphaType() != set[base].fImage->alphaType() || in drawEdgeAAImageSet()
980 !SkColorSpace::Equals(set[i].fImage->colorSpace(), set[base].fImage->colorSpace()))) { in drawEdgeAAImageSet()
984 // set being accumulated so increment n, and increment p if proxies are different. in drawEdgeAAImageSet()
986 if (n == 1 || textures[i - 1].fProxyView.proxy() != textures[i].fProxyView.proxy()) { in drawEdgeAAImageSet()
988 // to i - 1). in drawEdgeAAImageSet()