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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 sk_sp<SkShader> lightingShader = SkLightingShader::Make(std::move(diffus eShader), |
591 std::move(normal Source), | 591 std::move(normal Source), |
592 fLights); | 592 fLights); |
593 | 593 |
594 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get() , true, reporter)); | 594 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get() , true, reporter)); |
595 // TODO test equality? | 595 // TODO test equality? |
596 | 596 |
597 } | 597 } |
598 | |
599 // Test NormalBevelSource serialization | |
600 { | |
601 sk_sp<SkNormalSource> bevelSource = SkNormalSource::MakeBevel( | |
602 SkNormalSource::BevelType::kLinear, 2.0f, 5.0f); | |
603 | |
604 SkAutoTUnref<SkNormalSource>(TestFlattenableSerialization(bevelSource.ge t(), true, | |
605 reporter)) ; | |
robertphillips
2016/07/11 19:13:21
Do we need to hard cast to a NormalBevelSourceImpl
dvonbeck
2016/07/13 14:23:38
Not that easy, because serializing/deserializing c
| |
606 // TODO test equality? | |
607 | |
608 } | |
598 } | 609 } |
599 | 610 |
600 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 611 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
601 #include "SkAnnotation.h" | 612 #include "SkAnnotation.h" |
602 | 613 |
603 static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) { | 614 static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) { |
604 SkDynamicMemoryWStream wstream; | 615 SkDynamicMemoryWStream wstream; |
605 src->serialize(&wstream); | 616 src->serialize(&wstream); |
606 SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream()); | 617 SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream()); |
607 return SkPicture::MakeFromStream(rstream); | 618 return SkPicture::MakeFromStream(rstream); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, | 681 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, |
671 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, | 682 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, |
672 }; | 683 }; |
673 | 684 |
674 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 685 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
675 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 686 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
676 | 687 |
677 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 688 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
678 canvas.drawPicture(pict1); | 689 canvas.drawPicture(pict1); |
679 } | 690 } |
OLD | NEW |