Remove CFX_ThreadLock (its a no-op)
We wouldn't want to imply that any of this is
thread-safe ...
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1724483002 .
diff --git a/xfa/src/fdp/src/css/fde_csscache.h b/xfa/src/fdp/src/css/fde_csscache.h
index 637fd11..d42821b 100644
--- a/xfa/src/fdp/src/css/fde_csscache.h
+++ b/xfa/src/fdp/src/css/fde_csscache.h
@@ -14,7 +14,6 @@
FX_DWORD dwActivity;
} FDE_CSSCACHEITEM, *FDE_LPCSSCACHEITEM;
class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache,
- public CFX_ThreadLock,
public CFX_Target {
public:
CFDE_CSSStyleSheetCache();
diff --git a/xfa/src/fdp/src/css/fde_csssyntax.cpp b/xfa/src/fdp/src/css/fde_csssyntax.cpp
index b546d10..15b8dbb 100644
--- a/xfa/src/fdp/src/css/fde_csssyntax.cpp
+++ b/xfa/src/fdp/src/css/fde_csssyntax.cpp
@@ -444,12 +444,10 @@
if (!ExpandBuf(iMaxChars)) {
return 0;
}
- pTxtStream->Lock();
if (pTxtStream->GetPosition() != iStreamOffset) {
pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
}
m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS);
- pTxtStream->Unlock();
return m_iDatLen;
}
FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
diff --git a/xfa/src/fdp/src/fde/fde_render.cpp b/xfa/src/fdp/src/fde/fde_render.cpp
index 30e208c..a3f00ac 100644
--- a/xfa/src/fdp/src/fde/fde_render.cpp
+++ b/xfa/src/fdp/src/fde/fde_render.cpp
@@ -58,8 +58,7 @@
return new CFDE_RenderContext;
}
CFDE_RenderContext::CFDE_RenderContext()
- : CFX_ThreadLock(),
- m_eStatus(FDE_RENDERSTATUS_Reset),
+ : m_eStatus(FDE_RENDERSTATUS_Reset),
m_pRenderDevice(NULL),
m_pSolidBrush(NULL),
m_Transform(),
@@ -83,7 +82,7 @@
if (pCanvasSet == NULL) {
return FALSE;
}
- Lock();
+
m_eStatus = FDE_RENDERSTATUS_Paused;
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
@@ -91,10 +90,7 @@
m_pIterator = IFDE_VisualSetIterator::Create();
FXSYS_assert(m_pIterator != NULL);
}
- FX_BOOL bAttach =
- m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
- Unlock();
- return bAttach;
+ return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
if (m_pRenderDevice == NULL) {
@@ -103,7 +99,6 @@
if (m_pIterator == NULL) {
return FDE_RENDERSTATUS_Failed;
}
- Lock();
FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused;
CFX_Matrix rm;
rm.SetReverse(m_Transform);
@@ -152,11 +147,9 @@
break;
}
}
- Unlock();
return m_eStatus = eStatus;
}
void CFDE_RenderContext::StopRender() {
- Lock();
m_eStatus = FDE_RENDERSTATUS_Reset;
m_pRenderDevice = nullptr;
m_Transform.SetIdentity();
@@ -171,7 +164,6 @@
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
m_iCharPosCount = 0;
- Unlock();
}
void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
FDE_HVISUALOBJ hText) {
diff --git a/xfa/src/fdp/src/fde/fde_render.h b/xfa/src/fdp/src/fde/fde_render.h
index 50f76f3..4d9ae42 100644
--- a/xfa/src/fdp/src/fde/fde_render.h
+++ b/xfa/src/fdp/src/fde/fde_render.h
@@ -7,9 +7,7 @@
#ifndef XFA_SRC_FDP_SRC_FDE_FDE_RENDER_H_
#define XFA_SRC_FDP_SRC_FDE_FDE_RENDER_H_
-class CFDE_RenderContext;
class CFDE_RenderContext : public IFDE_RenderContext,
- public CFX_ThreadLock,
public CFX_Target {
public:
CFDE_RenderContext();
diff --git a/xfa/src/fdp/src/xml/fde_xml_imp.cpp b/xfa/src/fdp/src/xml/fde_xml_imp.cpp
index e5250fd..626e238 100644
--- a/xfa/src/fdp/src/xml/fde_xml_imp.cpp
+++ b/xfa/src/fdp/src/xml/fde_xml_imp.cpp
@@ -1515,14 +1515,12 @@
}
m_iParsedChars += (m_pEnd - m_pBuffer);
m_iParsedBytes = m_iCurrentPos;
- m_pStream->Lock();
if (m_pStream->GetPosition() != m_iCurrentPos) {
m_pStream->Seek(FX_STREAMSEEK_Begin, m_iCurrentPos);
}
m_iBufferChars =
m_pStream->ReadString(m_pBuffer, m_iXMLPlaneSize, m_bEOS);
iPos = m_pStream->GetPosition();
- m_pStream->Unlock();
if (m_iBufferChars < 1) {
m_iCurrentPos = iStreamLength;
m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS;
diff --git a/xfa/src/fgas/include/fx_stm.h b/xfa/src/fgas/include/fx_stm.h
index 0f0385b..cfd863d 100644
--- a/xfa/src/fgas/include/fx_stm.h
+++ b/xfa/src/fgas/include/fx_stm.h
@@ -64,8 +64,6 @@
virtual int32_t GetBOM(uint8_t bom[4]) const = 0;
virtual FX_WORD GetCodePage() const = 0;
virtual FX_WORD SetCodePage(FX_WORD wCodePage) = 0;
- virtual void Lock() = 0;
- virtual void Unlock() = 0;
virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess,
int32_t iOffset,
int32_t iLength) = 0;
diff --git a/xfa/src/fgas/include/fx_utl.h b/xfa/src/fgas/include/fx_utl.h
index c8d943e..f6c7c09 100644
--- a/xfa/src/fgas/include/fx_utl.h
+++ b/xfa/src/fgas/include/fx_utl.h
@@ -10,7 +10,6 @@
#include "xfa/src/fgas/include/fx_mem.h"
#include "core/include/fxcrt/fx_coordinates.h" // For CFX_Rect.
-class CFX_ThreadLock;
class CFX_BaseArray;
template <class baseType>
class CFX_BaseArrayTemplate;
@@ -36,13 +35,6 @@
class CFX_CPLTree;
class FX_BASEARRAYDATA;
-class CFX_ThreadLock {
- public:
- CFX_ThreadLock();
- virtual ~CFX_ThreadLock();
- void Lock();
- void Unlock();
-};
class CFX_BaseArray : public CFX_Target {
protected:
CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize);
diff --git a/xfa/src/fgas/src/crt/fx_stream.cpp b/xfa/src/fgas/src/crt/fx_stream.cpp
index 93cdb5e..79a0e4c 100644
--- a/xfa/src/fgas/src/crt/fx_stream.cpp
+++ b/xfa/src/fgas/src/crt/fx_stream.cpp
@@ -72,7 +72,7 @@
}
return pSR;
}
-CFX_StreamImp::CFX_StreamImp() : CFX_ThreadLock(), m_dwAccess(0) {}
+CFX_StreamImp::CFX_StreamImp() : m_dwAccess(0) {}
CFX_FileStreamImp::CFX_FileStreamImp()
: CFX_StreamImp(), m_hFile(NULL), m_iLength(0) {}
CFX_FileStreamImp::~CFX_FileStreamImp() {
@@ -771,9 +771,7 @@
if (m_wCodePage == FX_CODEPAGE_UTF16LE ||
m_wCodePage == FX_CODEPAGE_UTF16BE) {
int32_t iBytes = pByteSize == NULL ? iMaxLength * 2 : *pByteSize;
- m_pStreamImp->Lock();
iLen = m_pStreamImp->ReadData((uint8_t*)pStr, iBytes);
- m_pStreamImp->Unlock();
iMaxLength = iLen / 2;
if (sizeof(FX_WCHAR) > 2) {
FX_UTF16ToWChar(pStr, iMaxLength);
@@ -799,13 +797,11 @@
m_pBuf = FX_Realloc(uint8_t, m_pBuf, iBytes);
m_iBufSize = iBytes;
}
- m_pStreamImp->Lock();
iLen = m_pStreamImp->ReadData(m_pBuf, iBytes);
int32_t iSrc = iLen;
int32_t iDecode = FX_DecodeString(m_wCodePage, (const FX_CHAR*)m_pBuf,
&iSrc, pStr, &iMaxLength, TRUE);
m_pStreamImp->Seek(FX_STREAMSEEK_Current, iSrc - iLen);
- m_pStreamImp->Unlock();
if (iDecode < 1) {
return -1;
}
@@ -828,10 +824,8 @@
encoder.Input(*pStr++);
}
CFX_ByteStringC bsResult = encoder.GetResult();
- m_pStreamImp->Lock();
m_pStreamImp->WriteData((const uint8_t*)bsResult.GetCStr(),
bsResult.GetLength());
- m_pStreamImp->Unlock();
}
return iLength;
}
@@ -1030,13 +1024,11 @@
if (iLen <= 0) {
return 0;
}
- m_pStreamImp->Lock();
if (m_pStreamImp->GetPosition() != m_iPosition) {
m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition);
}
iLen = m_pStreamImp->ReadData(pBuffer, iLen);
m_iPosition = m_pStreamImp->GetPosition();
- m_pStreamImp->Unlock();
return iLen;
}
int32_t CFX_Stream::ReadString(FX_WCHAR* pStr,
@@ -1056,7 +1048,6 @@
if (iLen <= 0) {
return 0;
}
- m_pStreamImp->Lock();
if (m_pStreamImp->GetPosition() != m_iPosition) {
m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition);
}
@@ -1065,7 +1056,6 @@
if (iLen > 0 && m_iPosition >= iEnd) {
bEOS = TRUE;
}
- m_pStreamImp->Unlock();
return iLen;
}
int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) {
@@ -1083,7 +1073,6 @@
return 0;
}
}
- m_pStreamImp->Lock();
int32_t iEnd = m_iStart + m_iLength;
if (m_pStreamImp->GetPosition() != m_iPosition) {
m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition);
@@ -1093,7 +1082,6 @@
if (m_iPosition > iEnd) {
m_iLength = m_iPosition - m_iStart;
}
- m_pStreamImp->Unlock();
return iLen;
}
int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
@@ -1111,7 +1099,6 @@
return 0;
}
}
- m_pStreamImp->Lock();
int32_t iEnd = m_iStart + m_iLength;
if (m_pStreamImp->GetPosition() != m_iPosition) {
m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition);
@@ -1121,7 +1108,6 @@
if (m_iPosition > iEnd) {
m_iLength = m_iPosition - m_iStart;
}
- m_pStreamImp->Unlock();
return iLen;
}
void CFX_Stream::Flush() {
@@ -1219,10 +1205,8 @@
FX_BOOL CFGAS_FileRead::ReadBlock(void* buffer,
FX_FILESIZE offset,
size_t size) {
- m_pStream->Lock();
m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset);
int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size);
- m_pStream->Unlock();
return iLen == (int32_t)size;
}
@@ -1349,9 +1333,7 @@
FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData,
FX_FILESIZE offset,
size_t size) {
- m_pStream->Lock();
m_pStream->Seek(FX_STREAMSEEK_Begin, offset);
int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size);
- m_pStream->Unlock();
return iLen == (int32_t)size;
}
diff --git a/xfa/src/fgas/src/crt/fx_stream.h b/xfa/src/fgas/src/crt/fx_stream.h
index 15646a5..d58b52c 100644
--- a/xfa/src/fgas/src/crt/fx_stream.h
+++ b/xfa/src/fgas/src/crt/fx_stream.h
@@ -18,7 +18,7 @@
class CFX_FileRead;
class CFX_FileWrite;
class CFX_BufferAccImp;
-class CFX_StreamImp : public CFX_ThreadLock {
+class CFX_StreamImp {
public:
virtual void Release() { delete this; }
virtual FX_DWORD GetAccessModes() const { return m_dwAccess; }
@@ -170,7 +170,7 @@
FX_STREAMTYPE_Stream,
FX_STREAMTYPE_BufferRead,
};
-class CFX_Stream : public IFX_Stream, public CFX_ThreadLock {
+class CFX_Stream : public IFX_Stream {
public:
CFX_Stream();
~CFX_Stream();
@@ -201,8 +201,6 @@
virtual int32_t GetBOM(uint8_t bom[4]) const;
virtual FX_WORD GetCodePage() const;
virtual FX_WORD SetCodePage(FX_WORD wCodePage);
- virtual void Lock() { CFX_ThreadLock::Lock(); }
- virtual void Unlock() { CFX_ThreadLock::Unlock(); }
virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess,
int32_t iOffset,
int32_t iLength);
@@ -217,7 +215,7 @@
int32_t m_iLength;
int32_t m_iRefCount;
};
-class CFX_TextStream : public IFX_Stream, public CFX_ThreadLock {
+class CFX_TextStream : public IFX_Stream {
public:
CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream);
~CFX_TextStream();
@@ -244,9 +242,6 @@
virtual FX_WORD GetCodePage() const;
virtual FX_WORD SetCodePage(FX_WORD wCodePage);
- virtual void Lock() { CFX_ThreadLock::Lock(); }
- virtual void Unlock() { CFX_ThreadLock::Unlock(); }
-
virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess,
int32_t iOffset,
int32_t iLength);
diff --git a/xfa/src/fgas/src/crt/fx_utils.cpp b/xfa/src/fgas/src/crt/fx_utils.cpp
index 2818e07..31fcb9e 100644
--- a/xfa/src/fgas/src/crt/fx_utils.cpp
+++ b/xfa/src/fgas/src/crt/fx_utils.cpp
@@ -10,11 +10,6 @@
#include "xfa/src/fgas/src/fgas_base.h"
#include "xfa/src/fgas/src/crt/fx_utils.h"
-CFX_ThreadLock::CFX_ThreadLock() {
-}
-CFX_ThreadLock::~CFX_ThreadLock() {}
-void CFX_ThreadLock::Lock() {}
-void CFX_ThreadLock::Unlock() {}
class FX_BASEARRAYDATA : public CFX_Target {
public:
FX_BASEARRAYDATA(int32_t growsize, int32_t blocksize)
diff --git a/xfa/src/fgas/src/font/fx_gdifont.h b/xfa/src/fgas/src/font/fx_gdifont.h
index b267e97..b501958 100644
--- a/xfa/src/fgas/src/font/fx_gdifont.h
+++ b/xfa/src/fgas/src/font/fx_gdifont.h
@@ -27,7 +27,7 @@
protected:
CFX_MapPtrToPtr m_GlyphMap;
};
-class CFX_GdiFont : public IFX_Font, public CFX_ThreadLock {
+class CFX_GdiFont : public IFX_Font {
public:
CFX_GdiFont(IFX_FontMgr* pFontMgr);
~CFX_GdiFont();
diff --git a/xfa/src/fgas/src/font/fx_gefont.cpp b/xfa/src/fgas/src/font/fx_gefont.cpp
index cc8421c..079814f 100644
--- a/xfa/src/fgas/src/font/fx_gefont.cpp
+++ b/xfa/src/fgas/src/font/fx_gefont.cpp
@@ -87,7 +87,7 @@
return pFont;
}
CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr)
- : CFX_ThreadLock(),
+ :
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
m_bUseLogFontStyle(FALSE),
m_dwLogFontStyle(0),
@@ -109,7 +109,7 @@
}
CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles)
- : CFX_ThreadLock(),
+ :
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
m_bUseLogFontStyle(FALSE),
m_dwLogFontStyle(0),
@@ -192,7 +192,6 @@
if (m_pFont) {
return FALSE;
}
- Lock();
CFX_ByteString csFontFamily;
if (pszFontFamily != NULL) {
csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
@@ -239,28 +238,24 @@
if (bRet) {
bRet = InitFont();
}
- Unlock();
return bRet;
}
FX_BOOL CFX_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) {
if (m_pFont) {
return FALSE;
}
- Lock();
m_pFont = new CFX_Font;
FX_BOOL bRet = m_pFont->LoadEmbedded(pBuffer, length);
if (bRet) {
bRet = InitFont();
}
m_wCharSet = 0xFFFF;
- Unlock();
return bRet;
}
FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
if (m_pFont || m_pStream || m_pFileRead) {
return FALSE;
}
- Lock();
m_pStream = IFX_Stream::CreateStream(
pszFileName, FX_STREAMACCESS_Binary | FX_STREAMACCESS_Read);
m_pFileRead = FX_CreateFileRead(m_pStream);
@@ -276,14 +271,12 @@
}
}
m_wCharSet = 0xFFFF;
- Unlock();
return bRet;
}
FX_BOOL CFX_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) {
if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
return FALSE;
}
- Lock();
if (bSaveStream) {
m_pStream = pFontStream;
}
@@ -297,14 +290,12 @@
m_pFileRead = nullptr;
}
m_wCharSet = 0xFFFF;
- Unlock();
return bRet;
}
FX_BOOL CFX_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) {
if (m_pFont || !pExtFont) {
return FALSE;
}
- Lock();
m_pFont = pExtFont;
FX_BOOL bRet = !!m_pFont;
if (bRet) {
@@ -314,7 +305,6 @@
m_bExtFont = TRUE;
}
m_wCharSet = 0xFFFF;
- Unlock();
return bRet;
}
FX_BOOL CFX_GEFont::InitFont() {
@@ -419,9 +409,7 @@
iWidth = -1;
}
}
- Lock();
m_pCharWidthMap->SetAtGrow(wUnicode, (int16_t)iWidth);
- Unlock();
} else if (iWidth == 65535) {
iWidth = -1;
}
@@ -446,13 +434,11 @@
if (pFont == (IFX_Font*)this) {
FX_RECT rtBBox;
if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
- Lock();
CFX_Rect rt;
rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
int32_t index = m_pRectArray->Add(rt);
pRect = m_pRectArray->GetPtrAt(index);
m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect);
- Unlock();
}
} else if (((CFX_GEFont*)pFont)
->GetCharBBox(wUnicode, bbox, FALSE, bCharCode)) {
@@ -563,7 +549,6 @@
return m_pFont->GetDescent();
}
void CFX_GEFont::Reset() {
- Lock();
int32_t iCount = m_SubstFonts.GetSize();
for (int32_t i = 0; i < iCount; i++) {
IFX_Font* pFont = (IFX_Font*)m_SubstFonts[i];
@@ -578,7 +563,6 @@
if (m_pRectArray != NULL) {
m_pRectArray->RemoveAll();
}
- Unlock();
}
IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24;
diff --git a/xfa/src/fgas/src/font/fx_gefont.h b/xfa/src/fgas/src/font/fx_gefont.h
index cddc984..88688f0 100644
--- a/xfa/src/fgas/src/font/fx_gefont.h
+++ b/xfa/src/fgas/src/font/fx_gefont.h
@@ -12,7 +12,7 @@
#ifndef FXFONT_SUBST_ITALIC
#define FXFONT_SUBST_ITALIC 0x02
#endif
-class CFX_GEFont : public IFX_Font, public CFX_ThreadLock {
+class CFX_GEFont : public IFX_Font {
public:
CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles);
CFX_GEFont(IFX_FontMgr* pFontMgr);