Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: tools/SkBitmapRegionCanvas.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use aligned memory in swizzler test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/SwizzlerTest.cpp ('k') | tools/SkBitmapRegionDecoderInterface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapRegionCanvas.h" 8 #include "SkBitmapRegionCanvas.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // Allocate a bitmap for the unscaled decode 122 // Allocate a bitmap for the unscaled decode
123 SkBitmap tmp; 123 SkBitmap tmp;
124 SkImageInfo tmpInfo = decodeInfo.makeWH(this->width(), imageSubsetHeight); 124 SkImageInfo tmpInfo = decodeInfo.makeWH(this->width(), imageSubsetHeight);
125 if (!tmp.tryAllocPixels(tmpInfo)) { 125 if (!tmp.tryAllocPixels(tmpInfo)) {
126 SkDebugf("Error: Could not allocate pixels.\n"); 126 SkDebugf("Error: Could not allocate pixels.\n");
127 return nullptr; 127 return nullptr;
128 } 128 }
129 129
130 // Skip the unneeded rows 130 // Skip the unneeded rows
131 if (SkCodec::kSuccess != fDecoder->skipScanlines(imageSubsetY)) { 131 if (!fDecoder->skipScanlines(imageSubsetY)) {
132 SkDebugf("Error: Failed to skip scanlines.\n"); 132 SkDebugf("Error: Failed to skip scanlines.\n");
133 return nullptr; 133 return nullptr;
134 } 134 }
135 135
136 // Decode the necessary rows 136 // Decode the necessary rows
137 SkCodec::Result result = fDecoder->getScanlines(tmp.getAddr(0, 0), imageSubs etHeight, 137 fDecoder->getScanlines(tmp.getAddr(0, 0), imageSubsetHeight, tmp.rowBytes()) ;
138 tmp.rowBytes());
139 switch (result) {
140 case SkCodec::kSuccess:
141 case SkCodec::kIncompleteInput:
142 break;
143 default:
144 SkDebugf("Error: Failed to get scanlines.\n");
145 return nullptr;
146 }
147 138
148 // Calculate the size of the output 139 // Calculate the size of the output
149 const int outWidth = get_scaled_dimension(inputWidth, sampleSize); 140 const int outWidth = get_scaled_dimension(inputWidth, sampleSize);
150 const int outHeight = get_scaled_dimension(inputHeight, sampleSize); 141 const int outHeight = get_scaled_dimension(inputHeight, sampleSize);
151 142
152 // Initialize the destination bitmap 143 // Initialize the destination bitmap
153 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); 144 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap());
154 SkImageInfo dstInfo = decodeInfo.makeWH(outWidth, outHeight); 145 SkImageInfo dstInfo = decodeInfo.makeWH(outWidth, outHeight);
155 if (!bitmap->tryAllocPixels(dstInfo)) { 146 if (!bitmap->tryAllocPixels(dstInfo)) {
156 SkDebugf("Error: Could not allocate pixels.\n"); 147 SkDebugf("Error: Could not allocate pixels.\n");
(...skipping 22 matching lines...) Expand all
179 (SkScalar) get_scaled_dimension(imageSubsetWidth, sampleSize), 170 (SkScalar) get_scaled_dimension(imageSubsetWidth, sampleSize),
180 (SkScalar) get_scaled_dimension(imageSubsetHeight, sampleSize)); 171 (SkScalar) get_scaled_dimension(imageSubsetHeight, sampleSize));
181 SkPaint paint; 172 SkPaint paint;
182 // Overwrite the dst with the src pixels 173 // Overwrite the dst with the src pixels
183 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 174 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
184 // TODO (msarett): Test multiple filter qualities. kNone is the default. 175 // TODO (msarett): Test multiple filter qualities. kNone is the default.
185 canvas.drawBitmapRect(tmp, src, dst, &paint); 176 canvas.drawBitmapRect(tmp, src, dst, &paint);
186 177
187 return bitmap.detach(); 178 return bitmap.detach();
188 } 179 }
OLDNEW
« no previous file with comments | « tests/SwizzlerTest.cpp ('k') | tools/SkBitmapRegionDecoderInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698