Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3576)

Issue 6839043: Fix some extract subset bugs. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 7 months ago by Leon
Modified:
11 years, 6 months ago
CC:
skia-review_googlegroups.com
Base URL:
https://skia.googlecode.com/svn/trunk
Visibility:
Public.

Description

Fix some extract subset bugs. In SkBitmap::extractSubset, perform a deepCopy, if the pixelRef supports it. Fixes a bug in the 'extractbitmap' gm, which attempts to draw a subset of a texture backed bitmap (if the canvas is really an SkGpuCanvas). Also fix some bugs that happen when there is a pixel offset. These fixes get bypassed by the deepCopy, but a user can still set a pixel offset manually. When copying GPU backed bitmap with a pixel offset, copy the offset. If the new config is the same as the old, copy fRowBytes as well. Add a function to SkBitmap.cpp (getUpperLeftFromOffset) to find the x,y coordinate to use when copying to a new config. Fix a bug where readPixels copied to the correct desired config and we were setting the generation ID to match even though the desired config was not the same as the original config (caught by my new tests!). Add some tests to verify the correct behavior. Committed: https://code.google.com/p/skia/source/detail?r=6710

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : Improve the test, add comments, fix a bug in copyTo. #

Total comments: 1

Patch Set 4 : Performs a deepCopy on extractSubset. #

Total comments: 4

Patch Set 5 : Respond to comments. #

Total comments: 4

Patch Set 6 : Improve a comment, make copyTexture more robust, as per comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+296 lines, -73 lines) Patch
M include/core/SkPixelRef.h View 1 2 3 1 chunk +12 lines, -5 lines 0 comments Download
M include/gpu/GrContext.h View 1 2 3 4 5 1 chunk +6 lines, -2 lines 0 comments Download
M include/gpu/SkGrPixelRef.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkBitmap.cpp View 1 2 3 6 chunks +119 lines, -18 lines 0 comments Download
M src/gpu/GrContext.cpp View 1 2 3 4 5 2 chunks +12 lines, -5 lines 0 comments Download
M src/gpu/SkGrPixelRef.cpp View 1 2 3 5 chunks +19 lines, -7 lines 0 comments Download
M tests/GpuBitmapCopyTest.cpp View 1 2 4 chunks +127 lines, -35 lines 0 comments Download

Messages

Total messages: 9
Leon
11 years, 7 months ago (2012-11-13 15:34:40 UTC) #1
bsalomon
Would it make sense to have pixel ref track the x/y either instead of or ...
11 years, 7 months ago (2012-11-13 15:44:36 UTC) #2
Leon
On 2012/11/13 15:44:36, bsalomon wrote: > Would it make sense to have pixel ref track ...
11 years, 7 months ago (2012-11-13 16:49:01 UTC) #3
Leon
PTAL. I have changed it so the deepCopy is done in extractSubset, although the fact ...
11 years, 6 months ago (2012-12-06 21:56:30 UTC) #4
bsalomon
I think we have some deep problems with SkBitmap's interface WRT texture backed bitmaps. That ...
11 years, 6 months ago (2012-12-06 22:16:17 UTC) #5
Leon
https://codereview.appspot.com/6839043/diff/11001/include/gpu/SkGrPixelRef.h File include/gpu/SkGrPixelRef.h (right): https://codereview.appspot.com/6839043/diff/11001/include/gpu/SkGrPixelRef.h#newcode62 include/gpu/SkGrPixelRef.h:62: const SkIRect* subset = NULL) SK_OVERRIDE; On 2012/12/06 22:16:18, ...
11 years, 6 months ago (2012-12-06 23:12:25 UTC) #6
bsalomon
https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h File include/gpu/GrContext.h (right): https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h#newcode595 include/gpu/GrContext.h:595: * Copies all texels from one texture to another. ...
11 years, 6 months ago (2012-12-07 14:35:47 UTC) #7
Leon
https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h File include/gpu/GrContext.h (right): https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h#newcode595 include/gpu/GrContext.h:595: * Copies all texels from one texture to another. ...
11 years, 6 months ago (2012-12-07 16:28:18 UTC) #8
bsalomon
11 years, 6 months ago (2012-12-07 16:29:25 UTC) #9
On 2012/12/07 16:28:18, scroggo-work wrote:
> https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h
> File include/gpu/GrContext.h (right):
> 
>
https://codereview.appspot.com/6839043/diff/14002/include/gpu/GrContext.h#new...
> include/gpu/GrContext.h:595: * Copies all texels from one texture to another.
> On 2012/12/07 14:35:47, bsalomon wrote:
> > This should be updated... it doesn't copy all the pixels. We can say it
copies
> a
> > rect of pixels from src to dst. The size of dst is the size of the rectangle
> > copied and topLeft is the position of the rect in src. The rect is clipped
to
> > src's bounds.
> 
> Done.
> 
> https://codereview.appspot.com/6839043/diff/14002/src/gpu/GrContext.cpp
> File src/gpu/GrContext.cpp (right):
> 
>
https://codereview.appspot.com/6839043/diff/14002/src/gpu/GrContext.cpp#newco...
> src/gpu/GrContext.cpp:1443: sampleM.setIDiv(src->width(), src->height());
> On 2012/12/07 14:35:47, bsalomon wrote:
> > I think this would clip and catch a few more bad cases:
> > 
> > SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst-height());
> > if (NULL != topLeft) {
> >     srcRect.offset(*topLeft);
> > }
> > SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height());
> > if (!srcRect.intersect(srcBounds)) {
> >     return;
> > }
> > sampleM.preTranslate(SkIntToScalar(srcRect.fLeft),
> SkIntToScalar(srcRect.fTop));
> > drawState->createTextureEffect(0, src, sampleM);
> > SkRect dstRect = SkRect::MakeWH(SkIntToScalar(srcRect->width(),
> > SkIntToScalar(dstRect->height());
> > fGpu->drawSimpleRect(dstRect, NULL);
> 
> Done.

If it all works then LGTM.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b