fix slow performance on desktops by uping our max-texture-dim from 512 to

whatever the gpu itself broadcasts.



git-svn-id: http://skia.googlecode.com/svn/trunk@742 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-01-28 21:21:49 +00:00
Родитель d2938db1d9
Коммит 02a7e6c117
5 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -134,6 +134,11 @@ public:
*/
void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes);
/**
* Return the max width or height of a texture supported by the current gpu
*/
int getMaxTextureDimension();
///////////////////////////////////////////////////////////////////////////
// Render targets

Просмотреть файл

@ -287,6 +287,8 @@ public:
*/
NPOTTextureTypes npotTextureSupport() const { return fNPOTTextureSupport; }
int maxTextureDimension() const { return fMaxTextureDimension; }
// GrDrawTarget overrides
virtual void drawIndexed(PrimitiveType type,
uint32_t startVertex,
@ -381,6 +383,7 @@ protected:
// set by subclass
int fMinRenderTargetWidth;
int fMinRenderTargetHeight;
int fMaxTextureDimension;
// overridden by API specific GrGpu-derived class to perform the draw call.
virtual void drawIndexedHelper(PrimitiveType type,

Просмотреть файл

@ -241,6 +241,10 @@ void GrContext::setTextureCacheLimits(int maxTextures, size_t maxTextureBytes) {
fTextureCache->setLimits(maxTextures, maxTextureBytes);
}
int GrContext::getMaxTextureDimension() {
return fGpu->maxTextureDimension();
}
///////////////////////////////////////////////////////////////////////////////
GrRenderTarget* GrContext::createPlatformRenderTarget(intptr_t platformRenderTarget,

Просмотреть файл

@ -380,6 +380,8 @@ GrGpuGL::GrGpuGL() {
fMinRenderTargetHeight = GrMax<GLuint>(fMinRenderTargetHeight, 16);
#endif
GR_GL_GetIntegerv(GL_MAX_TEXTURE_SIZE, &fMaxTextureDimension);
#if GR_COLLECT_STATS
++fStats.fRenderTargetChngCnt;
#endif

Просмотреть файл

@ -709,13 +709,6 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& path,
fContext->drawPath(grPaint, &iter, fill);
}
/*
* This value must not exceed the GPU's texture dimension limit, but it can
* be smaller, if that helps avoid very large single textures hurting the
* cache.
*/
#define MAX_TEXTURE_DIM 512
void SkGpuDevice::drawBitmap(const SkDraw& draw,
const SkBitmap& bitmap,
const SkIRect* srcRectPtr,
@ -736,8 +729,9 @@ void SkGpuDevice::drawBitmap(const SkDraw& draw,
}
grPaint.fSampler.setFilter(paint.isFilterBitmap());
if (bitmap.getTexture() || (bitmap.width() <= MAX_TEXTURE_DIM &&
bitmap.height() <= MAX_TEXTURE_DIM)) {
const int maxTextureDim = fContext->getMaxTextureDimension();
if (bitmap.getTexture() || (bitmap.width() <= maxTextureDim &&
bitmap.height() <= maxTextureDim)) {
// take the fast case
this->internalDrawBitmap(draw, bitmap, srcRect, m, &grPaint);
return;
@ -762,13 +756,13 @@ void SkGpuDevice::drawBitmap(const SkDraw& draw,
clipRect.offset(DX, DY);
}
int nx = bitmap.width() / MAX_TEXTURE_DIM;
int ny = bitmap.height() / MAX_TEXTURE_DIM;
int nx = bitmap.width() / maxTextureDim;
int ny = bitmap.height() / maxTextureDim;
for (int x = 0; x <= nx; x++) {
for (int y = 0; y <= ny; y++) {
SkIRect tileR;
tileR.set(x * MAX_TEXTURE_DIM, y * MAX_TEXTURE_DIM,
(x + 1) * MAX_TEXTURE_DIM, (y + 1) * MAX_TEXTURE_DIM);
tileR.set(x * maxTextureDim, y * maxTextureDim,
(x + 1) * maxTextureDim, (y + 1) * maxTextureDim);
if (!SkIRect::Intersects(tileR, clipRect)) {
continue;
}
@ -807,8 +801,8 @@ void SkGpuDevice::internalDrawBitmap(const SkDraw& draw,
const SkIRect& srcRect,
const SkMatrix& m,
GrPaint* grPaint) {
SkASSERT(bitmap.width() <= MAX_TEXTURE_DIM &&
bitmap.height() <= MAX_TEXTURE_DIM);
SkASSERT(bitmap.width() <= fContext->getMaxTextureDimension() &&
bitmap.height() <= fContext->getMaxTextureDimension());
SkAutoLockPixels alp(bitmap);
if (!bitmap.getTexture() && !bitmap.readyToDraw()) {