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

Side by Side Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 101763010: Fix build warnings in SkAlphaThresholdFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix another warning Created 6 years, 11 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 | « gm/imagealphathreshold.cpp ('k') | tests/GLProgramsTest.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 2013 Google Inc. 2 * Copyright 2013 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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkFlattenableBuffers.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 buffer.writeScalar(fOuterThreshold); 301 buffer.writeScalar(fOuterThreshold);
302 buffer.writeRegion(fRegion); 302 buffer.writeRegion(fRegion);
303 } 303 }
304 304
305 bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src, 305 bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
306 const SkMatrix& matrix, SkBitmap* dst, 306 const SkMatrix& matrix, SkBitmap* dst,
307 SkIPoint* offset) { 307 SkIPoint* offset) {
308 SkASSERT(src.config() == SkBitmap::kARGB_8888_Config); 308 SkASSERT(src.config() == SkBitmap::kARGB_8888_Config);
309 309
310 if (src.config() != SkBitmap::kARGB_8888_Config) { 310 if (src.config() != SkBitmap::kARGB_8888_Config) {
311 return false; 311 return false;
312 } 312 }
313 313
314 SkMatrix localInverse; 314 SkMatrix localInverse;
315 if (!matrix.invert(&localInverse)) { 315 if (!matrix.invert(&localInverse)) {
316 return NULL; 316 return false;
317 } 317 }
318 318
319 SkAutoLockPixels alp(src); 319 SkAutoLockPixels alp(src);
320 SkASSERT(src.getPixels()); 320 SkASSERT(src.getPixels());
321 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { 321 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
322 return false; 322 return false;
323 } 323 }
324 324
325 dst->setConfig(src.config(), src.width(), src.height()); 325 dst->setConfig(src.config(), src.width(), src.height());
326 dst->allocPixels(); 326 dst->allocPixels();
327 if (!dst->getPixels()) { 327 if (!dst->getPixels()) {
328 return false; 328 return false;
329 } 329 }
330 330
331 U8CPU innerThreshold = fInnerThreshold * 0xFF; 331 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
332 U8CPU outerThreshold = fOuterThreshold * 0xFF; 332 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
333 SkColor* sptr = src.getAddr32(0, 0); 333 SkColor* sptr = src.getAddr32(0, 0);
334 SkColor* dptr = dst->getAddr32(0, 0); 334 SkColor* dptr = dst->getAddr32(0, 0);
335 int width = src.width(), height = src.height(); 335 int width = src.width(), height = src.height();
336 for (int y = 0; y < height; ++y) { 336 for (int y = 0; y < height; ++y) {
337 for (int x = 0; x < width; ++x) { 337 for (int x = 0; x < width; ++x) {
338 const SkColor& source = sptr[y * width + x]; 338 const SkColor& source = sptr[y * width + x];
339 SkColor output_color(source); 339 SkColor output_color(source);
340 SkPoint position; 340 SkPoint position;
341 localInverse.mapXY(x, y, &position); 341 localInverse.mapXY((SkScalar)x, (SkScalar)y, &position);
342 if (fRegion.contains(position.x(), position.y())) { 342 if (fRegion.contains((int32_t)position.x(), (int32_t)position.y())) {
343 if (SkColorGetA(source) < innerThreshold) { 343 if (SkColorGetA(source) < innerThreshold) {
344 U8CPU alpha = SkColorGetA(source); 344 U8CPU alpha = SkColorGetA(source);
345 if (alpha == 0) 345 if (alpha == 0)
346 alpha = 1; 346 alpha = 1;
347 float scale = (float)innerThreshold / alpha; 347 float scale = (float)innerThreshold / alpha;
348 output_color = SkColorSetARGB(innerThreshold, 348 output_color = SkColorSetARGB(innerThreshold,
349 SkColorGetR(source) * scale, 349 (U8CPU)(SkColorGetR(source) * scale),
350 SkColorGetG(source) * scale, 350 (U8CPU)(SkColorGetG(source) * scale),
351 SkColorGetB(source) * scale); 351 (U8CPU)(SkColorGetB(source) * scale));
352 } 352 }
353 } else { 353 } else {
354 if (SkColorGetA(source) > outerThreshold) { 354 if (SkColorGetA(source) > outerThreshold) {
355 float scale = (float)outerThreshold / SkColorGetA(source); 355 float scale = (float)outerThreshold / SkColorGetA(source);
356 output_color = SkColorSetARGB(outerThreshold, 356 output_color = SkColorSetARGB(outerThreshold,
357 SkColorGetR(source) * scale, 357 (U8CPU)(SkColorGetR(source) * scale),
358 SkColorGetG(source) * scale, 358 (U8CPU)(SkColorGetG(source) * scale),
359 SkColorGetB(source) * scale); 359 (U8CPU)(SkColorGetB(source) * scale));
360 } 360 }
361 } 361 }
362 dptr[y * dst->width() + x] = output_color; 362 dptr[y * dst->width() + x] = output_color;
363 } 363 }
364 } 364 }
365 365
366 return true; 366 return true;
367 } 367 }
OLDNEW
« no previous file with comments | « gm/imagealphathreshold.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698