Thang Bui Quy(deleted)
|
Write data into draw context memory slowly!
|
Thang Bui Quy(deleted)
05/28/2011 1:55 PM
post86234
|
Write data into draw context memory slowly!
I write a program using draw context memory by the function PdCreateOffscreenContext(). This function returns a pointer
to a PdOffscreenContext_t. After that i use the function PdGetOffscreenContextPtr() to get a pointer to the shared
memory object. When i have that pointer i can change data in the context to blit them on the screen by the function
PgContextBlit(). However i had a problem with writing data back into the context, it was very slow. For example: ptr is
the pointer to context, d is a variable.
for(int i=0; i < CONTEXT_HEIGHT; ++i)
for(int j=0; j < CONTEXT_WITH; ++j) {
d = *(ptr + i * CONTEXT_WIDTH * 4 + j);(1)
*(ptr + i * CONTEXT_WIDTH * 4 + j) = 2 * d; (2)
}
if i set CONTEXT_HEIGHT and CONTEXT_WIDTH small (about smaller than 256) the program run normal.
if i set CONTEXT_HEIGHT and CONTEXT_WIDTH biggerl (about 1024) the program run very slow.
I tried to test with bypassing either the line (1) or the line (2) and i realized that the line (2) made the program
very slow. Can you help me to solve it?
|
|
|