Re: SkBitmapProcShader: if the bitmap already has a texture, just use it. (issue 262803005)

12 views
Skip to first unread message

senor...@chromium.org

unread,
Oct 19, 2014, 2:34:54 PM10/19/14
to bsal...@chromium.org, skia-...@googlegroups.com
Reviewers: bsalomon1,

Message:
On 2014/05/01 15:30:21, Stephen White wrote:
> On 2014/05/01 15:22:14, bsalomon wrote:
> > On 2014/05/01 15:17:02, Stephen White wrote:
> > > Now that I think about this some more, perhaps we need to check that
> the
> > > bitmap's texture has matching params.
> >
> > The risk is that the bitmap is not a power-of-two, the npot extension
> isn't
> > available, and the shader wants to repeat/mirror the bitmap. In that
> case
we'd
> > have to go through the code path of stretching it to the next pot.

> Right. That should be doable on-GPU, no?

> The check seems to be made in get_texture_flags() in GrTexture.cpp;
> should we
> make
> this public? There doesn't seem to be a way of querying the texture for
> the
> params
> that were used to create it, but maybe we can cons up the flags using that
> function
> and compare the texture's flags against it?

Brian: dunno if you're still working on (or have finished) this, but this my
attempt to fix this issue (never landed).

Description:
SkBitmapProcShader: if the bitmap already has a texture, just use it.

BUG=367163


Please review this at https://codereview.chromium.org/262803005/

Base URL: https://skia.googlecode.com/svn/trunk

Affected files (+10, -2 lines):
M src/core/SkBitmapProcShader.cpp


Index: src/core/SkBitmapProcShader.cpp
diff --git a/src/core/SkBitmapProcShader.cpp
b/src/core/SkBitmapProcShader.cpp
index
44bdc6d348e7f3af6505bceb87f3f38a22812c8b..b9b8fd49e697e1522cb0ca47f20f1b6b32bcdd1c
100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -476,7 +476,13 @@ GrEffectRef*
SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint&

}
GrTextureParams params(tm, textureFilterMode);
- GrTexture* texture = GrLockAndRefCachedBitmapTexture(context,
fRawBitmap, &params);
+ GrTexture* texture = fRawBitmap.getTexture();
+ bool didLockTexture = false;
+
+ if (!texture) {
+ texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap,
&params);
+ didLockTexture = true;
+ }

if (NULL == texture) {
SkErrorInternals::SetError( kInternalError_SkError,
@@ -490,7 +496,9 @@ GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext*
context, const SkPaint&
} else {
effect = GrSimpleTextureEffect::Create(texture, matrix, params);
}
- GrUnlockAndUnrefCachedBitmapTexture(texture);
+ if (didLockTexture) {
+ GrUnlockAndUnrefCachedBitmapTexture(texture);
+ }
return effect;
}
#endif


Reply all
Reply to author
Forward
0 new messages