/
IImageDecoder.h
34 lines (32 loc) · 1.46 KB
/
IImageDecoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include <ppltasks.h>
#include <d2d1_1.h>
class IImageDecoder
{
protected:
uint32_t _maxRenderDimension;
concurrency::task_completion_event<void> _readySource;
IImageDecoder()
{
#if WINDOWS_PHONE_APP
_maxRenderDimension = Windows::System::MemoryManager::AppMemoryUsageLimit > 300 * 1024 * 1024 ? 1024 : 400;
#elif UWP
_maxRenderDimension = Windows::System::MemoryManager::AppMemoryUsageLimit > 300 * 1024 * 1024 ? 1024 : 400;
#else
_maxRenderDimension = 2048;
#endif
}
public:
virtual void LoadHandler(Windows::Storage::Streams::IBuffer^ buffer, bool finished, uint32_t expectedSize) { /*default to doing nothing */ };
virtual concurrency::task<void> Ready() { return concurrency::task<void>(_readySource); }
virtual Windows::Foundation::Size MaxSize() = 0;
virtual Windows::Foundation::Size DefaultSize() = 0;
virtual void RenderSize(Windows::Foundation::Size size) = 0;
//handler is the rendered rect to invalidate
virtual concurrency::task<Windows::Foundation::Rect> DecodeRectangleAsync(Windows::Foundation::Rect requestedRect, Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2dContext) = 0;
virtual bool CanDecode(Windows::Foundation::Rect rect) = 0;
virtual Windows::Foundation::Rect DecodeRectangle(Windows::Foundation::Rect requestedRect, Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2dContext, Microsoft::WRL::ComPtr<ID2D1Bitmap1>& copyDestination, bool& requeue) = 0;
virtual void Suspend() = 0;
virtual void Resume() = 0;
virtual ~IImageDecoder() {}
};