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

Side by Side Diff: Source/platform/graphics/filters/FELighting.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 University of Szeged 2 * Copyright (C) 2010 University of Szeged
3 * Copyright (C) 2010 Zoltan Herczeg 3 * Copyright (C) 2010 Zoltan Herczeg
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Anyway, feConvolveMatrix should also use the implementation 416 // Anyway, feConvolveMatrix should also use the implementation
417 417
418 IntSize absolutePaintSize = absolutePaintRect().size(); 418 IntSize absolutePaintSize = absolutePaintRect().size();
419 drawLighting(srcPixelArray, absolutePaintSize.width(), absolutePaintSize.hei ght()); 419 drawLighting(srcPixelArray, absolutePaintSize.width(), absolutePaintSize.hei ght());
420 } 420 }
421 421
422 PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder* builder) 422 PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder* builder)
423 { 423 {
424 SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() : FloatSize()); 424 SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() : FloatSize());
425 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); 425 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor);
426 RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operati ngColorSpace()) : 0); 426 RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operati ngColorSpace()) : nullptr);
427 switch (m_lightSource->type()) { 427 switch (m_lightSource->type()) {
428 case LS_DISTANT: { 428 case LS_DISTANT: {
429 DistantLightSource* distantLightSource = static_cast<DistantLightSource* >(m_lightSource.get()); 429 DistantLightSource* distantLightSource = static_cast<DistantLightSource* >(m_lightSource.get());
430 float azimuthRad = deg2rad(distantLightSource->azimuth()); 430 float azimuthRad = deg2rad(distantLightSource->azimuth());
431 float elevationRad = deg2rad(distantLightSource->elevation()); 431 float elevationRad = deg2rad(distantLightSource->elevation());
432 SkPoint3 direction(cosf(azimuthRad) * cosf(elevationRad), 432 SkPoint3 direction(cosf(azimuthRad) * cosf(elevationRad),
433 sinf(azimuthRad) * cosf(elevationRad), 433 sinf(azimuthRad) * cosf(elevationRad),
434 sinf(elevationRad)); 434 sinf(elevationRad));
435 if (m_specularConstant > 0) 435 if (m_specularConstant > 0)
436 return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(dire ction, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect)); 436 return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(dire ction, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
(...skipping 14 matching lines...) Expand all
451 float specularExponent = spotLightSource->specularExponent(); 451 float specularExponent = spotLightSource->specularExponent();
452 float limitingConeAngle = spotLightSource->limitingConeAngle(); 452 float limitingConeAngle = spotLightSource->limitingConeAngle();
453 if (!limitingConeAngle || limitingConeAngle > 90 || limitingConeAngle < -90) 453 if (!limitingConeAngle || limitingConeAngle > 90 || limitingConeAngle < -90)
454 limitingConeAngle = 90; 454 limitingConeAngle = 90;
455 if (m_specularConstant > 0) 455 if (m_specularConstant > 0)
456 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale , m_specularConstant, m_specularExponent, input.get(), &rect)); 456 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale , m_specularConstant, m_specularExponent, input.get(), &rect));
457 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d iffuseConstant, input.get(), &rect)); 457 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d iffuseConstant, input.get(), &rect));
458 } 458 }
459 default: 459 default:
460 ASSERT_NOT_REACHED(); 460 ASSERT_NOT_REACHED();
461 return 0; 461 return nullptr;
462 } 462 }
463 } 463 }
464 464
465 bool FELighting::applySkia() 465 bool FELighting::applySkia()
466 { 466 {
467 // For now, only use the skia implementation for accelerated rendering. 467 // For now, only use the skia implementation for accelerated rendering.
468 if (!filter()->isAccelerated()) 468 if (!filter()->isAccelerated())
469 return false; 469 return false;
470 470
471 ImageBuffer* resultImage = createImageBufferResult(); 471 ImageBuffer* resultImage = createImageBufferResult();
(...skipping 14 matching lines...) Expand all
486 GraphicsContext* dstContext = resultImage->context(); 486 GraphicsContext* dstContext = resultImage->context();
487 487
488 SkPaint paint; 488 SkPaint paint;
489 RefPtr<SkImageFilter> filter = createImageFilter(0); 489 RefPtr<SkImageFilter> filter = createImageFilter(0);
490 paint.setImageFilter(filter.get()); 490 paint.setImageFilter(filter.get());
491 dstContext->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint); 491 dstContext->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint);
492 return true; 492 return true;
493 } 493 }
494 494
495 } // namespace WebCore 495 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/LazyDecodingPixelRef.cpp ('k') | Source/platform/graphics/filters/FilterEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698