зеркало из https://github.com/mozilla/gecko-dev.git
Bug 484150 - support image-rendering attribute. Includes some gfx code by vlad from bug 423756 which is r=joe. The rest is r=dbaron, sr=roc
This commit is contained in:
Родитель
2922dc0a25
Коммит
fb4afd4ad6
|
@ -662,7 +662,7 @@ nsThebesImage::Draw(gfxContext* aContext,
|
|||
deviceToImage.xx >= 1.0 && deviceToImage.yy >= 1.0 &&
|
||||
deviceToImage.xy == 0.0 && deviceToImage.yx == 0.0;
|
||||
if (!isDownscale) {
|
||||
pattern->SetFilter(0);
|
||||
pattern->SetFilter(gfxPattern::FILTER_FAST);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -99,8 +99,17 @@ public:
|
|||
|
||||
int CairoStatus();
|
||||
|
||||
void SetFilter(int filter);
|
||||
int Filter() const;
|
||||
enum GraphicsFilter {
|
||||
FILTER_FAST,
|
||||
FILTER_GOOD,
|
||||
FILTER_BEST,
|
||||
FILTER_NEAREST,
|
||||
FILTER_BILINEAR,
|
||||
FILTER_GAUSSIAN
|
||||
};
|
||||
|
||||
void SetFilter(GraphicsFilter filter);
|
||||
GraphicsFilter Filter() const;
|
||||
|
||||
/* returns TRUE if it succeeded */
|
||||
PRBool GetSolidColor(gfxRGBA& aColor);
|
||||
|
|
|
@ -154,15 +154,15 @@ gfxPattern::Extend() const
|
|||
}
|
||||
|
||||
void
|
||||
gfxPattern::SetFilter(int filter)
|
||||
gfxPattern::SetFilter(GraphicsFilter filter)
|
||||
{
|
||||
cairo_pattern_set_filter(mPattern, (cairo_filter_t)filter);
|
||||
}
|
||||
|
||||
int
|
||||
gfxPattern::GraphicsFilter
|
||||
gfxPattern::Filter() const
|
||||
{
|
||||
return (int)cairo_pattern_get_filter(mPattern);
|
||||
return (GraphicsFilter)cairo_pattern_get_filter(mPattern);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
|
|
@ -279,7 +279,7 @@ gfxWindowsNativeDrawing::PaintToContext()
|
|||
pat->SetMatrix(m);
|
||||
|
||||
if (mNativeDrawFlags & DO_NEAREST_NEIGHBOR_FILTERING)
|
||||
pat->SetFilter(0);
|
||||
pat->SetFilter(gfxPattern::FILTER_FAST);
|
||||
|
||||
mContext->SetPattern(pat);
|
||||
mContext->Fill();
|
||||
|
|
|
@ -742,6 +742,12 @@
|
|||
#define NS_STYLE_FILL_RULE_NONZERO 0
|
||||
#define NS_STYLE_FILL_RULE_EVENODD 1
|
||||
|
||||
// image-rendering
|
||||
#define NS_STYLE_IMAGE_RENDERING_AUTO 0
|
||||
#define NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED 1
|
||||
#define NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY 2
|
||||
#define NS_STYLE_IMAGE_RENDERING_DISABLE_RESAMPLING 3
|
||||
|
||||
// pointer-events
|
||||
#define NS_STYLE_POINTER_EVENTS_NONE 0
|
||||
#define NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED 1
|
||||
|
|
|
@ -605,6 +605,7 @@ CSS_KEY(no-change, no_change)
|
|||
//CSS_KEY(none, none)
|
||||
CSS_KEY(nonzero, nonzero)
|
||||
CSS_KEY(optimizelegibility, optimizelegibility)
|
||||
CSS_KEY(optimizequality, optimizequality)
|
||||
CSS_KEY(optimizespeed, optimizespeed)
|
||||
CSS_KEY(painted, painted)
|
||||
CSS_KEY(reset-size, reset_size)
|
||||
|
@ -619,4 +620,5 @@ CSS_KEY(use-script, use_script)
|
|||
CSS_KEY(visiblefill, visiblefill)
|
||||
CSS_KEY(visiblepainted, visiblepainted)
|
||||
CSS_KEY(visiblestroke, visiblestroke)
|
||||
CSS_KEY(-moz-disable-resampling, _moz_disable_resampling)
|
||||
#endif
|
||||
|
|
|
@ -5494,6 +5494,9 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue,
|
|||
return ParseVariant(aValue, VARIANT_HC, nsnull);
|
||||
case eCSSProperty_flood_opacity:
|
||||
return ParseVariant(aValue, VARIANT_HN, nsnull);
|
||||
case eCSSProperty_image_rendering:
|
||||
return ParseVariant(aValue, VARIANT_AHK,
|
||||
nsCSSProps::kImageRenderingKTable);
|
||||
case eCSSProperty_lighting_color:
|
||||
return ParseVariant(aValue, VARIANT_HC, nsnull);
|
||||
case eCSSProperty_marker_end:
|
||||
|
|
|
@ -577,6 +577,7 @@ CSS_PROP_SVG(fill-rule, fill_rule, FillRule, 0, SVG, mFillRule, eCSSType_Value,
|
|||
CSS_PROP_SVGRESET(filter, filter, Filter, 0, SVG, mFilter, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVGRESET(flood-color, flood_color, FloodColor, 0, SVG, mFloodColor, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVGRESET(flood-opacity, flood_opacity, FloodOpacity, 0, SVG, mFloodOpacity, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(image-rendering, image_rendering, ImageRendering, 0, SVG, mImageRendering, eCSSType_Value, kImageRenderingKTable)
|
||||
CSS_PROP_SVGRESET(lighting-color, lighting_color, LightingColor, 0, SVG, mLightingColor, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SHORTHAND(marker, marker, Marker, 0)
|
||||
CSS_PROP_SVG(marker-end, marker_end, MarkerEnd, 0, SVG, mMarkerEnd, eCSSType_Value, nsnull)
|
||||
|
|
|
@ -1255,6 +1255,13 @@ const PRInt32 nsCSSProps::kFillRuleKTable[] = {
|
|||
eCSSKeyword_UNKNOWN, -1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kImageRenderingKTable[] = {
|
||||
eCSSKeyword_optimizespeed, NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED,
|
||||
eCSSKeyword_optimizequality, NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY,
|
||||
eCSSKeyword__moz_disable_resampling, NS_STYLE_IMAGE_RENDERING_DISABLE_RESAMPLING,
|
||||
eCSSKeyword_UNKNOWN, -1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kPointerEventsKTable[] = {
|
||||
eCSSKeyword_visiblepainted, NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED,
|
||||
eCSSKeyword_visiblefill, NS_STYLE_POINTER_EVENTS_VISIBLEFILL,
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
#ifdef MOZ_SVG
|
||||
static const PRInt32 kDominantBaselineKTable[];
|
||||
static const PRInt32 kFillRuleKTable[];
|
||||
static const PRInt32 kImageRenderingKTable[];
|
||||
static const PRInt32 kPointerEventsKTable[];
|
||||
static const PRInt32 kShapeRenderingKTable[];
|
||||
static const PRInt32 kStrokeLinecapKTable[];
|
||||
|
|
|
@ -681,6 +681,7 @@ struct nsCSSSVG : public nsCSSStruct {
|
|||
nsCSSValue mFilter;
|
||||
nsCSSValue mFloodColor;
|
||||
nsCSSValue mFloodOpacity;
|
||||
nsCSSValue mImageRendering;
|
||||
nsCSSValue mLightingColor;
|
||||
nsCSSValue mMarkerEnd;
|
||||
nsCSSValue mMarkerMid;
|
||||
|
|
|
@ -3872,6 +3872,24 @@ nsComputedDOMStyle::GetDominantBaseline(nsIDOMCSSValue** aValue)
|
|||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetImageRendering(nsIDOMCSSValue** aValue)
|
||||
{
|
||||
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
|
||||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
const nsStyleSVG* svg = GetStyleSVG();
|
||||
|
||||
if (svg->mImageRendering != NS_STYLE_IMAGE_RENDERING_AUTO) {
|
||||
val->SetIdent(nsCSSProps::ValueToKeywordEnum(
|
||||
svg->mImageRendering, nsCSSProps::kImageRenderingKTable));
|
||||
} else {
|
||||
val->SetIdent(eCSSKeyword_auto);
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetPointerEvents(nsIDOMCSSValue** aValue)
|
||||
{
|
||||
|
@ -4240,6 +4258,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
|
|||
COMPUTED_STYLE_MAP_ENTRY(flood_color, FloodColor),
|
||||
COMPUTED_STYLE_MAP_ENTRY(flood_opacity, FloodOpacity),
|
||||
COMPUTED_STYLE_MAP_ENTRY(lighting_color, LightingColor),
|
||||
COMPUTED_STYLE_MAP_ENTRY(image_rendering, ImageRendering),
|
||||
COMPUTED_STYLE_MAP_ENTRY(mask, Mask),
|
||||
COMPUTED_STYLE_MAP_ENTRY(marker_end, MarkerEnd),
|
||||
COMPUTED_STYLE_MAP_ENTRY(marker_mid, MarkerMid),
|
||||
|
|
|
@ -334,6 +334,7 @@ private:
|
|||
nsresult GetColorInterpolation(nsIDOMCSSValue** aValue);
|
||||
nsresult GetColorInterpolationFilters(nsIDOMCSSValue** aValue);
|
||||
nsresult GetDominantBaseline(nsIDOMCSSValue** aValue);
|
||||
nsresult GetImageRendering(nsIDOMCSSValue** aValue);
|
||||
nsresult GetPointerEvents(nsIDOMCSSValue** aValue);
|
||||
nsresult GetShapeRendering(nsIDOMCSSValue** aValue);
|
||||
nsresult GetTextRendering(nsIDOMCSSValue** aValue);
|
||||
|
|
|
@ -5219,6 +5219,13 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
|
|||
SETDSC_ENUMERATED, parentSVG->mFillRule,
|
||||
NS_STYLE_FILL_RULE_NONZERO, 0, 0, 0, 0);
|
||||
|
||||
// image-rendering: enum, auto, inherit
|
||||
SetDiscrete(SVGData.mImageRendering, svg->mImageRendering, canStoreInRuleTree,
|
||||
SETDSC_ENUMERATED | SETDSC_AUTO,
|
||||
parentSVG->mImageRendering,
|
||||
NS_STYLE_IMAGE_RENDERING_AUTO,
|
||||
NS_STYLE_IMAGE_RENDERING_AUTO, 0, 0, 0);
|
||||
|
||||
// marker-end: url, none, inherit
|
||||
if (eCSSUnit_URL == SVGData.mMarkerEnd.GetUnit()) {
|
||||
svg->mMarkerEnd = SVGData.mMarkerEnd.GetURLValue();
|
||||
|
|
|
@ -768,6 +768,7 @@ nsStyleSVG::nsStyleSVG()
|
|||
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
||||
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
|
||||
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
||||
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
|
||||
mPointerEvents = NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED;
|
||||
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
|
||||
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
|
||||
|
@ -816,6 +817,7 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
mColorInterpolation = aSource.mColorInterpolation;
|
||||
mColorInterpolationFilters = aSource.mColorInterpolationFilters;
|
||||
mFillRule = aSource.mFillRule;
|
||||
mImageRendering = aSource.mImageRendering;
|
||||
mPointerEvents = aSource.mPointerEvents;
|
||||
mShapeRendering = aSource.mShapeRendering;
|
||||
mStrokeLinecap = aSource.mStrokeLinecap;
|
||||
|
@ -875,6 +877,7 @@ nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
|||
mColorInterpolation != aOther.mColorInterpolation ||
|
||||
mColorInterpolationFilters != aOther.mColorInterpolationFilters ||
|
||||
mFillRule != aOther.mFillRule ||
|
||||
mImageRendering != aOther.mImageRendering ||
|
||||
mShapeRendering != aOther.mShapeRendering ||
|
||||
mStrokeDasharrayLength != aOther.mStrokeDasharrayLength ||
|
||||
mStrokeLinecap != aOther.mStrokeLinecap ||
|
||||
|
|
|
@ -1510,6 +1510,7 @@ struct nsStyleSVG {
|
|||
PRUint8 mColorInterpolation; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mFillRule; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mImageRendering; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mShapeRendering; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mStrokeLinecap; // [inherited] see nsStyleConsts.h
|
||||
|
|
|
@ -1887,6 +1887,14 @@ var gCSSProperties = {
|
|||
other_values: [ "0", "0.3", "-7.3" ],
|
||||
invalid_values: []
|
||||
},
|
||||
"image-rendering": {
|
||||
domProp: null,
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "auto" ],
|
||||
other_values: [ "optimizeSpeed", "optimizeQuality", "-moz-disable-resampling" ],
|
||||
invalid_values: []
|
||||
},
|
||||
"lighting-color": {
|
||||
domProp: null,
|
||||
inherited: false,
|
||||
|
|
|
@ -255,6 +255,22 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||
}
|
||||
|
||||
if (thebesPattern) {
|
||||
|
||||
switch (GetStyleSVG()->mImageRendering) {
|
||||
case NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED:
|
||||
thebesPattern->SetFilter(gfxPattern::FILTER_FAST);
|
||||
break;
|
||||
case NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY:
|
||||
thebesPattern->SetFilter(gfxPattern::FILTER_BEST);
|
||||
break;
|
||||
case NS_STYLE_IMAGE_RENDERING_DISABLE_RESAMPLING:
|
||||
thebesPattern->SetFilter(gfxPattern::FILTER_NEAREST);
|
||||
break;
|
||||
default:
|
||||
thebesPattern->SetFilter(gfxPattern::FILTER_GOOD);
|
||||
break;
|
||||
}
|
||||
|
||||
gfxContext *gfx = aContext->GetGfxContext();
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче