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
This commit is contained in:
parent
b88cfe58e1
commit
5c63865b52
@ -1464,17 +1464,19 @@ void GrContext::writePixels(int left, int top, int width, int height,
|
||||
// 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 @@ void GrContext::writePixels(int left, int top, int width, int height,
|
||||
|
||||
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);
|
||||
|
||||
|
@ -176,6 +176,10 @@ public:
|
||||
/** Set the matrix to scale by sx and sy.
|
||||
*/
|
||||
void setScale(SkScalar sx, SkScalar sy);
|
||||
/** Set the matrix to scale by 1/divx and 1/divy. Returns false and doesn't
|
||||
touch the matrix if either divx or divy is zero.
|
||||
*/
|
||||
bool setIDiv(int divx, int divy);
|
||||
/** Set the matrix to rotate by the specified number of degrees, with a
|
||||
pivot point at (px, py). The pivot point is the coordinate that should
|
||||
remain unchanged by the specified transformation.
|
||||
|
@ -220,6 +220,14 @@ void SkMatrix::setScale(SkScalar sx, SkScalar sy) {
|
||||
this->setTypeMask(kScale_Mask | kRectStaysRect_Mask);
|
||||
}
|
||||
|
||||
bool SkMatrix::setIDiv(int divx, int divy) {
|
||||
if (!divx || !divy) {
|
||||
return false;
|
||||
}
|
||||
this->setScale(SK_Scalar1 / divx, SK_Scalar1 / divy);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkMatrix::preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy, px, py);
|
||||
|
Loading…
Reference in New Issue
Block a user