Commit eacbb18
authored
Fix dxGetTexturePixels/dxSetTexturePixels failing on browser elements (#4876)
#### Summary
Relax the non-rendertarget branch in `CPixelsManager::GetTexturePixels`
and `CPixelsManager::SetTexturePixels` from `Desc.Usage == 0` to
`(Desc.Usage & D3DUSAGE_RENDERTARGET) == 0`, so that `D3DUSAGE_DYNAMIC`
textures are routed through the existing lockable-surface path instead
of silently returning `false`.
#### Motivation
PR #4634 (CEF performance improvements, commit ddb9249) switched
browser textures in `CWebBrowserItem::CreateUnderlyingData` from
`D3DPOOL_MANAGED` (Usage == 0) to `D3DPOOL_DEFAULT + D3DUSAGE_DYNAMIC`
in order to remove the duplicate system-RAM copy.
As a side effect, `CPixelsManager` no longer recognised the browser
texture's usage flag, so `dxGetTexturePixels(browser, ...)` and
`dxSetTexturePixels(browser, ...)` started returning `false`.
This change is scoped narrowly: textures created with `Usage == 0` (e.g.
`dxCreateTexture` from file/raw pixels, shader/RwTexture wrappers) and
`D3DUSAGE_RENDERTARGET` (e.g. `dxCreateRenderTarget`,
`dxCreateScreenSource`) continue to take exactly the same branches they
did before. Only previously-unhandled non-rendertarget usages (notably
`D3DUSAGE_DYNAMIC` browsers) now reach the lock path that was always
intended to handle them.
#### Test plan
**Before the fix:** all three image formats (jpg, png, plain) reported
`false` / `len=nil` from `dxGetTexturePixels` against an
actively-rendering browser
**After the fix:** all three formats return non-empty data with the
expected dimensions.
Existing render-target and managed-texture callers
(`dxCreateRenderTarget`, `dxCreateTexture` from file) were also
smoke-tested via existing scripts to confirm no regression in those code
paths.
#### Checklist
* [x] Your code should follow the [coding
guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines).
* [x] Smaller pull requests are easier to review. If your pull request
is beefy, your pull request should be reviewable commit-by-commit.1 parent 543b4e1 commit eacbb18
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | | - | |
| 208 | + | |
| 209 | + | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
0 commit comments