Modify SkBitmap::extractSubset() to respect volatility

The resulting subset bitmap will always have the same volatility flag as the
source bitmap.

BUG=452
Review URL: http://codereview.appspot.com/5544052

git-svn-id: http://skia.googlecode.com/svn/trunk@3039 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
skyostil@google.com 2012-01-16 10:45:53 +00:00
parent ff25e3e3a0
commit 0eb7576c65
2 changed files with 7 additions and 0 deletions

View File

@ -822,6 +822,7 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
SkBitmap dst;
dst.setConfig(this->config(), r.width(), r.height(), this->rowBytes());
dst.setIsOpaque(this->isOpaque());
dst.setIsVolatile(this->isVolatile());
if (fPixelRef) {
// share the pixelref with a custom offset

View File

@ -313,11 +313,14 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) {
SkIRect r;
r.set(1, 1, 2, 2);
bitmap.setIsOpaque(true);
bitmap.setIsVolatile(true);
if (bitmap.extractSubset(&subset, r)) {
REPORTER_ASSERT(reporter, subset.width() == 1);
REPORTER_ASSERT(reporter, subset.height() == 1);
REPORTER_ASSERT(reporter,
subset.isOpaque() == bitmap.isOpaque());
REPORTER_ASSERT(reporter,
subset.isVolatile() == true);
SkBitmap copy;
REPORTER_ASSERT(reporter,
@ -334,9 +337,12 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) {
(copy.getColorTable() != NULL) == hasCT);
}
bitmap.setIsOpaque(false);
bitmap.setIsVolatile(false);
if (bitmap.extractSubset(&subset, r)) {
REPORTER_ASSERT(reporter,
subset.isOpaque() == bitmap.isOpaque());
REPORTER_ASSERT(reporter,
subset.isVolatile() == false);
}
}
} else {