| 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 "SkBitmapProcShader.h" | 10 #include "SkBitmapProcShader.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 SkBitmap normals; | 580 SkBitmap normals; |
| 581 normals.allocN32Pixels(kTexSize, kTexSize); | 581 normals.allocN32Pixels(kTexSize, kTexSize); |
| 582 | 582 |
| 583 sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexS
ize, kTexSize)); | 583 sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexS
ize, kTexSize)); |
| 584 sk_sp<SkShader> normalMap = SkMakeBitmapShader(normals, SkShader::kClamp
_TileMode, | 584 sk_sp<SkShader> normalMap = SkMakeBitmapShader(normals, SkShader::kClamp
_TileMode, |
| 585 SkShader::kClamp_TileMode
, &matrix, nullptr); | 585 SkShader::kClamp_TileMode
, &matrix, nullptr); |
| 586 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(s
td::move(normalMap), | 586 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(s
td::move(normalMap), |
| 587 c
tm); | 587 c
tm); |
| 588 sk_sp<SkShader> diffuseShader = SkMakeBitmapShader(diffuse, SkShader::kC
lamp_TileMode, | 588 sk_sp<SkShader> diffuseShader = SkMakeBitmapShader(diffuse, SkShader::kC
lamp_TileMode, |
| 589 SkShader::kClamp_TileMode, &matrix, nullptr); | 589 SkShader::kClamp_TileMode, &matrix, nullptr); |
| 590 sk_sp<SkShader> lightingShader = SkLightingShader::Make(std::move(diffus
eShader), | 590 |
| 591 std::move(normal
Source), | 591 sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuseShader, |
| 592 normalSource, |
| 592 fLights); | 593 fLights); |
| 594 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get()
, true, reporter)); |
| 593 | 595 |
| 596 lightingShader = SkLightingShader::Make(std::move(diffuseShader), |
| 597 nullptr, |
| 598 fLights); |
| 594 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get()
, true, reporter)); | 599 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get()
, true, reporter)); |
| 595 // TODO test equality? | |
| 596 | 600 |
| 601 lightingShader = SkLightingShader::Make(nullptr, |
| 602 std::move(normalSource), |
| 603 fLights); |
| 604 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get()
, true, reporter)); |
| 605 |
| 606 lightingShader = SkLightingShader::Make(nullptr, |
| 607 nullptr, |
| 608 fLights); |
| 609 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get()
, true, reporter)); |
| 597 } | 610 } |
| 598 } | 611 } |
| 599 | 612 |
| 600 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 613 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 601 #include "SkAnnotation.h" | 614 #include "SkAnnotation.h" |
| 602 | 615 |
| 603 static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) { | 616 static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) { |
| 604 SkDynamicMemoryWStream wstream; | 617 SkDynamicMemoryWStream wstream; |
| 605 src->serialize(&wstream); | 618 src->serialize(&wstream); |
| 606 SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream()); | 619 SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, | 683 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, |
| 671 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, | 684 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, |
| 672 }; | 685 }; |
| 673 | 686 |
| 674 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 687 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
| 675 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 688 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
| 676 | 689 |
| 677 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 690 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
| 678 canvas.drawPicture(pict1); | 691 canvas.drawPicture(pict1); |
| 679 } | 692 } |
| OLD | NEW |