Use texture cache for writePixels temp
Review URL: http://codereview.appspot.com/4757050/
git-svn-id: http://skia.googlecode.com/svn/trunk@1887 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index dc4bac8..dcaba1d 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -1464,17 +1464,19 @@
// TODO: when underlying api has a direct way to do this we should use it
// (e.g. glDrawPixels on desktop GL).
+ this->flush(true);
+
const GrTextureDesc desc = {
kNone_GrTextureFlags, kNone_GrAALevel, width, height, config
};
- GrTexture* texture = fGpu->createTexture(desc, buffer, stride);
+ GrAutoUnlockTextureEntry aute(this,
+ this->findApproximateKeylessTexture(desc));
+ GrTexture* texture = aute.texture();
if (NULL == texture) {
return;
}
+ texture->uploadTextureData(0, 0, width, height, buffer, stride);
- this->flush(true);
-
- GrAutoUnref aur(texture);
GrDrawTarget::AutoStateRestore asr(fGpu);
GrMatrix matrix;
@@ -1490,7 +1492,7 @@
GrSamplerState sampler;
sampler.setClampNoFilter();
- matrix.setScale(GR_Scalar1 / width, GR_Scalar1 / height);
+ matrix.setIDiv(texture->width(), texture->height());
sampler.setMatrix(matrix);
fGpu->setSamplerState(0, sampler);