Bug 1342720 - Optimize away the cost of creating and destroying nsBidi from CanvasRenderingContext2D::DrawOrMeasureText(); r=baku

The ICU implementation of ~nsBidi is particularly expensive because
it calls free() several times.
This commit is contained in:
Ehsan Akhgari 2017-02-25 20:40:09 -05:00
Родитель 0c87943561
Коммит 0fea8eec91
2 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -57,7 +57,6 @@
#include "gfxUtils.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "LayerUserData.h"
@ -4276,7 +4275,6 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
// calls bidi algo twice since it needs the full text width and the
// bounding boxes before rendering anything
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
@ -4286,7 +4284,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nullptr,
0,
&totalWidthCoord,
&bidiEngine);
&mBidiEngine);
if (NS_FAILED(rv)) {
return rv;
}
@ -4401,7 +4399,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nullptr,
0,
nullptr,
&bidiEngine);
&mBidiEngine);
mTarget->SetTransform(oldTransform);

Просмотреть файл

@ -29,6 +29,7 @@
#include "FilterSupport.h"
#include "nsSVGEffects.h"
#include "Layers.h"
#include "nsBidi.h"
class nsGlobalWindow;
class nsXULElement;
@ -864,6 +865,8 @@ protected:
nsTArray<RegionInfo> mHitRegionsOptions;
nsBidi mBidiEngine;
/**
* Returns true if a shadow should be drawn along with a
* drawing operation.