Chromium Code Reviews| 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 <SkBitmapProcShader.h> | |
|
egdaniel
2016/06/21 14:37:30
why this top include?
reed1
2016/06/21 14:38:42
also, use "" instead of <>
dvonbeck
2016/06/21 14:47:55
Done. My bad! I thought I had fixed that.
| |
| 8 #include "Resources.h" | 9 #include "Resources.h" |
| 9 #include "SkAnnotationKeys.h" | 10 #include "SkAnnotationKeys.h" |
| 11 #include "SkBitmapProcShader.h" | |
| 10 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 11 #include "SkFixed.h" | 13 #include "SkFixed.h" |
| 12 #include "SkFontDescriptor.h" | 14 #include "SkFontDescriptor.h" |
| 13 #include "SkImage.h" | 15 #include "SkImage.h" |
| 14 #include "SkImageSource.h" | 16 #include "SkImageSource.h" |
| 15 #include "SkLightingShader.h" | 17 #include "SkLightingShader.h" |
| 16 #include "SkMallocPixelRef.h" | 18 #include "SkMallocPixelRef.h" |
| 17 #include "SkNormalSource.h" | 19 #include "SkNormalSource.h" |
| 18 #include "SkOSFile.h" | 20 #include "SkOSFile.h" |
| 19 #include "SkPictureRecorder.h" | 21 #include "SkPictureRecorder.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 | 574 |
| 573 SkMatrix matrix; | 575 SkMatrix matrix; |
| 574 SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSiz e)); | 576 SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSiz e)); |
| 575 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); | 577 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); |
| 576 | 578 |
| 577 SkVector invNormRotation = { SkScalarSqrt(0.3f), SkScalarSqrt(0.7f) }; | 579 SkVector invNormRotation = { SkScalarSqrt(0.3f), SkScalarSqrt(0.7f) }; |
| 578 SkBitmap normals; | 580 SkBitmap normals; |
| 579 normals.allocN32Pixels(kTexSize, kTexSize); | 581 normals.allocN32Pixels(kTexSize, kTexSize); |
| 580 | 582 |
| 581 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> diffuseShader = SkMakeBitmapShader(diffuse, SkShader::kC lamp_TileMode, | |
| 585 SkShader::kClamp_TileMode, &matrix, nullptr); | |
| 582 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeMap(normals, in vNormRotation, &matrix); | 586 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeMap(normals, in vNormRotation, &matrix); |
| 583 sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuse, fLights , &matrix, | 587 sk_sp<SkShader> lightingShader = SkLightingShader::Make(std::move(diffus eShader), |
| 584 std::move(normal Source)); | 588 std::move(normal Source), |
| 589 fLights); | |
| 585 | 590 |
| 586 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get() , true, reporter)); | 591 SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get() , true, reporter)); |
| 587 // TODO test equality? | 592 // TODO test equality? |
| 588 | 593 |
| 589 } | 594 } |
| 590 } | 595 } |
| 591 | 596 |
| 592 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 597 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
| 593 #include "SkAnnotation.h" | 598 #include "SkAnnotation.h" |
| 594 | 599 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, | 667 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, |
| 663 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, | 668 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, |
| 664 }; | 669 }; |
| 665 | 670 |
| 666 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 671 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
| 667 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 672 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
| 668 | 673 |
| 669 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 674 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
| 670 canvas.drawPicture(pict1); | 675 canvas.drawPicture(pict1); |
| 671 } | 676 } |
| OLD | NEW |