Bug 622482 - Part 3.5: Add TextTexture to avoid texture creation in majority of text draws. r=jrmuizel a=blocking-betaN

This commit is contained in:
Bas Schouten 2011-01-16 03:29:58 +01:00
parent 22425b06ff
commit 6e4a621f1e
2 changed files with 24 additions and 1 deletions

View File

@ -68,8 +68,14 @@ struct _cairo_d2d_device
RefPtr<ID3D10Buffer> mQuadBuffer;
RefPtr<ID3D10RasterizerState> mRasterizerState;
RefPtr<ID3D10BlendState> mBlendStates[MAX_OPERATORS];
/** Texture used for manual glyph rendering */
RefPtr<ID3D10Texture2D> mTextTexture;
RefPtr<ID3D10ShaderResourceView> mTextTextureView;
int mVRAMUsage;
};
const unsigned int TEXT_TEXTURE_WIDTH = 2048;
const unsigned int TEXT_TEXTURE_HEIGHT = 512;
typedef struct _cairo_d2d_device cairo_d2d_device_t;
struct _cairo_d2d_surface {

View File

@ -175,6 +175,10 @@ cairo_d2d_create_device_from_d3d10device(ID3D10Device1 *d3d10device)
Vertex vertices[] = { {0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0} };
CD3D10_BUFFER_DESC bufferDesc(sizeof(vertices), D3D10_BIND_VERTEX_BUFFER);
D3D10_SUBRESOURCE_DATA data;
CD3D10_TEXTURE2D_DESC textDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
TEXT_TEXTURE_WIDTH,
TEXT_TEXTURE_HEIGHT,
1, 1);
cairo_d2d_device_t *device = new cairo_d2d_device_t;
@ -244,7 +248,20 @@ cairo_d2d_create_device_from_d3d10device(ID3D10Device1 *d3d10device)
goto FAILED;
}
device->base.refcount = 1;
device->mVRAMUsage = 0;
// We start out with TEXT_TEXTURE roughly in VRAM usage.
device->mVRAMUsage = TEXT_TEXTURE_WIDTH * TEXT_TEXTURE_HEIGHT * 4;
textDesc.Usage = D3D10_USAGE_DYNAMIC;
textDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
hr = device->mD3D10Device->CreateTexture2D(&textDesc, NULL, &device->mTextTexture);
if (FAILED(hr)) {
goto FAILED;
}
hr = device->mD3D10Device->CreateShaderResourceView(device->mTextTexture,
NULL,
&device->mTextTextureView);
return &device->base;
FAILED: