Exemplo n.º 1
0
 internal LayerContext(Invariants invariants, Layer previousLayer, Layer currentLayer, int currentLayerIndex)
 {
     m_invariants = invariants;
     PreviousLayer = previousLayer;
     CurrentLayer = currentLayer;
     CurrentLayerIndex = currentLayerIndex;
 }
 private LayerContext CreateFakeLayerContext(Layer backgroundLayer, IImageProvider backgroundImage, Layer layer)
 {
     var invariants = new LayerContext.Invariants(backgroundLayer, new MaybeTask<IImageProvider>(backgroundImage), new Size(0, 0));
     var layerContext = new LayerContext(invariants, backgroundLayer, layer, 1);
     layerContext.PreviousImage = layerContext.BackgroundImage;
     return layerContext;
 }
 private LayerContext CreateFakeLayerContext(Layer layer)
 {
     var backgroundImage = new ColorImageSource(BackgroundLayerSize, Colors.AliceBlue);
     var backgroundLayer = new Layer(LayerStyle.Normal(), backgroundImage, BackgroundLayerSize);
     var invariants = new LayerContext.Invariants(backgroundLayer, new MaybeTask<IImageProvider>(backgroundImage), new Size(0, 0));
     var layerContext = new LayerContext(invariants, backgroundLayer, layer, 1);
     layerContext.PreviousImage = layerContext.BackgroundImage;
     return layerContext;
 }
 public void LayerWithSpecifiedLayerStyleHasSpecifiedLayerStyleWhenCreatedWithLambdaReturningAsynchronousImageProvider()
 {
     var layer = new Layer(LayerStyle.Add(0.6), context => CreateTestImageProviderAsync(context));
     Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
     Assert.AreEqual(0.6, layer.Style.Opacity);
 }
 public void LayerWithSpecifiedLayerStyleHasSpecifiedLayerStyle()
 {
     var layer = new Layer(LayerStyle.Add(0.6), CreateTestImageProvider());
     Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
     Assert.AreEqual(0.6, layer.Style.Opacity);
 }
        public async Task GetImageProviderReturnsExpectedResultWhenCreatedWithLambdaReturningAsynchronousImageProvider()
        {
            var layer = new Layer(LayerStyle.Normal(), context => CreateTestImageProviderAsync(context));
            var imageProvider = layer.GetImageProvider(CreateFakeLayerContext(layer));
            Assert.IsFalse(imageProvider.WasSynchronous);
            var imageProviderResult = await imageProvider.AsTask();
            Assert.IsNotNull(imageProviderResult);

            var imageProviderInfo = await imageProvider.Result.GetInfoAsync();
            Assert.AreEqual(BackgroundLayerSize, imageProviderInfo.ImageSize);
        }
        public async Task GetImageProviderReturnsExpectedResult()
        {
            var layer = new Layer(LayerStyle.Normal(), CreateTestImageProvider());
            var imageProvider = layer.GetImageProvider(CreateFakeLayerContext(layer));
            Assert.IsTrue(imageProvider.IsSynchronous);
            Assert.IsNotNull(imageProvider.Result);

            var imageProviderInfo = await imageProvider.Result.GetInfoAsync();
            Assert.AreEqual(TestLayerSize, imageProviderInfo.ImageSize);
        }
 public void LayerWithSpecifiedImageSizeHasCorrectImageSizeWhenCreatedWithLambdaReturningAsynchronousImageProvider()
 {
     var layer = new Layer(LayerStyle.Normal(), context => CreateTestImageProviderAsync(context), new Size(75, 25));
     Assert.AreEqual(new Size(75, 25), layer.ImageSize);
 }
 public void LayerWithSpecifiedImageSizeHasCorrectImageSize()
 {
     var layer = new Layer(LayerStyle.Normal(), CreateTestImageProvider(), new Size(75,25));
     Assert.AreEqual(new Size(75, 25), layer.ImageSize);
 }
 public void LayerWithoutSpecifiedImageSizeHasZeroImageSize()
 {
     var layer = new Layer(LayerStyle.Normal(), CreateTestImageProvider());
     Assert.AreEqual(new Size(0, 0), layer.ImageSize);
 }
Exemplo n.º 11
0
 internal Invariants(Layer backgroundLayer, MaybeTask<IImageProvider> backgroundImage, Size renderSizeHint)
 {
     BackgroundLayer = backgroundLayer;
     BackgroundImage = backgroundImage;
     HintedRenderSize = renderSizeHint;
 }
        public async Task GetImageProviderReturnsExpectedResultWhenCreatedWithLambdaReturningAsynchronousImageProvider()
        {
            var backgroundImage = new ColorImageSource(BackgroundLayerSize, Colors.AliceBlue);
            var backgroundLayer = new Layer(LayerStyle.Normal(), backgroundImage, BackgroundLayerSize);

            var layer = new AdjustmentLayer(LayerStyle.Normal(), context => CreateTestEffectAsync(context));
            var imageProvider = layer.GetImageProvider(CreateFakeLayerContext(backgroundLayer, backgroundImage, layer));
            ((IImageConsumer)await imageProvider.AsTask()).Source = backgroundImage;
            Assert.IsFalse(imageProvider.WasSynchronous);
            var imageProviderResult = await imageProvider.AsTask();
            Assert.IsNotNull(imageProviderResult);

            var imageProviderInfo = await imageProvider.Result.GetInfoAsync();
            Assert.AreEqual(BackgroundLayerSize, imageProviderInfo.ImageSize);
        }
        public async Task GetImageProviderReturnsExpectedResultWhenCreatedWithAsynchronousImageProvider()
        {
            var backgroundImage = new ColorImageSource(BackgroundLayerSize, Colors.AliceBlue);
            var backgroundLayer = new Layer(LayerStyle.Normal(), backgroundImage, BackgroundLayerSize);

            var layer = new AdjustmentLayer(LayerStyle.Normal(), CreateTestEffectAsync());
            var imageProvider = layer.GetImageProvider(CreateFakeLayerContext(backgroundLayer, backgroundImage, layer));
            ((IImageConsumer)await imageProvider.AsTask()).Source = backgroundImage;
            Assert.IsFalse(imageProvider.WasSynchronous);
            var imageProviderResult = await imageProvider.AsTask();
            Assert.IsNotNull(imageProviderResult);

            var bitmapRenderer = new BitmapRenderer(imageProvider.Result);
            var bitmap = await bitmapRenderer.RenderAsync();
            Assert.AreEqual(BackgroundLayerSize, bitmap.Dimensions);
        }