| OLD | NEW |
| 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 "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 571 |
| 572 SkMatrix matrix; | 572 SkMatrix matrix; |
| 573 SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSiz
e)); | 573 SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSiz
e)); |
| 574 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); | 574 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); |
| 575 | 575 |
| 576 SkVector invNormRotation = { SkScalarSqrt(0.3), SkScalarSqrt(0.7) }; | 576 SkVector invNormRotation = { SkScalarSqrt(0.3), SkScalarSqrt(0.7) }; |
| 577 SkBitmap normals; | 577 SkBitmap normals; |
| 578 normals.allocN32Pixels(kTexSize, kTexSize); | 578 normals.allocN32Pixels(kTexSize, kTexSize); |
| 579 | 579 |
| 580 sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexS
ize, kTexSize)); | 580 sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexS
ize, kTexSize)); |
| 581 sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuse, normals
, fLights, | 581 sk_sp<SkLightingShader::NormalSource> normalSource = |
| 582 invNormRotation, &matrix, &matrix); | 582 SkLightingShader::NormalMapSource::Make(normals, invNormRotation
, &matrix); |
| 583 sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuse, fLights
, &matrix, |
| 584 std::move(normal
Source)); |
| 583 | 585 |
| 584 TestFlattenableSerialization(lightingShader.get(), true, reporter); | 586 TestFlattenableSerialization(lightingShader.get(), true, reporter); |
| 585 // TODO test equality? | 587 // TODO test equality? |
| 586 | 588 |
| 587 } | 589 } |
| 588 } | 590 } |
| 589 | 591 |
| 590 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 592 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 591 #include "SkAnnotation.h" | 593 #include "SkAnnotation.h" |
| 592 | 594 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, | 662 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, |
| 661 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, | 663 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, |
| 662 }; | 664 }; |
| 663 | 665 |
| 664 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 666 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
| 665 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 667 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
| 666 | 668 |
| 667 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 669 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
| 668 canvas.drawPicture(pict1); | 670 canvas.drawPicture(pict1); |
| 669 } | 671 } |
| OLD | NEW |