OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 static bool bitmap_is_too_big(const SkBitmap& bm) { | 693 static bool bitmap_is_too_big(const SkBitmap& bm) { |
694 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it | 694 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it |
695 // communicates between its matrix-proc and its sampler-proc. Until we can | 695 // communicates between its matrix-proc and its sampler-proc. Until we can |
696 // widen that, we have to reject bitmaps that are larger. | 696 // widen that, we have to reject bitmaps that are larger. |
697 // | 697 // |
698 static const int kMaxSize = 65535; | 698 static const int kMaxSize = 65535; |
699 | 699 |
700 return bm.width() > kMaxSize || bm.height() > kMaxSize; | 700 return bm.width() > kMaxSize || bm.height() > kMaxSize; |
701 } | 701 } |
702 | 702 |
703 SkShader* SkLightingShader::Create(const SkBitmap& diffuse, const SkBitmap& norm
al, | 703 sk_sp<SkShader> SkLightingShader::Make(const SkBitmap& diffuse, const SkBitmap&
normal, |
704 const Lights* lights, | 704 const Lights* lights, |
705 const SkVector& invNormRotation, | 705 const SkVector& invNormRotation, |
706 const SkMatrix* diffLocalM, const SkMatrix* n
ormLocalM) { | 706 const SkMatrix* diffLocalM, const SkMatri
x* normLocalM) { |
707 if (diffuse.isNull() || bitmap_is_too_big(diffuse) || | 707 if (diffuse.isNull() || bitmap_is_too_big(diffuse) || |
708 normal.isNull() || bitmap_is_too_big(normal) || | 708 normal.isNull() || bitmap_is_too_big(normal) || |
709 diffuse.width() != normal.width() || | 709 diffuse.width() != normal.width() || |
710 diffuse.height() != normal.height()) { | 710 diffuse.height() != normal.height()) { |
711 return nullptr; | 711 return nullptr; |
712 } | 712 } |
713 | 713 |
714 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1)); | 714 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1)); |
715 | 715 |
716 return new SkLightingShaderImpl(diffuse, normal, lights, invNormRotation, di
ffLocalM, | 716 return sk_make_sp<SkLightingShaderImpl>(diffuse, normal, lights, invNormRota
tion, diffLocalM, |
717 normLocalM); | 717 normLocalM); |
718 } | 718 } |
719 | 719 |
720 /////////////////////////////////////////////////////////////////////////////// | 720 /////////////////////////////////////////////////////////////////////////////// |
721 | 721 |
722 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 722 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
723 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 723 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
724 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 724 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
725 | 725 |
726 /////////////////////////////////////////////////////////////////////////////// | 726 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |