CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture) { MOZ_ASSERT(aTexture); mTextures[0] = aTexture; RefPtr<ID3D11Device> device; mTextures[0]->GetDevice(byRef(device)); HRESULT hr = device->CreateRenderTargetView(mTextures[0], nullptr, byRef(mRTView)); if (FAILED(hr)) { LOGD3D11("Failed to create RenderTargetView."); } }
void TextureClientD3D11::EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType) { D3D10_TEXTURE2D_DESC desc; if (mTexture) { mTexture->GetDesc(&desc); if (desc.Width == aSize.width || desc.Height == aSize.height) { return; } mTexture = nullptr; mSurface = nullptr; ClearDT(); } mSize = aSize; ID3D10Device *device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1, D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE); newDesc.MiscFlags = D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX; HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, byRef(mTexture)); if (FAILED(hr)) { LOGD3D11("Error creating texture for client!"); return; } RefPtr<IDXGIResource> resource; mTexture->QueryInterface((IDXGIResource**)byRef(resource)); HANDLE sharedHandle; hr = resource->GetSharedHandle(&sharedHandle); if (FAILED(hr)) { LOGD3D11("Error getting shared handle for texture."); } mDescriptor = SurfaceDescriptorD3D10((WindowsHandle)sharedHandle, aType == gfxASurface::CONTENT_COLOR_ALPHA); mContentType = aType; }
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(); }
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(D2D1::PixelFormat(DXGIFormat(aFormat), AlphaMode(aFormat))); hr = aRT->CreateBitmap(D2DIntSize(aSize), aData, aStride, props, byRef(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create D2D Bitmap for data. Code: " << hr; return false; } DrawTargetD2D::mVRAMUsageSS += GetByteSize(); mDevice = Factory::GetDirect3D10Device(); return true; }
HRESULT MFTDecoder::SetDecoderOutputType(ConfigureOutputCallback aCallback, void* aData) { NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER); // Iterate the enumerate the output types, until we find one compatible // with what we need. HRESULT hr; RefPtr<IMFMediaType> outputType; UINT32 typeIndex = 0; while (SUCCEEDED(mDecoder->GetOutputAvailableType(0, typeIndex++, byRef(outputType)))) { BOOL resultMatch; hr = mOutputType->Compare(outputType, MF_ATTRIBUTES_MATCH_OUR_ITEMS, &resultMatch); if (SUCCEEDED(hr) && resultMatch == TRUE) { if (aCallback) { hr = aCallback(outputType, aData); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); } hr = mDecoder->SetOutputType(0, outputType, 0); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); hr = mDecoder->GetOutputStreamInfo(0, &mOutputStreamInfo); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); mMFTProvidesOutputSamples = IsFlagSet(mOutputStreamInfo.dwFlags, MFT_OUTPUT_STREAM_PROVIDES_SAMPLES); return S_OK; } outputType = nullptr; } return E_FAIL; }
void SourceSurfaceD2DTarget::DrawTargetWillChange() { RefPtr<ID3D10Texture2D> oldTexture = mTexture; D3D10_TEXTURE2D_DESC desc; mTexture->GetDesc(&desc); // Our original texture might implement the keyed mutex flag. We shouldn't // need that here. We actually specifically don't want it since we don't lock // our texture for usage! desc.MiscFlags = 0; // Get a copy of the surface data so the content at snapshot time was saved. Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(mTexture)); Factory::GetDirect3D10Device()->CopyResource(mTexture, oldTexture); mBitmap = nullptr; DrawTargetD2D::mVRAMUsageSS += desc.Width * desc.Height * BytesPerPixel(mFormat); mOwnsCopy = true; // We now no longer depend on the source surface content remaining the same. MarkIndependent(); }
bool Func::mustBeRef(int32_t arg) const { if (byRef(arg)) { return arg < m_numParams || !(m_attrs & AttrVariadicByRef) || !info() || !(info()->attribute & ClassInfo::MixedVariableArguments); } return false; }
TemporaryRef<SourceSurface> DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const { if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) { return aSurface; } RefPtr<DataSourceSurface> data = aSurface->GetDataSurface(); DataSourceSurface::MappedSurface map; if (!data->Map(DataSourceSurface::MapType::READ, &map)) { return nullptr; } RefPtr<ID2D1Bitmap1> bitmap; HRESULT hr = mDC->CreateBitmap(D2DIntSize(data->GetSize()), map.mData, map.mStride, D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(data->GetFormat())), byRef(bitmap)); data->Unmap(); if (!bitmap) { return data; } return new SourceSurfaceD2D1(bitmap.get(), mDC, data->GetFormat(), data->GetSize()); }
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: " << hr; return false; } D3D10_TEXTURE2D_DESC desc; aTexture->GetDesc(&desc); mSize = IntSize(desc.Width, desc.Height); mFormat = aFormat; D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(aFormat), AlphaMode(aFormat))); hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create SharedBitmap. Code: " << hr; return false; } DrawTargetD2D::mVRAMUsageSS += GetByteSize(); return true; }
bool TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) { mSize = aSize; ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1, D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE); newDesc.MiscFlags = D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX; HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, byRef(mTexture)); if (FAILED(hr)) { LOGD3D11("Error creating texture for client!"); return false; } // Defer clearing to the next time we lock to avoid an extra (expensive) lock. mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER; mNeedsClearWhite = aFlags & ALLOC_CLEAR_BUFFER_WHITE; return true; }
void SharedSurface_ANGLEShareHandle::ConsumerAcquireImpl() { if (!mConsumerTexture) { RefPtr<ID3D11Texture2D> tex; HRESULT hr = gfxWindowsPlatform::GetPlatform()->GetD3D11Device()->OpenSharedResource(mShareHandle, __uuidof(ID3D11Texture2D), (void**)(ID3D11Texture2D**)byRef(tex)); if (SUCCEEDED(hr)) { mConsumerTexture = tex; RefPtr<IDXGIKeyedMutex> mutex; hr = tex->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); if (SUCCEEDED(hr)) { mConsumerKeyedMutex = mutex; } } } if (mConsumerKeyedMutex) { HRESULT hr = mConsumerKeyedMutex->AcquireSync(0, 10000); if (hr == WAIT_TIMEOUT) { MOZ_CRASH(); } } }
TemporaryRef<GradientStops> DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, ExtendMode aExtendMode) const { D2D1_GRADIENT_STOP *stops = new D2D1_GRADIENT_STOP[aNumStops]; for (uint32_t i = 0; i < aNumStops; i++) { stops[i].position = rawStops[i].offset; stops[i].color = D2DColor(rawStops[i].color); } RefPtr<ID2D1GradientStopCollection> stopCollection; HRESULT hr = mDC->CreateGradientStopCollection(stops, aNumStops, D2D1_GAMMA_2_2, D2DExtend(aExtendMode), byRef(stopCollection)); delete [] stops; if (FAILED(hr)) { gfxWarning() << *this << ": Failed to create GradientStopCollection. Code: " << hr; return nullptr; } return new GradientStopsD2D(stopCollection); }
ID3D11ShaderResourceView* TextureSourceD3D11::GetShaderResourceView() { MOZ_ASSERT(mTexture == GetD3D11Texture(), "You need to override GetShaderResourceView if you're overriding GetD3D11Texture!"); if (!mSRV && mTexture) { RefPtr<ID3D11Device> device; mTexture->GetDevice(byRef(device)); HRESULT hr = device->CreateShaderResourceView(mTexture, nullptr, byRef(mSRV)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(false)) << "[D3D11] TextureSourceD3D11:GetShaderResourceView CreateSRV failure " << gfx::hexa(hr); return nullptr; } } return mSRV; }
STDMETHODIMP WMFByteStream::EndRead(IMFAsyncResult* aResult, ULONG *aBytesRead) { NS_ENSURE_TRUE(aResult, E_POINTER); NS_ENSURE_TRUE(aBytesRead, E_POINTER); ReentrantMonitorAutoEnter mon(mReentrantMonitor); // Extract our state object. RefPtr<IUnknown> unknown; HRESULT hr = aResult->GetObject(byRef(unknown)); if (FAILED(hr) || !unknown) { return E_INVALIDARG; } ReadRequest* requestState = static_cast<ReadRequest*>(unknown.get()); // Report result. *aBytesRead = requestState->mBytesRead; WMF_BS_LOG("[%p] WMFByteStream::EndRead() offset=%lld *aBytesRead=%u mOffset=%lld status=0x%x hr=0x%x eof=%d", this, requestState->mOffset, *aBytesRead, mOffset, aResult->GetStatus(), hr, IsEOS()); return aResult->GetStatus(); }
void SourceSurfaceD2D1::DrawTargetWillChange() { // At this point in time this should always be true here. MOZ_ASSERT(mRealizedBitmap); RefPtr<ID2D1Bitmap1> oldBitmap = mRealizedBitmap; D2D1_BITMAP_PROPERTIES1 props; props.dpiX = 96; props.dpiY = 96; props.pixelFormat = D2DPixelFormat(mFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mRealizedBitmap)); D2D1_POINT_2U point = D2D1::Point2U(0, 0); D2D1_RECT_U rect = D2D1::RectU(0, 0, mSize.width, mSize.height); mRealizedBitmap->CopyFromBitmap(&point, oldBitmap, &rect); mImage = mRealizedBitmap; DrawTargetD2D1::mVRAMUsageSS += mSize.width * mSize.height * BytesPerPixel(mFormat); mDrawTarget = nullptr; // We now no longer depend on the source surface content remaining the same. MarkIndependent(); }
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); }
TemporaryRef<CompositingRenderTarget> CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect, SurfaceInitMode aInit) { MOZ_ASSERT(aRect.width != 0 && aRect.height != 0); if (aRect.width * aRect.height == 0) { return nullptr; } CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aRect.width, aRect.height, 1, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET); RefPtr<ID3D11Texture2D> texture; HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); if (Failed(hr) || !texture) { return nullptr; } RefPtr<CompositingRenderTargetD3D11> rt = new CompositingRenderTargetD3D11(texture, aRect.TopLeft()); rt->SetSize(IntSize(aRect.width, aRect.height)); if (aInit == INIT_MODE_CLEAR) { FLOAT clear[] = { 0, 0, 0, 0 }; mContext->ClearRenderTargetView(rt->mRTView, clear); } return rt; }
CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture, const gfx::IntPoint& aOrigin) : CompositingRenderTarget(aOrigin) { MOZ_ASSERT(aTexture); mTexture = aTexture; RefPtr<ID3D11Device> device; mTexture->GetDevice(byRef(device)); HRESULT hr = device->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView)); if (FAILED(hr)) { LOGD3D11("Failed to create RenderTargetView."); } }
bool ScaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton) { UINT32 fileCount = 0; mFontFace->GetFiles(&fileCount, nullptr); if (fileCount > 1) { MOZ_ASSERT(false); return false; } RefPtr<IDWriteFontFile> file; mFontFace->GetFiles(&fileCount, byRef(file)); const void *referenceKey; UINT32 refKeySize; // XXX - This can currently crash for webfonts, as when we get the reference // key out of the file, that can be an invalid reference key for the loader // we use it with. The fix to this is not obvious but it will probably // have to happen inside thebes. file->GetReferenceKey(&referenceKey, &refKeySize); RefPtr<IDWriteFontFileLoader> loader; file->GetLoader(byRef(loader)); RefPtr<IDWriteFontFileStream> stream; loader->CreateStreamFromKey(referenceKey, refKeySize, byRef(stream)); UINT64 fileSize64; stream->GetFileSize(&fileSize64); if (fileSize64 > UINT32_MAX) { MOZ_ASSERT(false); return false; } uint32_t fileSize = static_cast<uint32_t>(fileSize64); const void *fragmentStart; void *context; stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context); aDataCallback((uint8_t*)fragmentStart, fileSize, mFontFace->GetIndex(), mSize, aBaton); stream->ReleaseFileFragment(context); return true; }
void DeprecatedTextureHostDXGID3D11::ReleaseTexture() { RefPtr<IDXGIKeyedMutex> mutex; mTextures[0]->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); mutex->ReleaseSync(0); }
TemporaryRef<IMFAttributes> MFTDecoder::GetAttributes() { RefPtr<IMFAttributes> attr; HRESULT hr = mDecoder->GetAttributes(byRef(attr)); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); return attr; }
void DeprecatedTextureHostDXGID3D11::LockTexture() { RefPtr<IDXGIKeyedMutex> mutex; mTextures[0]->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); mutex->AcquireSync(0, INFINITE); }
CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D *aTexture) { if (!aTexture) { return; } mTextures[0] = aTexture; RefPtr<ID3D11Device> device; mTextures[0]->GetDevice(byRef(device)); HRESULT hr = device->CreateRenderTargetView(mTextures[0], NULL, byRef(mRTView)); if (FAILED(hr)) { LOGD3D11("Failed to create RenderTargetView."); } }
TextureClient* IMFYCbCrImage::GetD3D9TextureClient(CompositableClient* aClient) { IDirect3DDevice9* device = gfxWindowsPlatform::GetPlatform()->GetD3D9Device(); RefPtr<IDirect3DTexture9> textureY; HANDLE shareHandleY = 0; if (!UploadData(device, textureY, shareHandleY, mData.mYChannel, mData.mYSize, mData.mYStride)) { return nullptr; } RefPtr<IDirect3DTexture9> textureCb; HANDLE shareHandleCb = 0; if (!UploadData(device, textureCb, shareHandleCb, mData.mCbChannel, mData.mCbCrSize, mData.mCbCrStride)) { return nullptr; } RefPtr<IDirect3DTexture9> textureCr; HANDLE shareHandleCr = 0; if (!UploadData(device, textureCr, shareHandleCr, mData.mCrChannel, mData.mCbCrSize, mData.mCbCrStride)) { return nullptr; } RefPtr<IDirect3DQuery9> query; HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, byRef(query)); hr = query->Issue(D3DISSUE_END); int iterations = 0; bool valid = false; while (iterations < 10) { HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH); if (hr == S_FALSE) { Sleep(1); iterations++; continue; } if (hr == S_OK) { valid = true; } break; } if (!valid) { return nullptr; } RefPtr<DXGIYCbCrTextureClient> texClient = new DXGIYCbCrTextureClient(aClient->GetForwarder(), TextureFlags::DEFAULT); texClient->InitWith(textureY, textureCb, textureCr, shareHandleY, shareHandleCb, shareHandleCr, GetSize(), mData.mYSize, mData.mCbCrSize); mTextureClient = texClient; return mTextureClient; }
TemporaryRef<CompositingRenderTarget> CompositorD3D9::CreateRenderTargetFromSource(const gfx::IntRect &aRect, const CompositingRenderTarget *aSource, const gfx::IntPoint &aSourcePoint) { RefPtr<IDirect3DTexture9> texture; HRESULT hr = device()->CreateTexture(aRect.width, aRect.height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, byRef(texture), NULL); if (FAILED(hr)) { ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTargetFromSource: Failed to create texture"), hr); return nullptr; } if (aSource) { nsRefPtr<IDirect3DSurface9> sourceSurface = static_cast<const CompositingRenderTargetD3D9*>(aSource)->GetD3D9Surface(); nsRefPtr<IDirect3DSurface9> destSurface; hr = texture->GetSurfaceLevel(0, getter_AddRefs(destSurface)); if (FAILED(hr)) { NS_WARNING("Failed to get texture surface level for dest."); } if (sourceSurface && destSurface) { RECT sourceRect; sourceRect.left = aSourcePoint.x; sourceRect.right = aSourcePoint.x + aRect.width; sourceRect.top = aSourcePoint.y; sourceRect.bottom = aSourcePoint.y + aRect.height; RECT destRect; destRect.left = 0; destRect.right = aRect.width; destRect.top = 0; destRect.bottom = aRect.height; // copy the source to the dest hr = device()->StretchRect(sourceSurface, &sourceRect, destSurface, &destRect, D3DTEXF_NONE); if (FAILED(hr)) { ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTargetFromSource: Failed to update texture"), hr); } } } RefPtr<CompositingRenderTargetD3D9> rt = new CompositingRenderTargetD3D9(texture, INIT_MODE_NONE, aRect); return rt; }
TemporaryRef<CompositingRenderTarget> CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect, const CompositingRenderTarget* aSource, const gfx::IntPoint &aSourcePoint) { MOZ_ASSERT(aRect.width != 0 && aRect.height != 0); if (aRect.width * aRect.height == 0) { return nullptr; } CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aRect.width, aRect.height, 1, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET); RefPtr<ID3D11Texture2D> texture; HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); NS_ASSERTION(texture, "Could not create texture"); if (Failed(hr) || !texture) { return nullptr; } if (aSource) { const CompositingRenderTargetD3D11* sourceD3D11 = static_cast<const CompositingRenderTargetD3D11*>(aSource); D3D11_BOX srcBox; srcBox.left = aSourcePoint.x; srcBox.top = aSourcePoint.y; srcBox.front = 0; srcBox.right = aSourcePoint.x + aRect.width; srcBox.bottom = aSourcePoint.y + aRect.height; srcBox.back = 1; const IntSize& srcSize = sourceD3D11->GetSize(); MOZ_ASSERT(srcSize.width >= 0 && srcSize.height >= 0, "render targets should have nonnegative sizes"); if (srcBox.left >= 0 && srcBox.top >= 0 && srcBox.left < srcBox.right && srcBox.top < srcBox.bottom && srcBox.right <= static_cast<uint32_t>(srcSize.width) && srcBox.bottom <= static_cast<uint32_t>(srcSize.height)) { mContext->CopySubresourceRegion(texture, 0, 0, 0, 0, sourceD3D11->GetD3D11Texture(), 0, &srcBox); } else { NS_WARNING("Could not copy render target - source rect out of bounds"); } } RefPtr<CompositingRenderTargetD3D11> rt = new CompositingRenderTargetD3D11(texture, aRect.TopLeft()); rt->SetSize(aRect.Size()); return rt; }
void DrawTargetD2D1::DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest, const Color &aColor, const Point &aOffset, Float aSigma, CompositionOp aOperator) { MarkChanged(); mDC->SetTransform(D2D1::IdentityMatrix()); mTransformDirty = true; Matrix mat; RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, ExtendMode::CLAMP); if (!mat.IsIdentity()) { gfxDebug() << *this << ": At this point complex partial uploads are not supported for Shadow surfaces."; return; } // Step 1, create the shadow effect. RefPtr<ID2D1Effect> shadowEffect; mDC->CreateEffect(CLSID_D2D1Shadow, byRef(shadowEffect)); shadowEffect->SetInput(0, image); shadowEffect->SetValue(D2D1_SHADOW_PROP_BLUR_STANDARD_DEVIATION, aSigma); D2D1_VECTOR_4F color = { aColor.r, aColor.g, aColor.b, aColor.a }; shadowEffect->SetValue(D2D1_SHADOW_PROP_COLOR, color); // Step 2, move the shadow effect into place. RefPtr<ID2D1Effect> affineTransformEffect; mDC->CreateEffect(CLSID_D2D12DAffineTransform, byRef(affineTransformEffect)); affineTransformEffect->SetInputEffect(0, shadowEffect); D2D1_MATRIX_3X2_F matrix = D2D1::Matrix3x2F::Translation(aOffset.x, aOffset.y); affineTransformEffect->SetValue(D2D1_2DAFFINETRANSFORM_PROP_TRANSFORM_MATRIX, matrix); // Step 3, create an effect that combines shadow and bitmap in one image. RefPtr<ID2D1Effect> compositeEffect; mDC->CreateEffect(CLSID_D2D1Composite, byRef(compositeEffect)); compositeEffect->SetInputEffect(0, affineTransformEffect); compositeEffect->SetInput(1, image); compositeEffect->SetValue(D2D1_COMPOSITE_PROP_MODE, D2DCompositionMode(aOperator)); D2D1_POINT_2F surfPoint = D2DPoint(aDest); mDC->DrawImage(compositeEffect, &surfPoint, nullptr, D2D1_INTERPOLATION_MODE_LINEAR, D2DCompositionMode(aOperator)); }
nsresult WMFVideoDecoder::Init(mozilla::layers::LayersBackend aLayersBackend, mozilla::layers::ImageContainer* aImageContainer) { NS_ENSURE_ARG_POINTER(aImageContainer); bool useDxva= InitializeDXVA(aLayersBackend); mDecoder = new MFTDecoder(); HRESULT hr = mDecoder->Create(CLSID_CMSH264DecoderMFT); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); if (useDxva) { RefPtr<IMFAttributes> attr(mDecoder->GetAttributes()); UINT32 aware = 0; if (attr) { attr->GetUINT32(MF_SA_D3D_AWARE, &aware); } if (aware) { // TODO: Test if I need this anywhere... Maybe on Vista? //hr = attr->SetUINT32(CODECAPI_AVDecVideoAcceleration_H264, TRUE); //NS_ENSURE_TRUE(SUCCEEDED(hr), hr); MOZ_ASSERT(mDXVA2Manager); ULONG_PTR manager = ULONG_PTR(mDXVA2Manager->GetDXVADeviceManager()); hr = mDecoder->SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER, manager); if (SUCCEEDED(hr)) { mUseHwAccel = true; } } } // Setup the input/output media types. RefPtr<IMFMediaType> type; hr = wmf::MFCreateMediaType(byRef(type)); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); hr = type->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); hr = type->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); hr = type->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_MixedInterlaceOrProgressive); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); GUID outputType = mUseHwAccel ? MFVideoFormat_NV12 : MFVideoFormat_YV12; hr = mDecoder->SetMediaTypes(type, outputType); NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE); mImageContainer = aImageContainer; LOG("Video Decoder initialized, Using DXVA: %s", (mUseHwAccel ? "Yes" : "No")); return NS_OK; }
HRESULT RadialGradientEffectD2D1::SetStopCollection(IUnknown *aStopCollection) { if (SUCCEEDED(aStopCollection->QueryInterface((ID2D1GradientStopCollection**)byRef(mStopCollection)))) { return S_OK; } return E_INVALIDARG; }
void DeprecatedTextureClientD3D11::LockTexture() { RefPtr<IDXGIKeyedMutex> mutex; mTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); mutex->AcquireSync(0, INFINITE); mIsLocked = true; }