bool ScaledFontDWrite::DefaultToArialFont(IDWriteFontCollection* aSystemFonts) { // If we can't find the same font face as we're given, fallback to arial static const WCHAR fontFamilyName[] = L"Arial"; UINT32 fontIndex; BOOL exists; HRESULT hr = aSystemFonts->FindFamilyName(fontFamilyName, &fontIndex, &exists); if (FAILED(hr)) { gfxCriticalNote << "Failed to get backup arial font font from system fonts. Code: " << hexa(hr); return false; } hr = aSystemFonts->GetFontFamily(fontIndex, getter_AddRefs(mFontFamily)); if (FAILED(hr)) { gfxCriticalNote << "Failed to get font family for arial. Code: " << hexa(hr); return false; } hr = mFontFamily->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, getter_AddRefs(mFont)); if (FAILED(hr)) { gfxCriticalNote << "Failed to get a matching font for arial. Code: " << hexa(hr); return false; } return true; }
// This can happen if we have mixed backends which create DWrite // fonts in a mixed environment. e.g. a cairo content backend // but Skia canvas backend. bool ScaledFontDWrite::GetFontDataFromSystemFonts(IDWriteFactory* aFactory) { MOZ_ASSERT(mFontFace); RefPtr<IDWriteFontCollection> systemFonts; HRESULT hr = aFactory->GetSystemFontCollection(getter_AddRefs(systemFonts)); if (FAILED(hr)) { gfxCriticalNote << "Failed to get system font collection from file data. Code: " << hexa(hr); return false; } hr = systemFonts->GetFontFromFontFace(mFontFace, getter_AddRefs(mFont)); if (FAILED(hr)) { gfxCriticalNote << "Failed to get system font from font face. Code: " << hexa(hr); return DefaultToArialFont(systemFonts); } hr = mFont->GetFontFamily(getter_AddRefs(mFontFamily)); if (FAILED(hr)) { gfxCriticalNote << "Failed to get font family from font face. Code: " << hexa(hr); return DefaultToArialFont(systemFonts); } return true; }
bool SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat, ID2D1RenderTarget *aRT) { HRESULT hr; RefPtr<IDXGISurface> surf; hr = aTexture->QueryInterface((IDXGISurface**)&surf); if (FAILED(hr)) { gfxWarning() << "Failed to QI texture to surface. Code: " << hexa(hr); return false; } D3D10_TEXTURE2D_DESC desc; aTexture->GetDesc(&desc); mSize = IntSize(desc.Width, desc.Height); mFormat = aFormat; D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(aFormat)); hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create SharedBitmap. Code: " << hexa(hr); return false; } aTexture->GetDevice(byRef(mDevice)); DrawTargetD2D::mVRAMUsageSS += GetByteSize(); return true; }
bool DeviceManagerDx::ContentAdapterIsParentAdapter(ID3D11Device* device) { DXGI_ADAPTER_DESC desc; if (!D3D11Checks::GetDxgiDesc(device, &desc)) { gfxCriticalNote << "Could not query device DXGI adapter info"; return false; } const DxgiAdapterDesc& preferred = mDeviceStatus->adapter(); if (desc.VendorId != preferred.VendorId || desc.DeviceId != preferred.DeviceId || desc.SubSysId != preferred.SubSysId || desc.AdapterLuid.HighPart != preferred.AdapterLuid.HighPart || desc.AdapterLuid.LowPart != preferred.AdapterLuid.LowPart) { gfxCriticalNote << "VendorIDMismatch P " << hexa(preferred.VendorId) << " " << hexa(desc.VendorId); return false; } return true; }
void GPUProcessManager::CreateContentVideoDecoderManager(base::ProcessId aOtherProcess, ipc::Endpoint<dom::PVideoDecoderManagerChild>* aOutEndpoint) { if (!EnsureGPUReady() || !MediaPrefs::PDMUseGPUDecoder() || !mDecodeVideoOnGpuProcess) { return; } ipc::Endpoint<dom::PVideoDecoderManagerParent> parentPipe; ipc::Endpoint<dom::PVideoDecoderManagerChild> childPipe; nsresult rv = dom::PVideoDecoderManager::CreateEndpoints( mGPUChild->OtherPid(), aOtherProcess, &parentPipe, &childPipe); if (NS_FAILED(rv)) { gfxCriticalNote << "Could not create content video decoder: " << hexa(int(rv)); return; } mGPUChild->SendNewContentVideoDecoderManager(Move(parentPipe)); *aOutEndpoint = Move(childPipe); return; }
bool GPUProcessManager::CreateContentVRManager(base::ProcessId aOtherProcess, ipc::Endpoint<PVRManagerChild>* aOutEndpoint) { EnsureVRManager(); base::ProcessId gpuPid = mGPUChild ? mGPUChild->OtherPid() : base::GetCurrentProcId(); ipc::Endpoint<PVRManagerParent> parentPipe; ipc::Endpoint<PVRManagerChild> childPipe; nsresult rv = PVRManager::CreateEndpoints( gpuPid, aOtherProcess, &parentPipe, &childPipe); if (NS_FAILED(rv)) { gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv)); return false; } if (EnsureGPUReady()) { mGPUChild->SendNewContentVRManager(Move(parentPipe)); } else { if (!VRManagerParent::CreateForContent(Move(parentPipe))) { return false; } } *aOutEndpoint = Move(childPipe); return true; }
void main() { int no,ch; clrscr(); printf("Enter no.:"); scanf("%d",&no); printf("\nPress 2 for change no. in binary."); printf("\nPress 8 for change no. in octal."); printf("\nPress 16 for change no. in hexadecimal."); printf("Enter choise:"); fflush(stdin); scanf("%d",&ch); switch(ch) { case 2: bin(no,ch); break; case 8: bin(no,ch); break; case 16: hexa(no,ch); break; default: printf("\nWrong choise."); } getch(); }
already_AddRefed<DataSourceSurface> SourceSurfaceD2DTarget::GetDataSurface() { RefPtr<DataSourceSurfaceD2DTarget> dataSurf = new DataSourceSurfaceD2DTarget(mFormat); D3D10_TEXTURE2D_DESC desc; mTexture->GetDesc(&desc); desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ; desc.Usage = D3D10_USAGE_STAGING; desc.BindFlags = 0; desc.MiscFlags = 0; if (!Factory::GetDirect3D10Device()) { gfxCriticalError() << "Invalid D3D10 device in D2D target surface"; return nullptr; } HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(dataSurf->mTexture)); if (FAILED(hr)) { gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hexa(hr); return nullptr; } Factory::GetDirect3D10Device()->CopyResource(dataSurf->mTexture, mTexture); return dataSurf.forget(); }
/* static */ void D3D11Checks::WarnOnAdapterMismatch(ID3D11Device *device) { DXGI_ADAPTER_DESC desc; PodZero(&desc); GetDxgiDesc(device, &desc); nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo(); nsString vendorID; gfxInfo->GetAdapterVendorID(vendorID); nsresult ec; int32_t vendor = vendorID.ToInteger(&ec, 16); if (vendor != desc.VendorId) { gfxCriticalNote << "VendorIDMismatch V " << hexa(vendor) << " " << hexa(desc.VendorId); } }
TemporaryRef<DataSourceSurface> SourceSurfaceD2D1::GetDataSurface() { HRESULT hr; EnsureRealizedBitmap(); RefPtr<ID2D1Bitmap1> softwareBitmap; D2D1_BITMAP_PROPERTIES1 props; props.dpiX = 96; props.dpiY = 96; props.pixelFormat = D2DPixelFormat(mFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ; hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(softwareBitmap)); if (FAILED(hr)) { gfxCriticalError() << "Failed to create software bitmap: " << mSize << " Code: " << hexa(hr); return nullptr; } D2D1_POINT_2U point = D2D1::Point2U(0, 0); D2D1_RECT_U rect = D2D1::RectU(0, 0, mSize.width, mSize.height); hr = softwareBitmap->CopyFromBitmap(&point, mRealizedBitmap, &rect); if (FAILED(hr)) { gfxWarning() << "Failed to readback into software bitmap. Code: " << hexa(hr); return nullptr; } return MakeAndAddRef<DataSourceSurfaceD2D1>(softwareBitmap, mFormat); }
void ScaledFontDWrite::CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink) { std::vector<UINT16> indices; std::vector<FLOAT> advances; std::vector<DWRITE_GLYPH_OFFSET> offsets; indices.resize(aBuffer.mNumGlyphs); advances.resize(aBuffer.mNumGlyphs); offsets.resize(aBuffer.mNumGlyphs); memset(&advances.front(), 0, sizeof(FLOAT) * aBuffer.mNumGlyphs); for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) { indices[i] = aBuffer.mGlyphs[i].mIndex; offsets[i].advanceOffset = aBuffer.mGlyphs[i].mPosition.x; offsets[i].ascenderOffset = -aBuffer.mGlyphs[i].mPosition.y; } HRESULT hr = mFontFace->GetGlyphRunOutline(mSize, &indices.front(), &advances.front(), &offsets.front(), aBuffer.mNumGlyphs, FALSE, FALSE, aSink); if (FAILED(hr)) { gfxCriticalNote << "Failed to copy glyphs to geometry sink. Code: " << hexa(hr); } }
already_AddRefed<PathBuilder> PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const { RefPtr<ID2D1PathGeometry> path; HRESULT hr = DrawTargetD2D1::factory()->CreatePathGeometry(getter_AddRefs(path)); if (FAILED(hr)) { gfxWarning() << "Failed to create PathGeometry. Code: " << hexa(hr); return nullptr; } RefPtr<ID2D1GeometrySink> sink; hr = path->Open(getter_AddRefs(sink)); if (FAILED(hr)) { gfxWarning() << "Failed to open Geometry for writing. Code: " << hexa(hr); return nullptr; } if (aFillRule == FillRule::FILL_WINDING) { sink->SetFillMode(D2D1_FILL_MODE_WINDING); } if (mEndedActive) { OpeningGeometrySink wrapSink(sink); hr = mGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, D2DMatrix(aTransform), &wrapSink); } else { hr = mGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, D2DMatrix(aTransform), sink); } if (FAILED(hr)) { gfxWarning() << "Failed to simplify PathGeometry to tranformed copy. Code: " << hexa(hr) << " Active: " << mEndedActive; return nullptr; } RefPtr<PathBuilderD2D> pathBuilder = new PathBuilderD2D(sink, path, aFillRule, mBackendType); pathBuilder->mCurrentPoint = aTransform.TransformPoint(mEndPoint); if (mEndedActive) { pathBuilder->mFigureActive = true; } return pathBuilder.forget(); }
FeatureStatus DeviceManagerDx::CreateContentDevice() { RefPtr<IDXGIAdapter1> adapter; if (!mDeviceStatus->isWARP()) { adapter = GetDXGIAdapter(); if (!adapter) { gfxCriticalNote << "Could not get a DXGI adapter"; return FeatureStatus::Unavailable; } } HRESULT hr; RefPtr<ID3D11Device> device; UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; D3D_DRIVER_TYPE type = mDeviceStatus->isWARP() ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_UNKNOWN; if (!CreateDevice(adapter, type, flags, hr, device)) { gfxCriticalNote << "Recovered from crash while creating a D3D11 content device"; gfxWindowsPlatform::RecordContentDeviceFailure(TelemetryDeviceCode::Content); return FeatureStatus::CrashedInHandler; } if (FAILED(hr) || !device) { gfxCriticalNote << "Failed to create a D3D11 content device: " << hexa(hr); gfxWindowsPlatform::RecordContentDeviceFailure(TelemetryDeviceCode::Content); return FeatureStatus::Failed; } // InitializeD2D() will abort early if the compositor device did not support // texture sharing. If we're in the content process, we can't rely on the // parent device alone: some systems have dual GPUs that are capable of // binding the parent and child processes to different GPUs. As a safety net, // we re-check texture sharing against the newly created D3D11 content device. // If it fails, we won't use Direct2D. if (XRE_IsContentProcess()) { if (!D3D11Checks::DoesTextureSharingWork(device)) { return FeatureStatus::Failed; } DebugOnly<bool> ok = ContentAdapterIsParentAdapter(device); MOZ_ASSERT(ok); } { MutexAutoLock lock(mDeviceLock); mContentDevice = device; } mContentDevice->SetExceptionMode(0); RefPtr<ID3D10Multithread> multi; hr = mContentDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi)); if (SUCCEEDED(hr) && multi) { multi->SetMultithreadProtected(TRUE); } return FeatureStatus::Available; }
void hexa(int no,int ch) { int r; if(no!=0) { r=no%ch; no=no/ch; if(r>=0 && r<=9) { hexa(no,ch); printf("%d",r); } else if(r>=10) { hexa(no,ch); printf("%c",r+55); } } }
/* 將十六進位碼還原成字元 */ char* convert(char* s) { int x, y, len; char* data; len = strlen(s); data = (char*)malloc(sizeof(char) * (len + 1)); y = 0; for (x = 0; x < len; x++) { if (s[x] != '%') { data[y] = s[x]; // 一般字元,不作處理 y++; } else { /* 將%xx中的xx先各別轉換為十六進位值,相加後,再轉為字元 */ data[y] = (char)(16 * hexa(s[x + 1]) + hexa(s[x + 2])); y++; x = x + 2; } } data[y] = '\0'; return data; }
bool SourceSurfaceD2D::InitFromData(unsigned char *aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat, ID2D1RenderTarget *aRT) { HRESULT hr; mFormat = aFormat; mSize = aSize; if ((uint32_t)aSize.width > aRT->GetMaximumBitmapSize() || (uint32_t)aSize.height > aRT->GetMaximumBitmapSize()) { gfxDebug() << "Bitmap does not fit in texture."; return false; } D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(aFormat)); hr = aRT->CreateBitmap(D2DIntSize(aSize), props, byRef(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create D2D Bitmap for data. Code: " << hexa(hr); return false; } hr = mBitmap->CopyFromMemory(nullptr, aData, aStride); if (FAILED(hr)) { gfxWarning() << "Failed to copy data to D2D bitmap. Code: " << hexa(hr); return false; } DrawTargetD2D::mVRAMUsageSS += GetByteSize(); mDevice = Factory::GetDirect3D10Device(); return true; }
void DataSourceSurfaceD2DTarget::EnsureMapped() { // Do not use GetData() after having used Map! MOZ_ASSERT(!mIsMapped); if (!mMapped) { HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mMap); if (FAILED(hr)) { gfxWarning() << "Failed to map texture to memory. Code: " << hexa(hr); return; } mMapped = true; } }
void DeviceManagerDx::CreateWARPCompositorDevice() { ScopedGfxFeatureReporter reporterWARP("D3D11-WARP", gfxPrefs::LayersD3D11ForceWARP()); FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING); HRESULT hr; RefPtr<ID3D11Device> device; // Use D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS // to prevent bug 1092260. IE 11 also uses this flag. UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; if (!CreateDevice(nullptr, D3D_DRIVER_TYPE_WARP, flags, hr, device)) { gfxCriticalError() << "Exception occurred initializing WARP D3D11 device!"; d3d11.SetFailed(FeatureStatus::CrashedInHandler, "Crashed creating a D3D11 WARP device", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_WARP_DEVICE")); } if (FAILED(hr) || !device) { // This should always succeed... in theory. gfxCriticalError() << "Failed to initialize WARP D3D11 device! " << hexa(hr); d3d11.SetFailed(FeatureStatus::Failed, "Failed to create a D3D11 WARP device", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_WARP_DEVICE2")); return; } // Only test for texture sharing on Windows 8 since it puts the device into // an unusable state if used on Windows 7 bool textureSharingWorks = false; if (IsWin8OrLater()) { textureSharingWorks = D3D11Checks::DoesTextureSharingWork(device); } DxgiAdapterDesc nullAdapter; PodZero(&nullAdapter); int featureLevel = device->GetFeatureLevel(); { MutexAutoLock lock(mDeviceLock); mCompositorDevice = device; mDeviceStatus = Some(D3D11DeviceStatus( true, textureSharingWorks, featureLevel, nullAdapter)); } mCompositorDevice->SetExceptionMode(0); reporterWARP.SetSuccessful(); }
Rect PathD2D::GetBounds(const Matrix &aTransform) const { D2D1_RECT_F d2dBounds; HRESULT hr = mGeometry->GetBounds(D2DMatrix(aTransform), &d2dBounds); Rect bounds = ToRect(d2dBounds); if (FAILED(hr) || !bounds.IsFinite()) { gfxWarning() << "Failed to get stroked bounds for path. Code: " << hexa(hr); return Rect(); } return bounds; }
void PathD2D::StreamToSink(PathSink *aSink) const { HRESULT hr; StreamingGeometrySink sink(aSink); hr = mGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, D2D1::IdentityMatrix(), &sink); if (FAILED(hr)) { gfxWarning() << "Failed to stream D2D path to sink. Code: " << hexa(hr); return; } }
already_AddRefed<Path> PathBuilderD2D::Finish() { if (mFigureActive) { mSink->EndFigure(D2D1_FIGURE_END_OPEN); } HRESULT hr = mSink->Close(); if (FAILED(hr)) { gfxCriticalNote << "Failed to close PathSink. Code: " << hexa(hr); return nullptr; } return MakeAndAddRef<PathD2D>(mGeometry, mFigureActive, mCurrentPoint, mFillRule, mBackendType); }
ID3D10ShaderResourceView* SourceSurfaceD2DTarget::GetSRView() { if (mSRView) { return mSRView; } HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView)); if (FAILED(hr)) { gfxWarning() << "Failed to create ShaderResourceView. Code: " << hexa(hr); } return mSRView; }
void Blind::refresh() { std::chrono::milliseconds time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()); if ((time - m_time) >= m_delay && m_isDisplayed && m_alpha < m_maxAplha) { std::cout << "Time: " << time.count() << " m_time: " << m_time.count() << " Delay:" << m_delay.count() << " m_aplha: " << m_alpha << std::endl; m_alpha += m_step; std::stringstream stream; stream << std::hex << m_alpha; std::string hexa(stream.str()); m_windows->setProperty("BackgroundColours", "tl:" + hexa + "000000 tr:" + hexa + "000000 bl:" + hexa + "000000 br:" + hexa + "000000"); m_time = time; } }
int main(){ int t = 285; int p = 165; int h = 143; t++; int tt = tri(t); int pp = penta(p); int hh = hexa(h); while (1) { if (tt == pp && tt == hh) { break; } while (tt < pp && tt < hh) { t++; tt = tri(t); } while (pp < tt && pp < hh) { p++; pp = penta(p); } while (hh < tt && hh < pp) { h++; hh = hexa(h); } } printf("tt: %d\n", tt); return 0; }
/* 由于在提交的信息中,任何特殊字符 用%接相应的十六进制ASCII码代替(%HH格式); 需要进行还原 */ void convert(char *src) { int x,y,len; char *tmp; len=strlen(src); tmp=(char *)malloc(sizeof(char)*(len+1)); y=0; for(x=0;x<len;x++) { if(src[x] != '%') { tmp[y]=src[x]; y++; } else { tmp[y]=(char)(16*hexa(src[x+1])+hexa(src[x+2])); y++; x=x+2; } } tmp[y]='\0'; memset(src, 0, len); strcpy(src, tmp); free(tmp); }
bool DeviceManagerDx::CreateCompositorDeviceHelper( FeatureState& aD3d11, IDXGIAdapter1* aAdapter, bool aAttemptVideoSupport, RefPtr<ID3D11Device>& aOutDevice) { // Check if a failure was injected for testing. if (gfxPrefs::DeviceFailForTesting()) { aD3d11.SetFailed(FeatureStatus::Failed, "Direct3D11 device failure simulated by preference", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_SIM")); return false; } // Use D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS // to prevent bug 1092260. IE 11 also uses this flag. UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS; if (aAttemptVideoSupport) { flags |= D3D11_CREATE_DEVICE_VIDEO_SUPPORT; } HRESULT hr; RefPtr<ID3D11Device> device; if (!CreateDevice(aAdapter, D3D_DRIVER_TYPE_UNKNOWN, flags, hr, device)) { if (!aAttemptVideoSupport) { gfxCriticalError() << "Crash during D3D11 device creation"; aD3d11.SetFailed(FeatureStatus::CrashedInHandler, "Crashed trying to acquire a D3D11 device", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_DEVICE1")); } return false; } if (FAILED(hr) || !device) { if (!aAttemptVideoSupport) { gfxCriticalError() << "D3D11 device creation failed: " << hexa(hr); aD3d11.SetFailed(FeatureStatus::Failed, "Failed to acquire a D3D11 device", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_DEVICE2")); } return false; } if (!D3D11Checks::DoesDeviceWork()) { if (!aAttemptVideoSupport) { aD3d11.SetFailed(FeatureStatus::Broken, "Direct3D11 device was determined to be broken", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_BROKEN")); } return false; } aOutDevice = device; return true; }
void DeviceManagerDx::InitializeDirectDraw() { MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread()); if (mDirectDraw) { // Already initialized. return; } FeatureState& ddraw = gfxConfig::GetFeature(Feature::DIRECT_DRAW); if (!ddraw.IsEnabled()) { return; } // Check if DirectDraw is available on this system. mDirectDrawDLL.own(LoadLibrarySystem32(L"ddraw.dll")); if (!mDirectDrawDLL) { ddraw.SetFailed(FeatureStatus::Unavailable, "DirectDraw not available on this computer", NS_LITERAL_CSTRING("FEATURE_FAILURE_DDRAW_LIB")); return; } sDirectDrawCreateExFn = (decltype(DirectDrawCreateEx)*)GetProcAddress(mDirectDrawDLL, "DirectDrawCreateEx"); if (!sDirectDrawCreateExFn) { ddraw.SetFailed(FeatureStatus::Unavailable, "DirectDraw not available on this computer", NS_LITERAL_CSTRING("FEATURE_FAILURE_DDRAW_LIB")); return; } HRESULT hr; MOZ_SEH_TRY { hr = sDirectDrawCreateExFn(nullptr, getter_AddRefs(mDirectDraw), IID_IDirectDraw7, nullptr); } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ddraw.SetFailed(FeatureStatus::Failed, "Failed to create DirectDraw", NS_LITERAL_CSTRING("FEATURE_FAILURE_DDRAW_LIB")); gfxCriticalNote << "DoesCreatingDirectDrawFailed"; return; } if (FAILED(hr)) { ddraw.SetFailed(FeatureStatus::Failed, "Failed to create DirectDraw", NS_LITERAL_CSTRING("FEATURE_FAILURE_DDRAW_LIB")); gfxCriticalNote << "DoesCreatingDirectDrawFailed " << hexa(hr); return; } }
Rect PathD2D::GetStrokedBounds(const StrokeOptions &aStrokeOptions, const Matrix &aTransform) const { D2D1_RECT_F d2dBounds; RefPtr<ID2D1StrokeStyle> strokeStyle = CreateStrokeStyleForOptions(aStrokeOptions); HRESULT hr = mGeometry->GetWidenedBounds(aStrokeOptions.mLineWidth, strokeStyle, D2DMatrix(aTransform), &d2dBounds); Rect bounds = ToRect(d2dBounds); if (FAILED(hr) || !bounds.IsFinite()) { gfxWarning() << "Failed to get stroked bounds for path. Code: " << hexa(hr); return Rect(); } return bounds; }
void DataSourceSurfaceD2D::EnsureMappedTexture() { // Do not use GetData() after having used Map! MOZ_ASSERT(!mIsMapped); if (mMapped || !mTexture) { return; } HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mData); if (FAILED(hr)) { gfxWarning() << "Failed to map texture. Code: " << hexa(hr); mTexture = nullptr; } else { mMapped = true; } }
ID3D10ShaderResourceView* SourceSurfaceD2DTarget::GetSRView() { if (mSRView) { return mSRView; } if (!Factory::GetDirect3D10Device()) { gfxCriticalError() << "Invalid D3D10 device in D2D target surface"; return nullptr; } HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView)); if (FAILED(hr)) { gfxWarning() << "Failed to create ShaderResourceView. Code: " << hexa(hr); } return mSRView; }