Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: src/ports/SkScalerContext_win_dw.cpp

Issue 2019383003: Remove DWrite locks (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkScalerContext_win_dw.cpp
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index c9ff5d86c35e2f8efd0eb5aec882631b0cd2fb13..481ae703e980b521623e88910a4e33d965e476c8 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -18,7 +18,6 @@
#include "SkHRESULT.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
-#include "SkMutex.h"
#include "SkOTTable_EBLC.h"
#include "SkOTTable_EBSC.h"
#include "SkOTTable_gasp.h"
@@ -27,7 +26,6 @@
#include "SkRasterClip.h"
#include "SkScalerContext.h"
#include "SkScalerContext_win_dw.h"
-#include "SkSharedMutex.h"
#include "SkTScopedComPtr.h"
#include "SkTypeface_win_dw.h"
@@ -36,20 +34,11 @@
# include <dwrite_1.h>
#endif
-/* Note:
- * In versions 8 and 8.1 of Windows, some calls in DWrite are not thread safe.
- * The DWriteFactoryMutex protects the calls that are problematic.
- */
-static SkSharedMutex DWriteFactoryMutex;
-
-typedef SkAutoSharedMutexShared Shared;
-
static bool isLCD(const SkScalerContext::Rec& rec) {
return SkMask::kLCD16_Format == rec.fMaskFormat;
}
static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) {
- SkAutoExclusive l(DWriteFactoryMutex);
AutoTDWriteTable<SkOTTableMaximumProfile> maxp(typeface->fDWriteFontFace.get());
if (!maxp.fExists) {
return false;
@@ -119,7 +108,6 @@ static void expand_range_if_gridfit_only(DWriteFontTypeface* typeface, int size,
}
static bool has_bitmap_strike(DWriteFontTypeface* typeface, PPEMRange range) {
- SkAutoExclusive l(DWriteFactoryMutex);
{
AutoTDWriteTable<SkOTTableEmbeddedBitmapLocation> eblc(typeface->fDWriteFontFace.get());
if (!eblc.fExists) {
@@ -362,7 +350,6 @@ void SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
if (DWRITE_MEASURING_MODE_GDI_CLASSIC == fMeasuringMode ||
DWRITE_MEASURING_MODE_GDI_NATURAL == fMeasuringMode)
{
- SkAutoExclusive l(DWriteFactoryMutex);
HRVM(fTypeface->fDWriteFontFace->GetGdiCompatibleGlyphMetrics(
fTextSizeMeasure,
1.0f, // pixelsPerDip
@@ -372,16 +359,12 @@ void SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
&gm),
"Could not get gdi compatible glyph metrics.");
} else {
- SkAutoExclusive l(DWriteFactoryMutex);
HRVM(fTypeface->fDWriteFontFace->GetDesignGlyphMetrics(&glyphId, 1, &gm),
"Could not get design metrics.");
}
DWRITE_FONT_METRICS dwfm;
- {
- Shared l(DWriteFactoryMutex);
- fTypeface->fDWriteFontFace->GetMetrics(&dwfm);
- }
+ fTypeface->fDWriteFontFace->GetMetrics(&dwfm);
SkScalar advanceX = SkScalarMulDiv(fTextSizeMeasure,
SkIntToScalar(gm.advanceWidth),
SkIntToScalar(dwfm.designUnitsPerEm));
@@ -430,24 +413,18 @@ HRESULT SkScalerContext_DW::getBoundingBox(SkGlyph* glyph,
run.glyphOffsets = &offset;
SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
- {
- SkAutoExclusive l(DWriteFactoryMutex);
- HRM(fTypeface->fFactory->CreateGlyphRunAnalysis(
- &run,
- 1.0f, // pixelsPerDip,
- &fXform,
- renderingMode,
- fMeasuringMode,
- 0.0f, // baselineOriginX,
- 0.0f, // baselineOriginY,
- &glyphRunAnalysis),
- "Could not create glyph run analysis.");
- }
- {
- Shared l(DWriteFactoryMutex);
- HRM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox),
- "Could not get texture bounds.");
- }
+ HRM(fTypeface->fFactory->CreateGlyphRunAnalysis(
+ &run,
+ 1.0f, // pixelsPerDip,
+ &fXform,
+ renderingMode,
+ fMeasuringMode,
+ 0.0f, // baselineOriginX,
+ 0.0f, // baselineOriginY,
+ &glyphRunAnalysis),
+ "Could not create glyph run analysis.");
+ HRM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox),
+ "Could not get texture bounds.");
return S_OK;
}
@@ -735,18 +712,15 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
{
SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
- {
- SkAutoExclusive l(DWriteFactoryMutex);
- HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run,
- 1.0f, // pixelsPerDip,
- &fXform,
- renderingMode,
- fMeasuringMode,
- 0.0f, // baselineOriginX,
- 0.0f, // baselineOriginY,
- &glyphRunAnalysis),
- "Could not create glyph run analysis.");
- }
+ HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run,
+ 1.0f, // pixelsPerDip,
+ &fXform,
+ renderingMode,
+ fMeasuringMode,
+ 0.0f, // baselineOriginX,
+ 0.0f, // baselineOriginY,
+ &glyphRunAnalysis),
+ "Could not create glyph run analysis.");
//NOTE: this assumes that the glyph has already been measured
//with an exact same glyph run analysis.
RECT bbox;
@@ -754,14 +728,11 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
bbox.top = glyph.fTop;
bbox.right = glyph.fLeft + glyph.fWidth;
bbox.bottom = glyph.fTop + glyph.fHeight;
- {
- Shared l(DWriteFactoryMutex);
- HRNM(glyphRunAnalysis->CreateAlphaTexture(textureType,
- &bbox,
- fBits.begin(),
- sizeNeeded),
- "Could not draw mask.");
- }
+ HRNM(glyphRunAnalysis->CreateAlphaTexture(textureType,
+ &bbox,
+ fBits.begin(),
+ sizeNeeded),
+ "Could not draw mask.");
}
return fBits.begin();
}
@@ -819,19 +790,16 @@ void SkScalerContext_DW::generateColorGlyphImage(const SkGlyph& glyph) {
SkTScopedComPtr<IDWriteGeometrySink> geometryToPath;
HRVM(SkDWriteGeometrySink::Create(&path, &geometryToPath),
"Could not create geometry to path converter.");
- {
- SkAutoExclusive l(DWriteFactoryMutex);
- HRVM(colorGlyph->glyphRun.fontFace->GetGlyphRunOutline(
- colorGlyph->glyphRun.fontEmSize,
- colorGlyph->glyphRun.glyphIndices,
- colorGlyph->glyphRun.glyphAdvances,
- colorGlyph->glyphRun.glyphOffsets,
- colorGlyph->glyphRun.glyphCount,
- colorGlyph->glyphRun.isSideways,
- colorGlyph->glyphRun.bidiLevel % 2, //rtl
- geometryToPath.get()),
- "Could not create glyph outline.");
- }
+ HRVM(colorGlyph->glyphRun.fontFace->GetGlyphRunOutline(
+ colorGlyph->glyphRun.fontEmSize,
+ colorGlyph->glyphRun.glyphIndices,
+ colorGlyph->glyphRun.glyphAdvances,
+ colorGlyph->glyphRun.glyphOffsets,
+ colorGlyph->glyphRun.glyphCount,
+ colorGlyph->glyphRun.isSideways,
+ colorGlyph->glyphRun.bidiLevel % 2, //rtl
+ geometryToPath.get()),
+ "Could not create glyph outline.");
draw.drawPath(path, paint, nullptr, true /* pathIsMutable */);
}
}
@@ -897,20 +865,17 @@ void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) {
HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath),
"Could not create geometry to path converter.");
uint16_t glyphId = glyph.getGlyphID();
- {
- SkAutoExclusive l(DWriteFactoryMutex);
- //TODO: convert to<->from DIUs? This would make a difference if hinting.
- //It may not be needed, it appears that DirectWrite only hints at em size.
- HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSizeRender),
- &glyphId,
- nullptr, //advances
- nullptr, //offsets
- 1, //num glyphs
- FALSE, //sideways
- FALSE, //rtl
- geometryToPath.get()),
- "Could not create glyph outline.");
- }
+ //TODO: convert to<->from DIUs? This would make a difference if hinting.
+ //It may not be needed, it appears that DirectWrite only hints at em size.
+ HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSizeRender),
+ &glyphId,
+ nullptr, //advances
+ nullptr, //offsets
+ 1, //num glyphs
+ FALSE, //sideways
+ FALSE, //rtl
+ geometryToPath.get()),
+ "Could not create glyph outline.");
path->transform(fSkXform);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698