Commit b1c9a8e5 authored by gyuyoung.kim@samsung.com's avatar gyuyoung.kim@samsung.com
Browse files

<https://webkit.org/b/92330> [CSS] Pass an image orientation data to drawImage()

Reviewed by Beth Dakin.

In support of ongoing css3-images image-orientation implementation. This patch passes
an imageOrientationDescription object to drawImage() function as a argument. The drawImage()
can know information of image orientation by the argument.

Spec: http://www.w3.org/TR/2012/CR-css3-images-20120417/#the-image-orientation

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::paint):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawImage):
(WebCore::drawImageToContext):
* platform/graphics/ImageOrientation.h: Add setter functions.
(WebCore::ImageOrientationDescription::setRespectImageOrientation):
(WebCore::ImageOrientationDescription::setImageOrientationEnum):
* platform/graphics/texmap/TextureMapperImageBuffer.cpp:
(WebCore::BitmapTextureImageBuffer::updateContents):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintNinePieceImage):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintReplaced):
(WebCore::RenderImage::paintIntoRect):
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::paintSnapshot):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e0099816
2013-08-20 David Barr <davidbarr@chromium.org>, Gyuyoung Kim <gyuyoung.kim@samsung.com>
<https://webkit.org/b/92330> [CSS] Pass an image orientation data to drawImage()
Reviewed by Beth Dakin.
In support of ongoing css3-images image-orientation implementation. This patch passes
an imageOrientationDescription object to drawImage() function as a argument. The drawImage()
can know information of image orientation by the argument.
Spec: http://www.w3.org/TR/2012/CR-css3-images-20120417/#the-image-orientation
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::paint):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawImage):
(WebCore::drawImageToContext):
* platform/graphics/ImageOrientation.h: Add setter functions.
(WebCore::ImageOrientationDescription::setRespectImageOrientation):
(WebCore::ImageOrientationDescription::setImageOrientationEnum):
* platform/graphics/texmap/TextureMapperImageBuffer.cpp:
(WebCore::BitmapTextureImageBuffer::updateContents):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintNinePieceImage):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintReplaced):
(WebCore::RenderImage::paintIntoRect):
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::paintSnapshot):
2013-08-20 Gavin Barraclough <barraclough@apple.com>
 
https://bugs.webkit.org/show_bug.cgi?id=120093
......@@ -404,9 +404,13 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, boo
if (hasCreatedImageBuffer()) {
ImageBuffer* imageBuffer = buffer();
if (imageBuffer) {
if (m_presentedImage)
context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, ImageOrientationDescription(), useLowQualityScale);
else
if (m_presentedImage) {
ImageOrientationDescription orientationDescription;
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(renderer()->style()->imageOrientation());
#endif
context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, orientationDescription, useLowQualityScale);
} else
context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, BlendModeNormal, useLowQualityScale);
}
}
......
......@@ -1308,17 +1308,17 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec
checkOrigin(image);
if (rectContainsCanvas(normalizedDstRect)) {
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode);
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode, ImageOrientationDescription());
didDrawEntireCanvas();
} else if (isFullCanvasCompositeMode(op)) {
fullCanvasCompositedDrawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op);
didDrawEntireCanvas();
} else if (op == CompositeCopy) {
clearCanvas();
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode);
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode, ImageOrientationDescription());
didDrawEntireCanvas();
} else {
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode);
c->drawImage(cachedImage->imageForRenderer(image->renderer()), ColorSpaceDeviceRGB, normalizedDstRect, normalizedSrcRect, op, blendMode, ImageOrientationDescription());
didDraw(normalizedDstRect);
}
}
......@@ -1577,7 +1577,7 @@ void CanvasRenderingContext2D::compositeBuffer(ImageBuffer* buffer, const IntRec
static void drawImageToContext(Image* image, GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op)
{
context->drawImage(image, styleColorSpace, dest, src, op);
context->drawImage(image, styleColorSpace, dest, src, op, ImageOrientationDescription());
}
static void drawImageToContext(ImageBuffer* imageBuffer, GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op)
......
......@@ -72,7 +72,10 @@ struct ImageOrientationDescription {
{
}
void setRespectImageOrientation(RespectImageOrientationEnum shouldRespectImageOrientation) { m_respectOrientation = shouldRespectImageOrientation; }
RespectImageOrientationEnum respectImageOrientation() { return m_respectOrientation; }
void setImageOrientationEnum(ImageOrientationEnum orientation) { m_orientation = orientation; }
ImageOrientationEnum imageOrientation() { return m_orientation; }
RespectImageOrientationEnum m_respectOrientation;
......
......@@ -79,7 +79,7 @@ void BitmapTextureImageBuffer::didReset()
void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag)
{
m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy);
m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy, ImageOrientationDescription());
}
IntSize TextureMapperImageBuffer::maxTextureSize() const
......
......@@ -1453,13 +1453,13 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
// The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
if (drawTop)
graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.location(), IntSize(leftWidth, topWidth)),
LayoutRect(0, 0, leftSlice, topSlice), op);
LayoutRect(0, 0, leftSlice, topSlice), op, ImageOrientationDescription());
// The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
// The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
if (drawBottom)
graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth),
LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op, ImageOrientationDescription());
// Paint the left edge.
// Have to scale and tile into the border rect.
......@@ -1476,13 +1476,13 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
// The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
if (drawTop)
graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y(), rightWidth, topWidth),
LayoutRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
LayoutRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op, ImageOrientationDescription());
// The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
// The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
if (drawBottom)
graphicsContext->drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth),
LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op, ImageOrientationDescription());
// Paint the right edge.
if (sourceHeight > 0)
......
......@@ -353,7 +353,13 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf
if (centerY < 0)
centerY = 0;
imageOffset = LayoutSize(leftBorder + leftPad + centerX + borderWidth, topBorder + topPad + centerY + borderWidth);
context->drawImage(image.get(), style()->colorSpace(), pixelSnappedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOver, ImageOrientationDescription(shouldRespectImageOrientation()));
ImageOrientationDescription orientationDescription;
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(style()->imageOrientation());
orientationDescription.setRespectImageOrientation(shouldRespectImageOrientation());
#endif
context->drawImage(image.get(), style()->colorSpace(), pixelSnappedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOver, orientationDescription);
errorPictureDrawn = true;
}
......@@ -475,7 +481,12 @@ void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect
CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
Image* image = m_imageResource->image().get();
bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, ImageOrientationDescription(shouldRespectImageOrientation()), useLowQualityScaling);
ImageOrientationDescription orientationDescription;
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(style()->imageOrientation());
orientationDescription.setRespectImageOrientation(shouldRespectImageOrientation());
#endif
context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, orientationDescription, useLowQualityScaling);
}
bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const
......
......@@ -139,7 +139,12 @@ void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPo
return;
bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
context->drawImage(image, style()->colorSpace(), alignedRect, CompositeSourceOver, ImageOrientationDescription(shouldRespectImageOrientation()), useLowQualityScaling);
ImageOrientationDescription orientationDescription;
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(style()->imageOrientation());
#endif
context->drawImage(image, style()->colorSpace(), alignedRect, CompositeSourceOver, orientationDescription, useLowQualityScaling);
}
CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cursor& overrideCursor) const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment