FloatRect FEGaussianBlur::determineAbsolutePaintRect(const FloatRect& originalRequestedRect) { FloatRect requestedRect = originalRequestedRect; if (clipsToBounds()) requestedRect.intersect(maxEffectRect()); FilterEffect* input = inputEffect(0); FloatRect inputRect = input->determineAbsolutePaintRect(mapRect(requestedRect, false)); FloatRect outputRect = mapRect(inputRect, true); outputRect.intersect(requestedRect); addAbsolutePaintRect(outputRect); // Blur needs space for both input and output pixels in the paint area. // Input is also clipped to subregion. if (clipsToBounds()) inputRect.intersect(maxEffectRect()); addAbsolutePaintRect(inputRect); return outputRect; }
void RenderImage::paintInvalidationOrMarkForLayout(const IntRect* rect) { ASSERT(isRooted()); LayoutSize oldIntrinsicSize = intrinsicSize(); LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(); updateIntrinsicSizeIfNeeded(newIntrinsicSize); bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize; if (imageSourceHasChangedSize) setPreferredLogicalWidthsDirty(); // If the actual area occupied by the image has changed and it is not constrained by style then a layout is required. bool imageSizeIsConstrained = style()->logicalWidth().isSpecified() && style()->logicalHeight().isSpecified(); // FIXME: We only need to recompute the containing block's preferred size if the containing block's size // depends on the image's size (i.e., the container uses shrink-to-fit sizing). // There's no easy way to detect that shrink-to-fit is needed, always force a layout. bool containingBlockNeedsToRecomputePreferredSize = style()->logicalWidth().isPercent() || style()->logicalMaxWidth().isPercent() || style()->logicalMinWidth().isPercent(); if (imageSourceHasChangedSize && (!imageSizeIsConstrained || containingBlockNeedsToRecomputePreferredSize)) { setNeedsLayoutAndFullPaintInvalidation(); return; } // The image hasn't changed in size or its style constrains its size, so a paint invalidation will suffice. if (everHadLayout() && !selfNeedsLayout()) { // The inner content rectangle is calculated during layout, but may need an update now // (unless the box has already been scheduled for layout). In order to calculate it, we // may need values from the containing block, though, so make sure that we're not too // early. It may be that layout hasn't even taken place once yet. updateInnerContentRect(); } LayoutRect paintInvalidationRect; if (rect) { // The image changed rect is in source image coordinates, // so map from the bounds of the image to the contentsBox. paintInvalidationRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatPoint(), m_imageResource->imageSize()), contentBoxRect())); // Guard against too-large changed rects. paintInvalidationRect.intersect(contentBoxRect()); } else { paintInvalidationRect = contentBoxRect(); } { // FIXME: We should not be allowing paint invalidations during layout. crbug.com/339584 AllowPaintInvalidationScope scoper(frameView()); DisableCompositingQueryAsserts disabler; invalidatePaintRectangle(paintInvalidationRect); } // Tell any potential compositing layers that the image needs updating. contentChanged(ImageChanged); }
FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect) { FloatRect result; if (m_inputEffects.size() > 0) { result = m_inputEffects.at(0)->mapRectRecursive(rect); for (unsigned i = 1; i < m_inputEffects.size(); ++i) result.unite(m_inputEffects.at(i)->mapRectRecursive(rect)); } else result = rect; return mapRect(result); }
void CGameMap::ShowMapTile(){ CPoint gridPoint(CConvert::GetGridPointByScreenPoint(CPoint(-64*6,-32*6))); //取得整個地圖的範圍,用於判斷是否再地圖內 CRect mapRect(0,0,sizeX-1,sizeY-1); for(int y=0;y<SIZE_Y/32+17;y++){//17為最佳化的值 for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x+=1; gridPoint.y-=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint) && this->mapTile[gridPoint.y][gridPoint.x].IsExplored()){ this->mapTile[gridPoint.y][gridPoint.x].OnShow(); } } gridPoint.x+=1; for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x-=1; gridPoint.y+=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint) && this->mapTile[gridPoint.y][gridPoint.x].IsExplored()){ this->mapTile[gridPoint.y][gridPoint.x].OnShow(); } } gridPoint.y+=1; } gridPoint = CConvert::GetGridPointByScreenPoint(CPoint(-64*6,-32*6)); for(int y=0;y<SIZE_Y/32+17;y++){//17為最佳化的值 for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x+=1; gridPoint.y-=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint) && this->mapTile[gridPoint.y][gridPoint.x].IsExplored()){ //this->mapTile[gridPoint.y][gridPoint.x].OnShow(); } } gridPoint.x+=1; for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x-=1; gridPoint.y+=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint) && this->mapTile[gridPoint.y][gridPoint.x].IsExplored()){ //this->mapTile[gridPoint.y][gridPoint.x].OnShow(); } } gridPoint.y+=1; } }
void FEDropShadow::determineAbsolutePaintRect() { Filter* filter = this->filter(); ASSERT(filter); FloatRect absolutePaintRect = mapRect(inputEffect(0)->absolutePaintRect()); if (clipsToBounds()) absolutePaintRect.intersect(maxEffectRect()); else absolutePaintRect.unite(maxEffectRect()); setAbsolutePaintRect(enclosingIntRect(absolutePaintRect)); }
void CGameMap::ShowSprites(){ CRect mapRect(0,0,sizeX-1,sizeY-1); CPoint gridPoint(CConvert::GetGridPointByScreenPoint(CPoint(-64*6,-32*6))); //gridPoint = CConvert::GetGridPointByScreenPoint(CPoint(-64*6,-32*6)); for(int y=0;y<SIZE_Y/32+17;y++){//17為最佳化的值 for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x+=1; gridPoint.y-=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint)){ if(!mapTile[gridPoint.y][gridPoint.x].IsExplored()){ continue; } if(mapTile[gridPoint.y][gridPoint.x].VisionCount()==0){//視野外只顯示房子 set<CSprite*>::iterator it; for(it = mapTile[gridPoint.y][gridPoint.x].Sprites().begin();it!= mapTile[gridPoint.y][gridPoint.x].Sprites().end();it++){ if((*it)->IsBuilding() || (*it)->IsResource()){ (*it)->OnShow(); } } }else{//再視野內 this->mapTile[gridPoint.y][gridPoint.x].OnShowSprites(); } } } gridPoint.x+=1; for(int x=0;x<SIZE_X/64+12;x++){ gridPoint.x-=1; gridPoint.y+=1; CPoint screenPoint(CConvert::GetScreenPointByGridPoint(gridPoint)); if(mapRect.PtInRect(gridPoint)){ if(!mapTile[gridPoint.y][gridPoint.x].IsExplored()){ continue; } if(mapTile[gridPoint.y][gridPoint.x].VisionCount()==0){//視野外只顯示房子 set<CSprite*>::iterator it; for(it = mapTile[gridPoint.y][gridPoint.x].Sprites().begin();it!= mapTile[gridPoint.y][gridPoint.x].Sprites().end();it++){ if((*it)->IsBuilding()){ (*it)->OnShow(); } } }else{//再視野內 this->mapTile[gridPoint.y][gridPoint.x].OnShowSprites(); } } } gridPoint.y+=1; } }
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription description) { #if PLATFORM(IOS) startAnimation(DoNotCatchUp); #else startAnimation(); #endif RetainPtr<CGImageRef> image; // Never use subsampled images for drawing into PDF contexts. if (wkCGContextIsPDFContext(ctxt->platformContext())) image = adoptCF(copyUnscaledFrameAtIndex(m_currentFrame)); else { CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(ctxt->platformContext())); float subsamplingScale = std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height())); image = frameAtIndex(m_currentFrame, subsamplingScale); } if (!image) // If it's too early we won't have an image yet. return; if (mayFillWithSolidColor()) { fillWithSolidColor(ctxt, destRect, solidColor(), styleColorSpace, compositeOp); return; } // Subsampling may have given us an image that is smaller than size(). IntSize imageSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get())); // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image. FloatRect scaledSrcRect = srcRect; if (imageSize != m_size) { FloatRect originalImageBounds(FloatPoint(), m_size); FloatRect subsampledImageBounds(FloatPoint(), imageSize); scaledSrcRect = mapRect(srcRect, originalImageBounds, subsampledImageBounds); } ImageOrientation orientation; if (description.respectImageOrientation() == RespectImageOrientation) orientation = frameOrientationAtIndex(m_currentFrame); ctxt->drawNativeImage(image.get(), imageSize, styleColorSpace, destRect, scaledSrcRect, compositeOp, blendMode, orientation); if (imageObserver()) imageObserver()->didDraw(this); }
FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlags flags) { Filter* filter = this->filter(); ASSERT(filter); // FETile, FETurbulence, FEFlood don't have input effects, take the filter region as unite rect. FloatRect subregion; if (unsigned numberOfInputEffects = inputEffects().size()) { subregion = inputEffect(0)->determineFilterPrimitiveSubregion(flags); for (unsigned i = 1; i < numberOfInputEffects; ++i) subregion.unite(inputEffect(i)->determineFilterPrimitiveSubregion(flags)); } else { subregion = filter->filterRegion(); } // After calling determineFilterPrimitiveSubregion on the target effect, reset the subregion again for <feTile>. if (filterEffectType() == FilterEffectTypeTile) subregion = filter->filterRegion(); if (flags & MapRectForward) { // mapRect works on absolute rectangles. subregion = filter->mapAbsoluteRectToLocalRect(mapRect( filter->mapLocalRectToAbsoluteRect(subregion))); } FloatRect boundaries = effectBoundaries(); if (hasX()) subregion.setX(boundaries.x()); if (hasY()) subregion.setY(boundaries.y()); if (hasWidth()) subregion.setWidth(boundaries.width()); if (hasHeight()) subregion.setHeight(boundaries.height()); setFilterPrimitiveSubregion(subregion); FloatRect absoluteSubregion = filter->mapLocalRectToAbsoluteRect(subregion); // Clip every filter effect to the filter region. if (flags & ClipToFilterRegion) { absoluteSubregion.intersect(filter->absoluteFilterRegion()); } setMaxEffectRect(absoluteSubregion); return subregion; }
void ImagePainter::paintIntoRect(GraphicsContext& context, const LayoutRect& destRect, const LayoutRect& contentRect) { if (!m_layoutImage.imageResource()->hasImage() || m_layoutImage.imageResource()->errorOccurred()) return; // FIXME: should we just ASSERT these conditions? (audit all // callers). IntRect pixelSnappedDestRect = pixelSnappedIntRect(destRect); if (pixelSnappedDestRect.isEmpty()) return; RefPtr<Image> image = m_layoutImage.imageResource()->image( pixelSnappedDestRect.size(), m_layoutImage.style()->effectiveZoom()); if (!image || image->isNull()) return; // FIXME: why is interpolation quality selection not included in the // Instrumentation reported cost of drawing an image? InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQuality( m_layoutImage, image.get(), image.get(), LayoutSize(pixelSnappedDestRect.size())); FloatRect srcRect = image->rect(); // If the content rect requires clipping, adjust |srcRect| and // |pixelSnappedDestRect| over using a clip. if (!contentRect.contains(destRect)) { IntRect pixelSnappedContentRect = pixelSnappedIntRect(contentRect); pixelSnappedContentRect.intersect(pixelSnappedDestRect); if (pixelSnappedContentRect.isEmpty()) return; srcRect = mapRect(pixelSnappedContentRect, pixelSnappedDestRect, srcRect); pixelSnappedDestRect = pixelSnappedContentRect; } TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data", InspectorPaintImageEvent::data(m_layoutImage)); InterpolationQuality previousInterpolationQuality = context.imageInterpolationQuality(); context.setImageInterpolationQuality(interpolationQuality); context.drawImage( image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode, LayoutObject::shouldRespectImageOrientation(&m_layoutImage)); context.setImageInterpolationQuality(previousInterpolationQuality); }
void HTMLCanvasElement::didFinalizeFrame() { if (m_dirtyRect.isEmpty()) return; // Propagate the m_dirtyRect accumulated so far to the compositor // before restarting with a blank dirty rect. FloatRect srcRect(0, 0, size().width(), size().height()); m_dirtyRect.intersect(srcRect); if (RenderBox* ro = renderBox()) { FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, ro->contentBoxRect()); ro->invalidatePaintRectangle(enclosingIntRect(mappedDirtyRect)); } notifyObserversCanvasChanged(m_dirtyRect); m_finalizeFrameTask.Cancel(); m_dirtyRect = FloatRect(); }
void HTMLCanvasElement::didFinalizeFrame() { if (m_dirtyRect.isEmpty()) return; // Propagate the m_dirtyRect accumulated so far to the compositor // before restarting with a blank dirty rect. FloatRect srcRect(0, 0, size().width(), size().height()); m_dirtyRect.intersect(srcRect); if (RenderBox* ro = renderBox()) { FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, ro->contentBoxRect()); // For querying RenderLayer::compositingState() // FIXME: is this invalidation using the correct compositing state? DisableCompositingQueryAsserts disabler; ro->invalidatePaintRectangle(enclosingIntRect(mappedDirtyRect)); } notifyObserversCanvasChanged(m_dirtyRect); blink::Platform::current()->currentThread()->removeTaskObserver(this); m_dirtyRect = FloatRect(); }
FloatRect FilterEffect::determineFilterPrimitiveSubregion() { ASSERT(filter()); // FETile, FETurbulence, FEFlood don't have input effects, take the filter region as unite rect. FloatRect subregion; if (unsigned numberOfInputEffects = inputEffects().size()) { subregion = inputEffect(0)->determineFilterPrimitiveSubregion(); for (unsigned i = 1; i < numberOfInputEffects; ++i) subregion.unite(inputEffect(i)->determineFilterPrimitiveSubregion()); } else subregion = filter()->filterRegion(); // After calling determineFilterPrimitiveSubregion on the target effect, reset the subregion again for <feTile>. if (filterEffectType() == FilterEffectTypeTile) subregion = filter()->filterRegion(); subregion = mapRect(subregion); FloatRect boundaries = effectBoundaries(); if (hasX()) subregion.setX(boundaries.x()); if (hasY()) subregion.setY(boundaries.y()); if (hasWidth()) subregion.setWidth(boundaries.width()); if (hasHeight()) subregion.setHeight(boundaries.height()); setFilterPrimitiveSubregion(subregion); FloatRect absoluteSubregion = filter()->absoluteTransform().mapRect(subregion); FloatSize filterResolution = filter()->filterResolution(); absoluteSubregion.scale(filterResolution.width(), filterResolution.height()); setMaxEffectRect(absoluteSubregion); return subregion; }
IntRect AffineTransform::mapRect(const IntRect &rect) const { return enclosingIntRect(mapRect(FloatRect(rect))); }
IntRect TransformationMatrix::mapRect(const IntRect &rect) const { return enclosingIntRect(mapRect(FloatRect(rect))); }
bool MapTilesFrame::isInMap(QPoint serverCoordinate, int scaleLevel) { QRect mapRect(0, 0, scaleMaps[scaleLevel].width, scaleMaps[scaleLevel].height); return mapRect.contains(serverCoordinate); }