Bug 811850: Fix gfx 2d recording to be 64-bit neutral. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Wed, 14 Nov 2012 20:55:02 +0000
changeset 113280 4789d67c601738d05935747991ae157b2385d03e
parent 113279 a858e1fa0bcc5157ac7441db2e7b1b0fa96f354c
child 113281 d6f4b5d48c73c681a860f9bc4631c46ea1ace7c1
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel
bugs811850
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 811850: Fix gfx 2d recording to be 64-bit neutral. r=jrmuizel
gfx/2d/RecordedEvent.cpp
gfx/2d/RecordedEvent.h
gfx/2d/gfx2d.vcxproj
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -176,29 +176,49 @@ RecordedEvent::StorePattern(PatternStora
       return;
     }
   }
 }
 
 void
 RecordedEvent::RecordStrokeOptions(std::ostream &aStream, const StrokeOptions &aStrokeOptions) const
 {
-  WriteElement(aStream, aStrokeOptions);
+  JoinStyle joinStyle = aStrokeOptions.mLineJoin;
+  CapStyle capStyle = aStrokeOptions.mLineCap;
+
+  WriteElement(aStream, uint64_t(aStrokeOptions.mDashLength));
+  WriteElement(aStream, aStrokeOptions.mDashOffset);
+  WriteElement(aStream, aStrokeOptions.mLineWidth);
+  WriteElement(aStream, aStrokeOptions.mMiterLimit);
+  WriteElement(aStream, joinStyle);
+  WriteElement(aStream, capStyle);
 
   if (!aStrokeOptions.mDashPattern) {
     return;
   }
 
   aStream.write((char*)aStrokeOptions.mDashPattern, sizeof(Float) * aStrokeOptions.mDashLength);
 }
 
 void
 RecordedEvent::ReadStrokeOptions(std::istream &aStream, StrokeOptions &aStrokeOptions)
 {
-  ReadElement(aStream, aStrokeOptions);
+  uint64_t dashLength;
+  JoinStyle joinStyle;
+  CapStyle capStyle;
+
+  ReadElement(aStream, dashLength);
+  ReadElement(aStream, aStrokeOptions.mDashOffset);
+  ReadElement(aStream, aStrokeOptions.mLineWidth);
+  ReadElement(aStream, aStrokeOptions.mMiterLimit);
+  ReadElement(aStream, joinStyle);
+  ReadElement(aStream, capStyle);
+  aStrokeOptions.mDashLength = dashLength;
+  aStrokeOptions.mLineJoin = joinStyle;
+  aStrokeOptions.mLineCap = capStyle;
 
   if (!aStrokeOptions.mDashLength) {
     return;
   }
 
   mDashPatternStorage.resize(aStrokeOptions.mDashLength);
   aStrokeOptions.mDashPattern = &mDashPatternStorage.front();
   aStream.read((char*)aStrokeOptions.mDashPattern, sizeof(Float) * aStrokeOptions.mDashLength);
@@ -882,17 +902,17 @@ RecordedPathCreation::PlayEvent(Translat
   RefPtr<Path> path = builder->Finish();
   aTranslator->AddPath(mRefPtr, path);
 }
 
 void
 RecordedPathCreation::RecordToStream(ostream &aStream) const
 {
   WriteElement(aStream, mRefPtr);
-  WriteElement(aStream, mPathOps.size());
+  WriteElement(aStream, uint64_t(mPathOps.size()));
   WriteElement(aStream, mFillRule);
   typedef std::vector<PathOp> pathOpVec;
   for (pathOpVec::const_iterator iter = mPathOps.begin(); iter != mPathOps.end(); iter++) {
     WriteElement(aStream, iter->mType);
     if (sPointCount[iter->mType] >= 1) {
       WriteElement(aStream, iter->mP1);
     }
     if (sPointCount[iter->mType] >= 2) {
@@ -903,23 +923,23 @@ RecordedPathCreation::RecordToStream(ost
     }
   }
 
 }
 
 RecordedPathCreation::RecordedPathCreation(istream &aStream)
   : RecordedEvent(PATHCREATION)
 {
-  size_t size;
+  uint64_t size;
 
   ReadElement(aStream, mRefPtr);
   ReadElement(aStream, size);
   ReadElement(aStream, mFillRule);
 
-  for (size_t i = 0; i < size; i++) {
+  for (uint64_t i = 0; i < size; i++) {
     PathOp newPathOp;
     ReadElement(aStream, newPathOp.mType);
     if (sPointCount[newPathOp.mType] >= 1) {
       ReadElement(aStream, newPathOp.mP1);
     }
     if (sPointCount[newPathOp.mType] >= 2) {
       ReadElement(aStream, newPathOp.mP2);
     }
--- a/gfx/2d/RecordedEvent.h
+++ b/gfx/2d/RecordedEvent.h
@@ -15,17 +15,17 @@
 
 namespace mozilla {
 namespace gfx {
 
 // A change in major revision means a change in event binary format, causing
 // loss of backwards compatibility. Old streams will not work in a player
 // using a newer major revision. And new streams will not work in a player
 // using an older major revision.
-const uint16_t kMajorRevision = 1;
+const uint16_t kMajorRevision = 2;
 // A change in minor revision means additions of new events. New streams will
 // not play in older players.
 const uint16_t kMinorRevision = 0;
 
 struct ReferencePtr
 {
   ReferencePtr()
     : mLongPtr(0)
@@ -207,17 +207,17 @@ protected:
   {
   }
 
   RecordedDrawingEvent(EventType aType, std::istream &aStream);
   virtual void RecordToStream(std::ostream &aStream) const;
 
   virtual ReferencePtr GetObject() const;
 
-  DrawTarget *mDT;
+  ReferencePtr mDT;
 };
 
 class RecordedDrawTargetCreation : public RecordedEvent {
 public:
   RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, const IntSize &aSize, SurfaceFormat aFormat)
     : RecordedEvent(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), mSize(aSize), mFormat(aFormat)
   {}
 
@@ -796,17 +796,17 @@ public:
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "Snapshot"; }
   virtual ReferencePtr GetObject() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
-  DrawTarget *mDT;
+  ReferencePtr mDT;
 
   RecordedSnapshot(std::istream &aStream);
 };
 
 class RecordedScaledFontCreation : public RecordedEvent {
 public:
   static void FontDataProc(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize, void* aBaton)
   {
--- a/gfx/2d/gfx2d.vcxproj
+++ b/gfx/2d/gfx2d.vcxproj
@@ -37,17 +37,17 @@
     <ExecutablePath>$(DXSDK_DIR)\Utilities\bin\x86;$(ExecutablePath)</ExecutablePath>
     <IncludePath>$(ProjectDir);$(IncludePath)</IncludePath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>true</LinkIncremental>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>USE_SSE2;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);GFX_LOG_DEBUG;GFX_LOG_WARNING;MFBT_STAND_ALONE;XP_WIN</PreprocessorDefinitions>
+      <PreprocessorDefinitions>INITGUID;USE_SSE2;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);GFX_LOG_DEBUG;GFX_LOG_WARNING;MFBT_STAND_ALONE;XP_WIN</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <Optimization>Disabled</Optimization>
     </ClCompile>
     <Link>
       <TargetMachine>MachineX86</TargetMachine>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -57,20 +57,21 @@
     </Link>
     <PreBuildEvent>
       <Command>xcopy $(ProjectDir)..\..\mfbt\*.h mozilla\ /Y</Command>
       <Message>Copying MFBT files</Message>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>USE_SSE2;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>INITGUID;USE_SSE2;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <AdditionalIncludeDirectories>./</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <TargetMachine>MachineX86</TargetMachine>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
     </Link>