diff options
Diffstat (limited to 'source/3rd-party/SDL2/src/render')
45 files changed, 27494 insertions, 0 deletions
diff --git a/source/3rd-party/SDL2/src/render/SDL_d3dmath.c b/source/3rd-party/SDL2/src/render/SDL_d3dmath.c new file mode 100644 index 0000000..47eafb2 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_d3dmath.c @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED +#include "SDL_stdinc.h" + +#include "SDL_d3dmath.h" + +/* Direct3D matrix math functions */ + +Float4X4 MatrixIdentity() +{ + Float4X4 m; + SDL_zero(m); + m.v._11 = 1.0f; + m.v._22 = 1.0f; + m.v._33 = 1.0f; + m.v._44 = 1.0f; + return m; +} + +Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2) +{ + Float4X4 m; + m.v._11 = M1.v._11 * M2.v._11 + M1.v._12 * M2.v._21 + M1.v._13 * M2.v._31 + M1.v._14 * M2.v._41; + m.v._12 = M1.v._11 * M2.v._12 + M1.v._12 * M2.v._22 + M1.v._13 * M2.v._32 + M1.v._14 * M2.v._42; + m.v._13 = M1.v._11 * M2.v._13 + M1.v._12 * M2.v._23 + M1.v._13 * M2.v._33 + M1.v._14 * M2.v._43; + m.v._14 = M1.v._11 * M2.v._14 + M1.v._12 * M2.v._24 + M1.v._13 * M2.v._34 + M1.v._14 * M2.v._44; + m.v._21 = M1.v._21 * M2.v._11 + M1.v._22 * M2.v._21 + M1.v._23 * M2.v._31 + M1.v._24 * M2.v._41; + m.v._22 = M1.v._21 * M2.v._12 + M1.v._22 * M2.v._22 + M1.v._23 * M2.v._32 + M1.v._24 * M2.v._42; + m.v._23 = M1.v._21 * M2.v._13 + M1.v._22 * M2.v._23 + M1.v._23 * M2.v._33 + M1.v._24 * M2.v._43; + m.v._24 = M1.v._21 * M2.v._14 + M1.v._22 * M2.v._24 + M1.v._23 * M2.v._34 + M1.v._24 * M2.v._44; + m.v._31 = M1.v._31 * M2.v._11 + M1.v._32 * M2.v._21 + M1.v._33 * M2.v._31 + M1.v._34 * M2.v._41; + m.v._32 = M1.v._31 * M2.v._12 + M1.v._32 * M2.v._22 + M1.v._33 * M2.v._32 + M1.v._34 * M2.v._42; + m.v._33 = M1.v._31 * M2.v._13 + M1.v._32 * M2.v._23 + M1.v._33 * M2.v._33 + M1.v._34 * M2.v._43; + m.v._34 = M1.v._31 * M2.v._14 + M1.v._32 * M2.v._24 + M1.v._33 * M2.v._34 + M1.v._34 * M2.v._44; + m.v._41 = M1.v._41 * M2.v._11 + M1.v._42 * M2.v._21 + M1.v._43 * M2.v._31 + M1.v._44 * M2.v._41; + m.v._42 = M1.v._41 * M2.v._12 + M1.v._42 * M2.v._22 + M1.v._43 * M2.v._32 + M1.v._44 * M2.v._42; + m.v._43 = M1.v._41 * M2.v._13 + M1.v._42 * M2.v._23 + M1.v._43 * M2.v._33 + M1.v._44 * M2.v._43; + m.v._44 = M1.v._41 * M2.v._14 + M1.v._42 * M2.v._24 + M1.v._43 * M2.v._34 + M1.v._44 * M2.v._44; + return m; +} + +Float4X4 MatrixScaling(float x, float y, float z) +{ + Float4X4 m; + SDL_zero(m); + m.v._11 = x; + m.v._22 = y; + m.v._33 = z; + m.v._44 = 1.0f; + return m; +} + +Float4X4 MatrixTranslation(float x, float y, float z) +{ + Float4X4 m; + SDL_zero(m); + m.v._11 = 1.0f; + m.v._22 = 1.0f; + m.v._33 = 1.0f; + m.v._44 = 1.0f; + m.v._41 = x; + m.v._42 = y; + m.v._43 = z; + return m; +} + +Float4X4 MatrixRotationX(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m.v._11 = 1.0f; + m.v._22 = cosR; + m.v._23 = sinR; + m.v._32 = -sinR; + m.v._33 = cosR; + m.v._44 = 1.0f; + return m; +} + +Float4X4 MatrixRotationY(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m.v._11 = cosR; + m.v._13 = -sinR; + m.v._22 = 1.0f; + m.v._31 = sinR; + m.v._33 = cosR; + m.v._44 = 1.0f; + return m; +} + +Float4X4 MatrixRotationZ(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m.v._11 = cosR; + m.v._12 = sinR; + m.v._21 = -sinR; + m.v._22 = cosR; + m.v._33 = 1.0f; + m.v._44 = 1.0f; + return m; + +} + +#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/SDL_d3dmath.h b/source/3rd-party/SDL2/src/render/SDL_d3dmath.h new file mode 100644 index 0000000..8555a17 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_d3dmath.h @@ -0,0 +1,72 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED + +/* Direct3D matrix math functions */ + +typedef struct +{ + float x; + float y; +} Float2; + +typedef struct +{ + float x; + float y; + float z; +} Float3; + +typedef struct +{ + float x; + float y; + float z; + float w; +} Float4; + +typedef struct +{ + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + } v; + float m[4][4]; + }; +} Float4X4; + + +Float4X4 MatrixIdentity(); +Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2); +Float4X4 MatrixScaling(float x, float y, float z); +Float4X4 MatrixTranslation(float x, float y, float z); +Float4X4 MatrixRotationX(float r); +Float4X4 MatrixRotationY(float r); +Float4X4 MatrixRotationZ(float r); + +#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/SDL_render.c b/source/3rd-party/SDL2/src/render/SDL_render.c new file mode 100644 index 0000000..4985b16 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_render.c @@ -0,0 +1,2293 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +/* The SDL 2D rendering system */ + +#include "SDL_assert.h" +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_render.h" +#include "SDL_sysrender.h" +#include "software/SDL_render_sw_c.h" + + +#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" + +#define CHECK_RENDERER_MAGIC(renderer, retval) \ + SDL_assert(renderer && renderer->magic == &renderer_magic); \ + if (!renderer || renderer->magic != &renderer_magic) { \ + SDL_SetError("Invalid renderer"); \ + return retval; \ + } + +#define CHECK_TEXTURE_MAGIC(texture, retval) \ + SDL_assert(texture && texture->magic == &texture_magic); \ + if (!texture || texture->magic != &texture_magic) { \ + SDL_SetError("Invalid texture"); \ + return retval; \ + } + +/* Predefined blend modes */ +#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, \ + srcAlphaFactor, dstAlphaFactor, alphaOperation) \ + (SDL_BlendMode)(((Uint32)colorOperation << 0) | \ + ((Uint32)srcColorFactor << 4) | \ + ((Uint32)dstColorFactor << 8) | \ + ((Uint32)alphaOperation << 16) | \ + ((Uint32)srcAlphaFactor << 20) | \ + ((Uint32)dstAlphaFactor << 24)) + +#define SDL_BLENDMODE_NONE_FULL \ + SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, \ + SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD) + +#define SDL_BLENDMODE_BLEND_FULL \ + SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \ + SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD) + +#define SDL_BLENDMODE_ADD_FULL \ + SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \ + SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD) + +#define SDL_BLENDMODE_MOD_FULL \ + SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \ + SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD) + +#if !SDL_RENDER_DISABLED +static const SDL_RenderDriver *render_drivers[] = { +#if SDL_VIDEO_RENDER_D3D + &D3D_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_D3D11 + &D3D11_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL + &GL_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL_ES2 + &GLES2_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL_ES + &GLES_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_DIRECTFB + &DirectFB_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_METAL + &METAL_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_PSP + &PSP_RenderDriver, +#endif + &SW_RenderDriver +}; +#endif /* !SDL_RENDER_DISABLED */ + +static char renderer_magic; +static char texture_magic; + +static int UpdateLogicalSize(SDL_Renderer *renderer); + +int +SDL_GetNumRenderDrivers(void) +{ +#if !SDL_RENDER_DISABLED + return SDL_arraysize(render_drivers); +#else + return 0; +#endif +} + +int +SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) +{ +#if !SDL_RENDER_DISABLED + if (index < 0 || index >= SDL_GetNumRenderDrivers()) { + return SDL_SetError("index must be in the range of 0 - %d", + SDL_GetNumRenderDrivers() - 1); + } + *info = render_drivers[index]->info; + return 0; +#else + return SDL_SetError("SDL not built with rendering support"); +#endif +} + +static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_Rect *viewport, SDL_FPoint *scale) +{ + SDL_LockMutex(renderer->target_mutex); + *logical_w = renderer->target ? renderer->logical_w_backup : renderer->logical_w; + *logical_h = renderer->target ? renderer->logical_h_backup : renderer->logical_h; + *viewport = renderer->target ? renderer->viewport_backup : renderer->viewport; + *scale = renderer->target ? renderer->scale_backup : renderer->scale; + SDL_UnlockMutex(renderer->target_mutex); +} + +static int SDLCALL +SDL_RendererEventWatch(void *userdata, SDL_Event *event) +{ + SDL_Renderer *renderer = (SDL_Renderer *)userdata; + + if (event->type == SDL_WINDOWEVENT) { + SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); + if (window == renderer->window) { + if (renderer->WindowEvent) { + renderer->WindowEvent(renderer, &event->window); + } + + if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Make sure we're operating on the default render target */ + SDL_Texture *saved_target = SDL_GetRenderTarget(renderer); + if (saved_target) { + SDL_SetRenderTarget(renderer, NULL); + } + + if (renderer->logical_w) { + UpdateLogicalSize(renderer); + } else { + /* Window was resized, reset viewport */ + int w, h; + + if (renderer->GetOutputSize) { + renderer->GetOutputSize(renderer, &w, &h); + } else { + SDL_GetWindowSize(renderer->window, &w, &h); + } + + if (renderer->target) { + renderer->viewport_backup.x = 0; + renderer->viewport_backup.y = 0; + renderer->viewport_backup.w = w; + renderer->viewport_backup.h = h; + } else { + renderer->viewport.x = 0; + renderer->viewport.y = 0; + renderer->viewport.w = w; + renderer->viewport.h = h; + renderer->UpdateViewport(renderer); + } + } + + if (saved_target) { + SDL_SetRenderTarget(renderer, saved_target); + } + } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) { + renderer->hidden = SDL_TRUE; + } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) { + if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) { + renderer->hidden = SDL_FALSE; + } + } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + renderer->hidden = SDL_TRUE; + } else if (event->window.event == SDL_WINDOWEVENT_RESTORED || + event->window.event == SDL_WINDOWEVENT_MAXIMIZED) { + if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) { + renderer->hidden = SDL_FALSE; + } + } + } + } else if (event->type == SDL_MOUSEMOTION) { + SDL_Window *window = SDL_GetWindowFromID(event->motion.windowID); + if (window == renderer->window) { + int logical_w, logical_h; + SDL_Rect viewport; + SDL_FPoint scale; + GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale); + if (logical_w) { + event->motion.x -= (int)(viewport.x * renderer->dpi_scale.x); + event->motion.y -= (int)(viewport.y * renderer->dpi_scale.y); + event->motion.x = (int)(event->motion.x / (scale.x * renderer->dpi_scale.x)); + event->motion.y = (int)(event->motion.y / (scale.y * renderer->dpi_scale.y)); + if (event->motion.xrel > 0) { + event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / (scale.x * renderer->dpi_scale.x))); + } else if (event->motion.xrel < 0) { + event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / (scale.x * renderer->dpi_scale.x))); + } + if (event->motion.yrel > 0) { + event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / (scale.y * renderer->dpi_scale.y))); + } else if (event->motion.yrel < 0) { + event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / (scale.y * renderer->dpi_scale.y))); + } + } + } + } else if (event->type == SDL_MOUSEBUTTONDOWN || + event->type == SDL_MOUSEBUTTONUP) { + SDL_Window *window = SDL_GetWindowFromID(event->button.windowID); + if (window == renderer->window) { + int logical_w, logical_h; + SDL_Rect viewport; + SDL_FPoint scale; + GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale); + if (logical_w) { + event->button.x -= (int)(viewport.x * renderer->dpi_scale.x); + event->button.y -= (int)(viewport.y * renderer->dpi_scale.y); + event->button.x = (int)(event->button.x / (scale.x * renderer->dpi_scale.x)); + event->button.y = (int)(event->button.y / (scale.y * renderer->dpi_scale.y)); + } + } + } else if (event->type == SDL_FINGERDOWN || + event->type == SDL_FINGERUP || + event->type == SDL_FINGERMOTION) { + int logical_w, logical_h; + SDL_Rect viewport; + SDL_FPoint scale; + GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale); + if (logical_w) { + int w = 1; + int h = 1; + SDL_GetRendererOutputSize(renderer, &w, &h); + + event->tfinger.x *= (w - 1); + event->tfinger.y *= (h - 1); + + event->tfinger.x -= (viewport.x * renderer->dpi_scale.x); + event->tfinger.y -= (viewport.y * renderer->dpi_scale.y); + event->tfinger.x = (event->tfinger.x / (scale.x * renderer->dpi_scale.x)); + event->tfinger.y = (event->tfinger.y / (scale.y * renderer->dpi_scale.y)); + + if (logical_w > 1) { + event->tfinger.x = event->tfinger.x / (logical_w - 1); + } else { + event->tfinger.x = 0.5f; + } + if (logical_h > 1) { + event->tfinger.y = event->tfinger.y / (logical_h - 1); + } else { + event->tfinger.y = 0.5f; + } + } + } + + return 0; +} + +int +SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer) +{ + *window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + width, height, window_flags); + if (!*window) { + *renderer = NULL; + return -1; + } + + *renderer = SDL_CreateRenderer(*window, -1, 0); + if (!*renderer) { + return -1; + } + + return 0; +} + +SDL_Renderer * +SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) +{ +#if !SDL_RENDER_DISABLED + SDL_Renderer *renderer = NULL; + int n = SDL_GetNumRenderDrivers(); + const char *hint; + + if (!window) { + SDL_SetError("Invalid window"); + return NULL; + } + + if (SDL_GetRenderer(window)) { + SDL_SetError("Renderer already associated with window"); + return NULL; + } + + if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) { + if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) { + flags |= SDL_RENDERER_PRESENTVSYNC; + } else { + flags &= ~SDL_RENDERER_PRESENTVSYNC; + } + } + + if (index < 0) { + hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + if (hint) { + for (index = 0; index < n; ++index) { + const SDL_RenderDriver *driver = render_drivers[index]; + + if (SDL_strcasecmp(hint, driver->info.name) == 0) { + /* Create a new renderer instance */ + renderer = driver->CreateRenderer(window, flags); + break; + } + } + } + + if (!renderer) { + for (index = 0; index < n; ++index) { + const SDL_RenderDriver *driver = render_drivers[index]; + + if ((driver->info.flags & flags) == flags) { + /* Create a new renderer instance */ + renderer = driver->CreateRenderer(window, flags); + if (renderer) { + /* Yay, we got one! */ + break; + } + } + } + } + if (index == n) { + SDL_SetError("Couldn't find matching render driver"); + return NULL; + } + } else { + if (index >= SDL_GetNumRenderDrivers()) { + SDL_SetError("index must be -1 or in the range of 0 - %d", + SDL_GetNumRenderDrivers() - 1); + return NULL; + } + /* Create a new renderer instance */ + renderer = render_drivers[index]->CreateRenderer(window, flags); + } + + if (renderer) { + renderer->magic = &renderer_magic; + renderer->window = window; + renderer->target_mutex = SDL_CreateMutex(); + renderer->scale.x = 1.0f; + renderer->scale.y = 1.0f; + renderer->dpi_scale.x = 1.0f; + renderer->dpi_scale.y = 1.0f; + + if (window && renderer->GetOutputSize) { + int window_w, window_h; + int output_w, output_h; + if (renderer->GetOutputSize(renderer, &output_w, &output_h) == 0) { + SDL_GetWindowSize(renderer->window, &window_w, &window_h); + renderer->dpi_scale.x = (float)window_w / output_w; + renderer->dpi_scale.y = (float)window_h / output_h; + } + } + + if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) { + renderer->hidden = SDL_TRUE; + } else { + renderer->hidden = SDL_FALSE; + } + + SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer); + + SDL_RenderSetViewport(renderer, NULL); + + SDL_AddEventWatch(SDL_RendererEventWatch, renderer); + + SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, + "Created renderer: %s", renderer->info.name); + } + return renderer; +#else + SDL_SetError("SDL not built with rendering support"); + return NULL; +#endif +} + +SDL_Renderer * +SDL_CreateSoftwareRenderer(SDL_Surface * surface) +{ +#if !SDL_RENDER_DISABLED + SDL_Renderer *renderer; + + renderer = SW_CreateRendererForSurface(surface); + + if (renderer) { + renderer->magic = &renderer_magic; + renderer->target_mutex = SDL_CreateMutex(); + renderer->scale.x = 1.0f; + renderer->scale.y = 1.0f; + + SDL_RenderSetViewport(renderer, NULL); + } + return renderer; +#else + SDL_SetError("SDL not built with rendering support"); + return NULL; +#endif /* !SDL_RENDER_DISABLED */ +} + +SDL_Renderer * +SDL_GetRenderer(SDL_Window * window) +{ + return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA); +} + +int +SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + *info = renderer->info; + return 0; +} + +int +SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (renderer->target) { + return SDL_QueryTexture(renderer->target, NULL, NULL, w, h); + } else if (renderer->GetOutputSize) { + return renderer->GetOutputSize(renderer, w, h); + } else if (renderer->window) { + SDL_GetWindowSize(renderer->window, w, h); + return 0; + } else { + SDL_assert(0 && "This should never happen"); + return SDL_SetError("Renderer doesn't support querying output size"); + } +} + +static SDL_bool +IsSupportedBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + switch (blendMode) + { + /* These are required to be supported by all renderers */ + case SDL_BLENDMODE_NONE: + case SDL_BLENDMODE_BLEND: + case SDL_BLENDMODE_ADD: + case SDL_BLENDMODE_MOD: + return SDL_TRUE; + + default: + return renderer->SupportsBlendMode && renderer->SupportsBlendMode(renderer, blendMode); + } +} + +static SDL_bool +IsSupportedFormat(SDL_Renderer * renderer, Uint32 format) +{ + Uint32 i; + + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (renderer->info.texture_formats[i] == format) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +static Uint32 +GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format) +{ + Uint32 i; + + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + /* Look for an exact match */ + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (renderer->info.texture_formats[i] == format) { + return renderer->info.texture_formats[i]; + } + } + } else { + SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); + + /* We just want to match the first format that has the same channels */ + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && + SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) { + return renderer->info.texture_formats[i]; + } + } + } + return renderer->info.texture_formats[0]; +} + + +static SDL_ScaleMode SDL_GetScaleMode(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); + + if (!hint || SDL_strcasecmp(hint, "nearest") == 0) { + return SDL_ScaleModeNearest; + } else if (SDL_strcasecmp(hint, "linear") == 0) { + return SDL_ScaleModeLinear; + } else if (SDL_strcasecmp(hint, "best") == 0) { + return SDL_ScaleModeBest; + } else { + return (SDL_ScaleMode)SDL_atoi(hint); + } +} + +SDL_Texture * +SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) +{ + SDL_Texture *texture; + + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (!format) { + format = renderer->info.texture_formats[0]; + } + if (SDL_BYTESPERPIXEL(format) == 0) { + SDL_SetError("Invalid texture format"); + return NULL; + } + if (SDL_ISPIXELFORMAT_INDEXED(format)) { + SDL_SetError("Palettized textures are not supported"); + return NULL; + } + if (w <= 0 || h <= 0) { + SDL_SetError("Texture dimensions can't be 0"); + return NULL; + } + if ((renderer->info.max_texture_width && w > renderer->info.max_texture_width) || + (renderer->info.max_texture_height && h > renderer->info.max_texture_height)) { + SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height); + return NULL; + } + texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); + if (!texture) { + SDL_OutOfMemory(); + return NULL; + } + texture->magic = &texture_magic; + texture->format = format; + texture->access = access; + texture->w = w; + texture->h = h; + texture->r = 255; + texture->g = 255; + texture->b = 255; + texture->a = 255; + texture->scaleMode = SDL_GetScaleMode(); + texture->renderer = renderer; + texture->next = renderer->textures; + if (renderer->textures) { + renderer->textures->prev = texture; + } + renderer->textures = texture; + + if (IsSupportedFormat(renderer, format)) { + if (renderer->CreateTexture(renderer, texture) < 0) { + SDL_DestroyTexture(texture); + return NULL; + } + } else { + texture->native = SDL_CreateTexture(renderer, + GetClosestSupportedFormat(renderer, format), + access, w, h); + if (!texture->native) { + SDL_DestroyTexture(texture); + return NULL; + } + + /* Swap textures to have texture before texture->native in the list */ + texture->native->next = texture->next; + if (texture->native->next) { + texture->native->next->prev = texture->native; + } + texture->prev = texture->native->prev; + if (texture->prev) { + texture->prev->next = texture; + } + texture->native->prev = texture; + texture->next = texture->native; + renderer->textures = texture; + + if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { + texture->yuv = SDL_SW_CreateYUVTexture(format, w, h); + if (!texture->yuv) { + SDL_DestroyTexture(texture); + return NULL; + } + } else if (access == SDL_TEXTUREACCESS_STREAMING) { + /* The pitch is 4 byte aligned */ + texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3); + texture->pixels = SDL_calloc(1, texture->pitch * h); + if (!texture->pixels) { + SDL_DestroyTexture(texture); + return NULL; + } + } + } + return texture; +} + +SDL_Texture * +SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) +{ + const SDL_PixelFormat *fmt; + SDL_bool needAlpha; + Uint32 i; + Uint32 format; + SDL_Texture *texture; + + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (!surface) { + SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); + return NULL; + } + + /* See what the best texture format is */ + fmt = surface->format; + if (fmt->Amask || SDL_HasColorKey(surface)) { + needAlpha = SDL_TRUE; + } else { + needAlpha = SDL_FALSE; + } + format = renderer->info.texture_formats[0]; + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && + SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { + format = renderer->info.texture_formats[i]; + break; + } + } + + texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, + surface->w, surface->h); + if (!texture) { + return NULL; + } + + if (format == surface->format->format) { + if (SDL_MUSTLOCK(surface)) { + SDL_LockSurface(surface); + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); + SDL_UnlockSurface(surface); + } else { + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); + } + } else { + SDL_PixelFormat *dst_fmt; + SDL_Surface *temp = NULL; + + /* Set up a destination surface for the texture update */ + dst_fmt = SDL_AllocFormat(format); + if (!dst_fmt) { + SDL_DestroyTexture(texture); + return NULL; + } + temp = SDL_ConvertSurface(surface, dst_fmt, 0); + SDL_FreeFormat(dst_fmt); + if (temp) { + SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); + SDL_FreeSurface(temp); + } else { + SDL_DestroyTexture(texture); + return NULL; + } + } + + { + Uint8 r, g, b, a; + SDL_BlendMode blendMode; + + SDL_GetSurfaceColorMod(surface, &r, &g, &b); + SDL_SetTextureColorMod(texture, r, g, b); + + SDL_GetSurfaceAlphaMod(surface, &a); + SDL_SetTextureAlphaMod(texture, a); + + if (SDL_HasColorKey(surface)) { + /* We converted to a texture with alpha format */ + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + } else { + SDL_GetSurfaceBlendMode(surface, &blendMode); + SDL_SetTextureBlendMode(texture, blendMode); + } + } + return texture; +} + +int +SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, + int *w, int *h) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (format) { + *format = texture->format; + } + if (access) { + *access = texture->access; + } + if (w) { + *w = texture->w; + } + if (h) { + *h = texture->h; + } + return 0; +} + +int +SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (r < 255 || g < 255 || b < 255) { + texture->modMode |= SDL_TEXTUREMODULATE_COLOR; + } else { + texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; + } + texture->r = r; + texture->g = g; + texture->b = b; + if (texture->native) { + return SDL_SetTextureColorMod(texture->native, r, g, b); + } else if (renderer->SetTextureColorMod) { + return renderer->SetTextureColorMod(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, + Uint8 * b) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (r) { + *r = texture->r; + } + if (g) { + *g = texture->g; + } + if (b) { + *b = texture->b; + } + return 0; +} + +int +SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (alpha < 255) { + texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; + } else { + texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; + } + texture->a = alpha; + if (texture->native) { + return SDL_SetTextureAlphaMod(texture->native, alpha); + } else if (renderer->SetTextureAlphaMod) { + return renderer->SetTextureAlphaMod(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (alpha) { + *alpha = texture->a; + } + return 0; +} + +int +SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (!IsSupportedBlendMode(renderer, blendMode)) { + return SDL_Unsupported(); + } + texture->blendMode = blendMode; + if (texture->native) { + return SDL_SetTextureBlendMode(texture->native, blendMode); + } else if (renderer->SetTextureBlendMode) { + return renderer->SetTextureBlendMode(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (blendMode) { + *blendMode = texture->blendMode; + } + return 0; +} + +static int +SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels = NULL; + int native_pitch = 0; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + const size_t alloclen = rect->h * temp_pitch; + if (alloclen > 0) { + void *temp_pixels = SDL_malloc(alloclen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + } + return 0; +} + +static int +SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Texture *native = texture->native; + + if (!rect->w || !rect->h) { + return 0; /* nothing to do. */ + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels = NULL; + int native_pitch = 0; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + const size_t alloclen = rect->h * temp_pitch; + if (alloclen > 0) { + void *temp_pixels = SDL_malloc(alloclen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + } + return 0; +} + +int +SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!pixels) { + return SDL_InvalidParamError("pixels"); + } + if (!pitch) { + return SDL_InvalidParamError("pitch"); + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if ((rect->w == 0) || (rect->h == 0)) { + return 0; /* nothing to do. */ + } else if (texture->yuv) { + return SDL_UpdateTextureYUV(texture, rect, pixels, pitch); + } else if (texture->native) { + return SDL_UpdateTextureNative(texture, rect, pixels, pitch); + } else { + renderer = texture->renderer; + return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); + } +} + +static int +SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateYUVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (!rect->w || !rect->h) { + return 0; /* nothing to do. */ + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels = NULL; + int native_pitch = 0; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + const size_t alloclen = rect->h * temp_pitch; + if (alloclen > 0) { + void *temp_pixels = SDL_malloc(alloclen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + } + return 0; +} + +int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!Yplane) { + return SDL_InvalidParamError("Yplane"); + } + if (!Ypitch) { + return SDL_InvalidParamError("Ypitch"); + } + if (!Uplane) { + return SDL_InvalidParamError("Uplane"); + } + if (!Upitch) { + return SDL_InvalidParamError("Upitch"); + } + if (!Vplane) { + return SDL_InvalidParamError("Vplane"); + } + if (!Vpitch) { + return SDL_InvalidParamError("Vpitch"); + } + + if (texture->format != SDL_PIXELFORMAT_YV12 && + texture->format != SDL_PIXELFORMAT_IYUV) { + return SDL_SetError("Texture format must by YV12 or IYUV"); + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (!rect->w || !rect->h) { + return 0; /* nothing to do. */ + } + + if (texture->yuv) { + return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + SDL_assert(!texture->native); + renderer = texture->renderer; + SDL_assert(renderer->UpdateTextureYUV); + if (renderer->UpdateTextureYUV) { + return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + return SDL_Unsupported(); + } + } +} + +static int +SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch); +} + +static int +SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + texture->locked_rect = *rect; + *pixels = (void *) ((Uint8 *) texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = texture->pitch; + return 0; +} + +int +SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (texture->access != SDL_TEXTUREACCESS_STREAMING) { + return SDL_SetError("SDL_LockTexture(): texture must be streaming"); + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (texture->yuv) { + return SDL_LockTextureYUV(texture, rect, pixels, pitch); + } else if (texture->native) { + return SDL_LockTextureNative(texture, rect, pixels, pitch); + } else { + renderer = texture->renderer; + return renderer->LockTexture(renderer, texture, rect, pixels, pitch); + } +} + +static void +SDL_UnlockTextureYUV(SDL_Texture * texture) +{ + SDL_Texture *native = texture->native; + void *native_pixels = NULL; + int native_pitch = 0; + SDL_Rect rect; + + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + + if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) { + return; + } + SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format, + rect.w, rect.h, native_pixels, native_pitch); + SDL_UnlockTexture(native); +} + +static void +SDL_UnlockTextureNative(SDL_Texture * texture) +{ + SDL_Texture *native = texture->native; + void *native_pixels = NULL; + int native_pitch = 0; + const SDL_Rect *rect = &texture->locked_rect; + const void* pixels = (void *) ((Uint8 *) texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + int pitch = texture->pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return; + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, native_pixels, native_pitch); + SDL_UnlockTexture(native); +} + +void +SDL_UnlockTexture(SDL_Texture * texture) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, ); + + if (texture->access != SDL_TEXTUREACCESS_STREAMING) { + return; + } + if (texture->yuv) { + SDL_UnlockTextureYUV(texture); + } else if (texture->native) { + SDL_UnlockTextureNative(texture); + } else { + renderer = texture->renderer; + renderer->UnlockTexture(renderer, texture); + } +} + +SDL_bool +SDL_RenderTargetSupported(SDL_Renderer *renderer) +{ + if (!renderer || !renderer->SetRenderTarget) { + return SDL_FALSE; + } + return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; +} + +int +SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + if (!SDL_RenderTargetSupported(renderer)) { + return SDL_Unsupported(); + } + if (texture == renderer->target) { + /* Nothing to do! */ + return 0; + } + + /* texture == NULL is valid and means reset the target to the window */ + if (texture) { + CHECK_TEXTURE_MAGIC(texture, -1); + if (renderer != texture->renderer) { + return SDL_SetError("Texture was not created with this renderer"); + } + if (texture->access != SDL_TEXTUREACCESS_TARGET) { + return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET"); + } + if (texture->native) { + /* Always render to the native texture */ + texture = texture->native; + } + } + + SDL_LockMutex(renderer->target_mutex); + + if (texture && !renderer->target) { + /* Make a backup of the viewport */ + renderer->viewport_backup = renderer->viewport; + renderer->clip_rect_backup = renderer->clip_rect; + renderer->clipping_enabled_backup = renderer->clipping_enabled; + renderer->scale_backup = renderer->scale; + renderer->logical_w_backup = renderer->logical_w; + renderer->logical_h_backup = renderer->logical_h; + } + renderer->target = texture; + + if (renderer->SetRenderTarget(renderer, texture) < 0) { + SDL_UnlockMutex(renderer->target_mutex); + return -1; + } + + if (texture) { + renderer->viewport.x = 0; + renderer->viewport.y = 0; + renderer->viewport.w = texture->w; + renderer->viewport.h = texture->h; + SDL_zero(renderer->clip_rect); + renderer->clipping_enabled = SDL_FALSE; + renderer->scale.x = 1.0f; + renderer->scale.y = 1.0f; + renderer->logical_w = texture->w; + renderer->logical_h = texture->h; + } else { + renderer->viewport = renderer->viewport_backup; + renderer->clip_rect = renderer->clip_rect_backup; + renderer->clipping_enabled = renderer->clipping_enabled_backup; + renderer->scale = renderer->scale_backup; + renderer->logical_w = renderer->logical_w_backup; + renderer->logical_h = renderer->logical_h_backup; + } + + SDL_UnlockMutex(renderer->target_mutex); + + if (renderer->UpdateViewport(renderer) < 0) { + return -1; + } + if (renderer->UpdateClipRect(renderer) < 0) { + return -1; + } + + /* All set! */ + return 0; +} + +SDL_Texture * +SDL_GetRenderTarget(SDL_Renderer *renderer) +{ + return renderer->target; +} + +static int +UpdateLogicalSize(SDL_Renderer *renderer) +{ + int w = 1, h = 1; + float want_aspect; + float real_aspect; + float scale; + SDL_Rect viewport; + /* 0 is for letterbox, 1 is for overscan */ + int scale_policy = 0; + const char *hint; + + if (!renderer->logical_w || !renderer->logical_h) { + return 0; + } + if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) { + return -1; + } + + hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE); + if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) { +#if SDL_VIDEO_RENDER_D3D + SDL_bool overscan_supported = SDL_TRUE; + /* Unfortunately, Direct3D 9 doesn't support negative viewport numbers + which the overscan implementation relies on. + */ + if (SDL_strcasecmp(SDL_GetCurrentVideoDriver(), "direct3d") == 0) { + overscan_supported = SDL_FALSE; + } + if (overscan_supported) { + scale_policy = 1; + } +#else + scale_policy = 1; +#endif + } + + want_aspect = (float)renderer->logical_w / renderer->logical_h; + real_aspect = (float)w / h; + + /* Clear the scale because we're setting viewport in output coordinates */ + SDL_RenderSetScale(renderer, 1.0f, 1.0f); + + if (renderer->integer_scale) { + if (want_aspect > real_aspect) { + scale = (float)(w / renderer->logical_w); + } else { + scale = (float)(h / renderer->logical_h); + } + viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.x = (w - viewport.w) / 2; + viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.y = (h - viewport.h) / 2; + + SDL_RenderSetViewport(renderer, &viewport); + } else if (SDL_fabs(want_aspect-real_aspect) < 0.0001) { + /* The aspect ratios are the same, just scale appropriately */ + scale = (float)w / renderer->logical_w; + SDL_RenderSetViewport(renderer, NULL); + } else if (want_aspect > real_aspect) { + if (scale_policy == 1) { + /* We want a wider aspect ratio than is available - + zoom so logical height matches the real height + and the width will grow off the screen + */ + scale = (float)h / renderer->logical_h; + viewport.y = 0; + viewport.h = h; + viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.x = (w - viewport.w) / 2; + SDL_RenderSetViewport(renderer, &viewport); + } else { + /* We want a wider aspect ratio than is available - letterbox it */ + scale = (float)w / renderer->logical_w; + viewport.x = 0; + viewport.w = w; + viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.y = (h - viewport.h) / 2; + SDL_RenderSetViewport(renderer, &viewport); + } + } else { + if (scale_policy == 1) { + /* We want a narrower aspect ratio than is available - + zoom so logical width matches the real width + and the height will grow off the screen + */ + scale = (float)w / renderer->logical_w; + viewport.x = 0; + viewport.w = w; + viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.y = (h - viewport.h) / 2; + SDL_RenderSetViewport(renderer, &viewport); + } else { + /* We want a narrower aspect ratio than is available - use side-bars */ + scale = (float)h / renderer->logical_h; + viewport.y = 0; + viewport.h = h; + viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.x = (w - viewport.w) / 2; + SDL_RenderSetViewport(renderer, &viewport); + } + } + + /* Set the new scale */ + SDL_RenderSetScale(renderer, scale, scale); + + return 0; +} + +int +SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!w || !h) { + /* Clear any previous logical resolution */ + renderer->logical_w = 0; + renderer->logical_h = 0; + SDL_RenderSetViewport(renderer, NULL); + SDL_RenderSetScale(renderer, 1.0f, 1.0f); + return 0; + } + + renderer->logical_w = w; + renderer->logical_h = h; + + return UpdateLogicalSize(renderer); +} + +void +SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + if (w) { + *w = renderer->logical_w; + } + if (h) { + *h = renderer->logical_h; + } +} + +int +SDL_RenderSetIntegerScale(SDL_Renderer * renderer, SDL_bool enable) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + renderer->integer_scale = enable; + + return UpdateLogicalSize(renderer); +} + +SDL_bool +SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, SDL_FALSE); + + return renderer->integer_scale; +} + +int +SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (rect) { + renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x); + renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y); + renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x); + renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y); + } else { + renderer->viewport.x = 0; + renderer->viewport.y = 0; + if (SDL_GetRendererOutputSize(renderer, &renderer->viewport.w, &renderer->viewport.h) < 0) { + return -1; + } + } + return renderer->UpdateViewport(renderer); +} + +void +SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + if (rect) { + rect->x = (int)(renderer->viewport.x / renderer->scale.x); + rect->y = (int)(renderer->viewport.y / renderer->scale.y); + rect->w = (int)(renderer->viewport.w / renderer->scale.x); + rect->h = (int)(renderer->viewport.h / renderer->scale.y); + } +} + +int +SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, -1) + + if (rect) { + renderer->clipping_enabled = SDL_TRUE; + renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x); + renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y); + renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x); + renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y); + } else { + renderer->clipping_enabled = SDL_FALSE; + SDL_zero(renderer->clip_rect); + } + return renderer->UpdateClipRect(renderer); +} + +void +SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, ) + + if (rect) { + rect->x = (int)(renderer->clip_rect.x / renderer->scale.x); + rect->y = (int)(renderer->clip_rect.y / renderer->scale.y); + rect->w = (int)(renderer->clip_rect.w / renderer->scale.x); + rect->h = (int)(renderer->clip_rect.h / renderer->scale.y); + } +} + +SDL_bool +SDL_RenderIsClipEnabled(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, SDL_FALSE) + return renderer->clipping_enabled; +} + +int +SDL_RenderSetScale(SDL_Renderer * renderer, float scaleX, float scaleY) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + renderer->scale.x = scaleX; + renderer->scale.y = scaleY; + return 0; +} + +void +SDL_RenderGetScale(SDL_Renderer * renderer, float *scaleX, float *scaleY) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + if (scaleX) { + *scaleX = renderer->scale.x; + } + if (scaleY) { + *scaleY = renderer->scale.y; + } +} + +int +SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + renderer->r = r; + renderer->g = g; + renderer->b = b; + renderer->a = a; + return 0; +} + +int +SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (r) { + *r = renderer->r; + } + if (g) { + *g = renderer->g; + } + if (b) { + *b = renderer->b; + } + if (a) { + *a = renderer->a; + } + return 0; +} + +int +SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!IsSupportedBlendMode(renderer, blendMode)) { + return SDL_Unsupported(); + } + renderer->blendMode = blendMode; + return 0; +} + +int +SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + *blendMode = renderer->blendMode; + return 0; +} + +int +SDL_RenderClear(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + return renderer->RenderClear(renderer); +} + +int +SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y) +{ + SDL_Point point; + + point.x = x; + point.y = y; + return SDL_RenderDrawPoints(renderer, &point, 1); +} + +static int +RenderDrawPointsWithRects(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + SDL_FRect *frects; + int i; + int status; + + frects = SDL_stack_alloc(SDL_FRect, count); + if (!frects) { + return SDL_OutOfMemory(); + } + for (i = 0; i < count; ++i) { + frects[i].x = points[i].x * renderer->scale.x; + frects[i].y = points[i].y * renderer->scale.y; + frects[i].w = renderer->scale.x; + frects[i].h = renderer->scale.y; + } + + status = renderer->RenderFillRects(renderer, frects, count); + + SDL_stack_free(frects); + + return status; +} + +int +SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + SDL_FPoint *fpoints; + int i; + int status; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!points) { + return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points"); + } + if (count < 1) { + return 0; + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { + return RenderDrawPointsWithRects(renderer, points, count); + } + + fpoints = SDL_stack_alloc(SDL_FPoint, count); + if (!fpoints) { + return SDL_OutOfMemory(); + } + for (i = 0; i < count; ++i) { + fpoints[i].x = points[i].x * renderer->scale.x; + fpoints[i].y = points[i].y * renderer->scale.y; + } + + status = renderer->RenderDrawPoints(renderer, fpoints, count); + + SDL_stack_free(fpoints); + + return status; +} + +int +SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) +{ + SDL_Point points[2]; + + points[0].x = x1; + points[0].y = y1; + points[1].x = x2; + points[1].y = y2; + return SDL_RenderDrawLines(renderer, points, 2); +} + +static int +RenderDrawLinesWithRects(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + SDL_FRect *frect; + SDL_FRect *frects; + SDL_FPoint fpoints[2]; + int i, nrects; + int status; + + frects = SDL_stack_alloc(SDL_FRect, count-1); + if (!frects) { + return SDL_OutOfMemory(); + } + + status = 0; + nrects = 0; + for (i = 0; i < count-1; ++i) { + if (points[i].x == points[i+1].x) { + int minY = SDL_min(points[i].y, points[i+1].y); + int maxY = SDL_max(points[i].y, points[i+1].y); + + frect = &frects[nrects++]; + frect->x = points[i].x * renderer->scale.x; + frect->y = minY * renderer->scale.y; + frect->w = renderer->scale.x; + frect->h = (maxY - minY + 1) * renderer->scale.y; + } else if (points[i].y == points[i+1].y) { + int minX = SDL_min(points[i].x, points[i+1].x); + int maxX = SDL_max(points[i].x, points[i+1].x); + + frect = &frects[nrects++]; + frect->x = minX * renderer->scale.x; + frect->y = points[i].y * renderer->scale.y; + frect->w = (maxX - minX + 1) * renderer->scale.x; + frect->h = renderer->scale.y; + } else { + /* FIXME: We can't use a rect for this line... */ + fpoints[0].x = points[i].x * renderer->scale.x; + fpoints[0].y = points[i].y * renderer->scale.y; + fpoints[1].x = points[i+1].x * renderer->scale.x; + fpoints[1].y = points[i+1].y * renderer->scale.y; + status += renderer->RenderDrawLines(renderer, fpoints, 2); + } + } + + status += renderer->RenderFillRects(renderer, frects, nrects); + + SDL_stack_free(frects); + + if (status < 0) { + status = -1; + } + return status; +} + +int +SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + SDL_FPoint *fpoints; + int i; + int status; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!points) { + return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points"); + } + if (count < 2) { + return 0; + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { + return RenderDrawLinesWithRects(renderer, points, count); + } + + fpoints = SDL_stack_alloc(SDL_FPoint, count); + if (!fpoints) { + return SDL_OutOfMemory(); + } + for (i = 0; i < count; ++i) { + fpoints[i].x = points[i].x * renderer->scale.x; + fpoints[i].y = points[i].y * renderer->scale.y; + } + + status = renderer->RenderDrawLines(renderer, fpoints, count); + + SDL_stack_free(fpoints); + + return status; +} + +int +SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + SDL_Rect full_rect; + SDL_Point points[5]; + + CHECK_RENDERER_MAGIC(renderer, -1); + + /* If 'rect' == NULL, then outline the whole surface */ + if (!rect) { + SDL_RenderGetViewport(renderer, &full_rect); + full_rect.x = 0; + full_rect.y = 0; + rect = &full_rect; + } + + points[0].x = rect->x; + points[0].y = rect->y; + points[1].x = rect->x+rect->w-1; + points[1].y = rect->y; + points[2].x = rect->x+rect->w-1; + points[2].y = rect->y+rect->h-1; + points[3].x = rect->x; + points[3].y = rect->y+rect->h-1; + points[4].x = rect->x; + points[4].y = rect->y; + return SDL_RenderDrawLines(renderer, points, 5); +} + +int +SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count) +{ + int i; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!rects) { + return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects"); + } + if (count < 1) { + return 0; + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + for (i = 0; i < count; ++i) { + if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) { + return -1; + } + } + return 0; +} + +int +SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + SDL_Rect full_rect = { 0, 0, 0, 0 }; + + CHECK_RENDERER_MAGIC(renderer, -1); + + /* If 'rect' == NULL, then outline the whole surface */ + if (!rect) { + SDL_RenderGetViewport(renderer, &full_rect); + full_rect.x = 0; + full_rect.y = 0; + rect = &full_rect; + } + return SDL_RenderFillRects(renderer, rect, 1); +} + +int +SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count) +{ + SDL_FRect *frects; + int i; + int status; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!rects) { + return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects"); + } + if (count < 1) { + return 0; + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + frects = SDL_stack_alloc(SDL_FRect, count); + if (!frects) { + return SDL_OutOfMemory(); + } + for (i = 0; i < count; ++i) { + frects[i].x = rects[i].x * renderer->scale.x; + frects[i].y = rects[i].y * renderer->scale.y; + frects[i].w = rects[i].w * renderer->scale.x; + frects[i].h = rects[i].h * renderer->scale.y; + } + + status = renderer->RenderFillRects(renderer, frects, count); + + SDL_stack_free(frects); + + return status; +} + +int +SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + SDL_Rect real_srcrect = { 0, 0, 0, 0 }; + SDL_Rect real_dstrect = { 0, 0, 0, 0 }; + SDL_FRect frect; + + CHECK_RENDERER_MAGIC(renderer, -1); + CHECK_TEXTURE_MAGIC(texture, -1); + + if (renderer != texture->renderer) { + return SDL_SetError("Texture was not created with this renderer"); + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + real_srcrect.x = 0; + real_srcrect.y = 0; + real_srcrect.w = texture->w; + real_srcrect.h = texture->h; + if (srcrect) { + if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { + return 0; + } + } + + SDL_RenderGetViewport(renderer, &real_dstrect); + real_dstrect.x = 0; + real_dstrect.y = 0; + if (dstrect) { + if (!SDL_HasIntersection(dstrect, &real_dstrect)) { + return 0; + } + real_dstrect = *dstrect; + } + + if (texture->native) { + texture = texture->native; + } + + frect.x = real_dstrect.x * renderer->scale.x; + frect.y = real_dstrect.y * renderer->scale.y; + frect.w = real_dstrect.w * renderer->scale.x; + frect.h = real_dstrect.h * renderer->scale.y; + + return renderer->RenderCopy(renderer, texture, &real_srcrect, &frect); +} + + +int +SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect, + const double angle, const SDL_Point *center, const SDL_RendererFlip flip) +{ + SDL_Rect real_srcrect = { 0, 0, 0, 0 }; + SDL_Rect real_dstrect = { 0, 0, 0, 0 }; + SDL_Point real_center; + SDL_FRect frect; + SDL_FPoint fcenter; + + if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */ + return SDL_RenderCopy(renderer, texture, srcrect, dstrect); + } + + CHECK_RENDERER_MAGIC(renderer, -1); + CHECK_TEXTURE_MAGIC(texture, -1); + + if (renderer != texture->renderer) { + return SDL_SetError("Texture was not created with this renderer"); + } + if (!renderer->RenderCopyEx) { + return SDL_SetError("Renderer does not support RenderCopyEx"); + } + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return 0; + } + + real_srcrect.x = 0; + real_srcrect.y = 0; + real_srcrect.w = texture->w; + real_srcrect.h = texture->h; + if (srcrect) { + if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { + return 0; + } + } + + /* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */ + if (dstrect) { + real_dstrect = *dstrect; + } else { + SDL_RenderGetViewport(renderer, &real_dstrect); + real_dstrect.x = 0; + real_dstrect.y = 0; + } + + if (texture->native) { + texture = texture->native; + } + + if (center) { + real_center = *center; + } else { + real_center.x = real_dstrect.w/2; + real_center.y = real_dstrect.h/2; + } + + frect.x = real_dstrect.x * renderer->scale.x; + frect.y = real_dstrect.y * renderer->scale.y; + frect.w = real_dstrect.w * renderer->scale.x; + frect.h = real_dstrect.h * renderer->scale.y; + + fcenter.x = real_center.x * renderer->scale.x; + fcenter.y = real_center.y * renderer->scale.y; + + return renderer->RenderCopyEx(renderer, texture, &real_srcrect, &frect, angle, &fcenter, flip); +} + +int +SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + SDL_Rect real_rect; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!renderer->RenderReadPixels) { + return SDL_Unsupported(); + } + + if (!format) { + format = SDL_GetWindowPixelFormat(renderer->window); + } + + real_rect.x = renderer->viewport.x; + real_rect.y = renderer->viewport.y; + real_rect.w = renderer->viewport.w; + real_rect.h = renderer->viewport.h; + if (rect) { + if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { + return 0; + } + if (real_rect.y > rect->y) { + pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y); + } + if (real_rect.x > rect->x) { + int bpp = SDL_BYTESPERPIXEL(format); + pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x); + } + } + + return renderer->RenderReadPixels(renderer, &real_rect, + format, pixels, pitch); +} + +void +SDL_RenderPresent(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + /* Don't draw while we're hidden */ + if (renderer->hidden) { + return; + } + renderer->RenderPresent(renderer); +} + +void +SDL_DestroyTexture(SDL_Texture * texture) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, ); + + renderer = texture->renderer; + if (texture == renderer->target) { + SDL_SetRenderTarget(renderer, NULL); + } + + texture->magic = NULL; + + if (texture->next) { + texture->next->prev = texture->prev; + } + if (texture->prev) { + texture->prev->next = texture->next; + } else { + renderer->textures = texture->next; + } + + if (texture->native) { + SDL_DestroyTexture(texture->native); + } + if (texture->yuv) { + SDL_SW_DestroyYUVTexture(texture->yuv); + } + SDL_free(texture->pixels); + + renderer->DestroyTexture(renderer, texture); + SDL_free(texture); +} + +void +SDL_DestroyRenderer(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + SDL_DelEventWatch(SDL_RendererEventWatch, renderer); + + /* Free existing textures for this renderer */ + while (renderer->textures) { + SDL_Texture *tex = renderer->textures; (void) tex; + SDL_DestroyTexture(renderer->textures); + SDL_assert(tex != renderer->textures); /* satisfy static analysis. */ + } + + if (renderer->window) { + SDL_SetWindowData(renderer->window, SDL_WINDOWRENDERDATA, NULL); + } + + /* It's no longer magical... */ + renderer->magic = NULL; + + /* Free the target mutex */ + SDL_DestroyMutex(renderer->target_mutex); + renderer->target_mutex = NULL; + + /* Free the renderer instance */ + renderer->DestroyRenderer(renderer); +} + +int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + renderer = texture->renderer; + if (texture->native) { + return SDL_GL_BindTexture(texture->native, texw, texh); + } else if (renderer && renderer->GL_BindTexture) { + return renderer->GL_BindTexture(renderer, texture, texw, texh); + } else { + return SDL_Unsupported(); + } +} + +int SDL_GL_UnbindTexture(SDL_Texture *texture) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + renderer = texture->renderer; + if (texture->native) { + return SDL_GL_UnbindTexture(texture->native); + } else if (renderer && renderer->GL_UnbindTexture) { + return renderer->GL_UnbindTexture(renderer, texture); + } + + return SDL_Unsupported(); +} + +void * +SDL_RenderGetMetalLayer(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (renderer->GetMetalLayer) { + return renderer->GetMetalLayer(renderer); + } + return NULL; +} + +void * +SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (renderer->GetMetalCommandEncoder) { + return renderer->GetMetalCommandEncoder(renderer); + } + return NULL; +} + +static SDL_BlendMode +SDL_GetShortBlendMode(SDL_BlendMode blendMode) +{ + if (blendMode == SDL_BLENDMODE_NONE_FULL) { + return SDL_BLENDMODE_NONE; + } + if (blendMode == SDL_BLENDMODE_BLEND_FULL) { + return SDL_BLENDMODE_BLEND; + } + if (blendMode == SDL_BLENDMODE_ADD_FULL) { + return SDL_BLENDMODE_ADD; + } + if (blendMode == SDL_BLENDMODE_MOD_FULL) { + return SDL_BLENDMODE_MOD; + } + return blendMode; +} + +static SDL_BlendMode +SDL_GetLongBlendMode(SDL_BlendMode blendMode) +{ + if (blendMode == SDL_BLENDMODE_NONE) { + return SDL_BLENDMODE_NONE_FULL; + } + if (blendMode == SDL_BLENDMODE_BLEND) { + return SDL_BLENDMODE_BLEND_FULL; + } + if (blendMode == SDL_BLENDMODE_ADD) { + return SDL_BLENDMODE_ADD_FULL; + } + if (blendMode == SDL_BLENDMODE_MOD) { + return SDL_BLENDMODE_MOD_FULL; + } + return blendMode; +} + +SDL_BlendMode +SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, + SDL_BlendOperation colorOperation, + SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, + SDL_BlendOperation alphaOperation) +{ + SDL_BlendMode blendMode = SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, + srcAlphaFactor, dstAlphaFactor, alphaOperation); + return SDL_GetShortBlendMode(blendMode); +} + +SDL_BlendFactor +SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendFactor)(((Uint32)blendMode >> 4) & 0xF); +} + +SDL_BlendFactor +SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendFactor)(((Uint32)blendMode >> 8) & 0xF); +} + +SDL_BlendOperation +SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendOperation)(((Uint32)blendMode >> 0) & 0xF); +} + +SDL_BlendFactor +SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendFactor)(((Uint32)blendMode >> 20) & 0xF); +} + +SDL_BlendFactor +SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendFactor)(((Uint32)blendMode >> 24) & 0xF); +} + +SDL_BlendOperation +SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode) +{ + blendMode = SDL_GetLongBlendMode(blendMode); + return (SDL_BlendOperation)(((Uint32)blendMode >> 16) & 0xF); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/SDL_sysrender.h b/source/3rd-party/SDL2/src/render/SDL_sysrender.h new file mode 100644 index 0000000..940bebc --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_sysrender.h @@ -0,0 +1,214 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +#ifndef SDL_sysrender_h_ +#define SDL_sysrender_h_ + +#include "SDL_render.h" +#include "SDL_events.h" +#include "SDL_mutex.h" +#include "SDL_yuv_sw_c.h" + +/* The SDL 2D rendering system */ + +typedef struct SDL_RenderDriver SDL_RenderDriver; + +typedef enum +{ + SDL_ScaleModeNearest, + SDL_ScaleModeLinear, + SDL_ScaleModeBest +} SDL_ScaleMode; + +typedef struct +{ + float x; + float y; +} SDL_FPoint; + +typedef struct +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + +/* Define the SDL texture structure */ +struct SDL_Texture +{ + const void *magic; + Uint32 format; /**< The pixel format of the texture */ + int access; /**< SDL_TextureAccess */ + int w; /**< The width of the texture */ + int h; /**< The height of the texture */ + int modMode; /**< The texture modulation mode */ + SDL_BlendMode blendMode; /**< The texture blend mode */ + SDL_ScaleMode scaleMode; /**< The texture scale mode */ + Uint8 r, g, b, a; /**< Texture modulation values */ + + SDL_Renderer *renderer; + + /* Support for formats not supported directly by the renderer */ + SDL_Texture *native; + SDL_SW_YUVTexture *yuv; + void *pixels; + int pitch; + SDL_Rect locked_rect; + + void *driverdata; /**< Driver specific texture representation */ + + SDL_Texture *prev; + SDL_Texture *next; +}; + +/* Define the SDL renderer structure */ +struct SDL_Renderer +{ + const void *magic; + + void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event); + int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h); + SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode); + int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*SetTextureColorMod) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*SetTextureAlphaMod) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*SetTextureBlendMode) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); + int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); + void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*UpdateViewport) (SDL_Renderer * renderer); + int (*UpdateClipRect) (SDL_Renderer * renderer); + int (*RenderClear) (SDL_Renderer * renderer); + int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points, + int count); + int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points, + int count); + int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects, + int count); + int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); + int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcquad, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); + int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); + void (*RenderPresent) (SDL_Renderer * renderer); + void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + + void (*DestroyRenderer) (SDL_Renderer * renderer); + + int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); + int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture); + + void *(*GetMetalLayer) (SDL_Renderer * renderer); + void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer); + + /* The current renderer info */ + SDL_RendererInfo info; + + /* The window associated with the renderer */ + SDL_Window *window; + SDL_bool hidden; + + /* The logical resolution for rendering */ + int logical_w; + int logical_h; + int logical_w_backup; + int logical_h_backup; + + /* Whether or not to force the viewport to even integer intervals */ + SDL_bool integer_scale; + + /* The drawable area within the window */ + SDL_Rect viewport; + SDL_Rect viewport_backup; + + /* The clip rectangle within the window */ + SDL_Rect clip_rect; + SDL_Rect clip_rect_backup; + + /* Wether or not the clipping rectangle is used. */ + SDL_bool clipping_enabled; + SDL_bool clipping_enabled_backup; + + /* The render output coordinate scale */ + SDL_FPoint scale; + SDL_FPoint scale_backup; + + /* The pixel to point coordinate scale */ + SDL_FPoint dpi_scale; + + /* The list of textures */ + SDL_Texture *textures; + SDL_Texture *target; + SDL_mutex *target_mutex; + + Uint8 r, g, b, a; /**< Color for drawing operations values */ + SDL_BlendMode blendMode; /**< The drawing blend mode */ + + void *driverdata; +}; + +/* Define the SDL render driver structure */ +struct SDL_RenderDriver +{ + SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); + + /* Info about the renderer capabilities */ + SDL_RendererInfo info; +}; + +/* Not all of these are available in a given build. Use #ifdefs, etc. */ +extern SDL_RenderDriver D3D_RenderDriver; +extern SDL_RenderDriver D3D11_RenderDriver; +extern SDL_RenderDriver GL_RenderDriver; +extern SDL_RenderDriver GLES2_RenderDriver; +extern SDL_RenderDriver GLES_RenderDriver; +extern SDL_RenderDriver DirectFB_RenderDriver; +extern SDL_RenderDriver METAL_RenderDriver; +extern SDL_RenderDriver PSP_RenderDriver; +extern SDL_RenderDriver SW_RenderDriver; + +/* Blend mode functions */ +extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode); +extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode); +extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode); +extern SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode); +extern SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode); +extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode); + +#endif /* SDL_sysrender_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/SDL_yuv_sw.c b/source/3rd-party/SDL2/src/render/SDL_yuv_sw.c new file mode 100644 index 0000000..c227cdc --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_yuv_sw.c @@ -0,0 +1,414 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +/* This is the software implementation of the YUV texture support */ + +#include "SDL_assert.h" + +#include "SDL_yuv_sw_c.h" + + +SDL_SW_YUVTexture * +SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) +{ + SDL_SW_YUVTexture *swdata; + + switch (format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + break; + default: + SDL_SetError("Unsupported YUV format"); + return NULL; + } + + swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata)); + if (!swdata) { + SDL_OutOfMemory(); + return NULL; + } + + swdata->format = format; + swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; + swdata->w = w; + swdata->h = h; + { + const int sz_plane = w * h; + const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2); + const int sz_plane_packed = ((w + 1) / 2) * h; + int dst_size = 0; + switch(format) + { + case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */ + case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */ + dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; + break; + + case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + dst_size = 4 * sz_plane_packed; + break; + + case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */ + case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */ + dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; + break; + + default: + SDL_assert(0 && "We should never get here (caught above)"); + break; + } + swdata->pixels = (Uint8 *) SDL_malloc(dst_size); + if (!swdata->pixels) { + SDL_SW_DestroyYUVTexture(swdata); + SDL_OutOfMemory(); + return NULL; + } + } + + /* Find the pitch and offset values for the texture */ + switch (format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + swdata->pitches[0] = w; + swdata->pitches[1] = (swdata->pitches[0] + 1) / 2; + swdata->pitches[2] = (swdata->pitches[0] + 1) / 2; + swdata->planes[0] = swdata->pixels; + swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h; + swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * ((h + 1) / 2); + break; + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + swdata->pitches[0] = ((w + 1) / 2) * 4; + swdata->planes[0] = swdata->pixels; + break; + + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + swdata->pitches[0] = w; + swdata->pitches[1] = 2 * ((swdata->pitches[0] + 1) / 2); + swdata->planes[0] = swdata->pixels; + swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h; + break; + + default: + SDL_assert(0 && "We should never get here (caught above)"); + break; + } + + /* We're all done.. */ + return (swdata); +} + +int +SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, + int *pitch) +{ + *pixels = swdata->planes[0]; + *pitch = swdata->pitches[0]; + return 0; +} + +int +SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + switch (swdata->format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + if (rect->x == 0 && rect->y == 0 && + rect->w == swdata->w && rect->h == swdata->h) { + SDL_memcpy(swdata->pixels, pixels, + (swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2)); + } else { + Uint8 *src, *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = (Uint8 *) pixels; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += swdata->w; + } + + /* Copy the next plane */ + src = (Uint8 *) pixels + rect->h * pitch; + dst = swdata->pixels + swdata->h * swdata->w; + dst += rect->y/2 * ((swdata->w + 1) / 2) + rect->x/2; + length = (rect->w + 1) / 2; + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += (pitch + 1)/2; + dst += (swdata->w + 1)/2; + } + + /* Copy the next plane */ + src = (Uint8 *) pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2); + dst = swdata->pixels + swdata->h * swdata->w + + ((swdata->h + 1)/2) * ((swdata->w+1) / 2); + dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + length = (rect->w + 1) / 2; + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += (pitch + 1)/2; + dst += (swdata->w + 1)/2; + } + } + break; + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + { + Uint8 *src, *dst; + int row; + size_t length; + + src = (Uint8 *) pixels; + dst = + swdata->planes[0] + rect->y * swdata->pitches[0] + + rect->x * 2; + length = 4 * ((rect->w + 1) / 2); + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += swdata->pitches[0]; + } + } + break; + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + { + if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) { + SDL_memcpy(swdata->pixels, pixels, + (swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2)); + } else { + + Uint8 *src, *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = (Uint8 *) pixels; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += swdata->w; + } + + /* Copy the next plane */ + src = (Uint8 *) pixels + rect->h * pitch; + dst = swdata->pixels + swdata->h * swdata->w; + dst += 2 * ((rect->y + 1)/2) * ((swdata->w + 1) / 2) + 2 * (rect->x/2); + length = 2 * ((rect->w + 1) / 2); + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += 2 * ((pitch + 1)/2); + dst += 2 * ((swdata->w + 1)/2); + } + } + } + } + return 0; +} + +int +SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + const Uint8 *src; + Uint8 *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = Yplane; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += Ypitch; + dst += swdata->w; + } + + /* Copy the U plane */ + src = Uplane; + if (swdata->format == SDL_PIXELFORMAT_IYUV) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2); + } + dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + length = (rect->w + 1) / 2; + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += Upitch; + dst += (swdata->w + 1)/2; + } + + /* Copy the V plane */ + src = Vplane; + if (swdata->format == SDL_PIXELFORMAT_YV12) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2); + } + dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + length = (rect->w + 1) / 2; + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += Vpitch; + dst += (swdata->w + 1)/2; + } + return 0; +} + +int +SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + switch (swdata->format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + if (rect + && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w + || rect->h != swdata->h)) { + return SDL_SetError + ("YV12, IYUV, NV12, NV21 textures only support full surface locks"); + } + break; + } + + if (rect) { + *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2; + } else { + *pixels = swdata->planes[0]; + } + *pitch = swdata->pitches[0]; + return 0; +} + +void +SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata) +{ +} + +int +SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, + Uint32 target_format, int w, int h, void *pixels, + int pitch) +{ + int stretch; + + /* Make sure we're set up to display in the desired format */ + if (target_format != swdata->target_format && swdata->display) { + SDL_FreeSurface(swdata->display); + swdata->display = NULL; + } + + stretch = 0; + if (srcrect->x || srcrect->y || srcrect->w < swdata->w || srcrect->h < swdata->h) { + /* The source rectangle has been clipped. + Using a scratch surface is easier than adding clipped + source support to all the blitters, plus that would + slow them down in the general unclipped case. + */ + stretch = 1; + } else if ((srcrect->w != w) || (srcrect->h != h)) { + stretch = 1; + } + if (stretch) { + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + if (swdata->display) { + swdata->display->w = w; + swdata->display->h = h; + swdata->display->pixels = pixels; + swdata->display->pitch = pitch; + } else { + /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */ + SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, + &Bmask, &Amask); + swdata->display = + SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, + Gmask, Bmask, Amask); + if (!swdata->display) { + return (-1); + } + } + if (!swdata->stretch) { + /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */ + SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, + &Bmask, &Amask); + swdata->stretch = + SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask, + Gmask, Bmask, Amask); + if (!swdata->stretch) { + return (-1); + } + } + pixels = swdata->stretch->pixels; + pitch = swdata->stretch->pitch; + } + if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format, + swdata->planes[0], swdata->pitches[0], + target_format, pixels, pitch) < 0) { + return -1; + } + if (stretch) { + SDL_Rect rect = *srcrect; + SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL); + } + return 0; +} + +void +SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) +{ + if (swdata) { + SDL_free(swdata->pixels); + SDL_FreeSurface(swdata->stretch); + SDL_FreeSurface(swdata->display); + SDL_free(swdata); + } +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/SDL_yuv_sw_c.h b/source/3rd-party/SDL2/src/render/SDL_yuv_sw_c.h new file mode 100644 index 0000000..34322f2 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/SDL_yuv_sw_c.h @@ -0,0 +1,73 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_yuv_sw_c_h_ +#define SDL_yuv_sw_c_h_ + +#include "../SDL_internal.h" + +#include "SDL_video.h" + +/* This is the software implementation of the YUV texture support */ + +struct SDL_SW_YUVTexture +{ + Uint32 format; + Uint32 target_format; + int w, h; + Uint8 *pixels; + + /* These are just so we don't have to allocate them separately */ + Uint16 pitches[3]; + Uint8 *planes[3]; + + /* This is a temporary surface in case we have to stretch copy */ + SDL_Surface *stretch; + SDL_Surface *display; +}; + +typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture; + +SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h); +int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, + int *pitch); +int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const void *pixels, int pitch); +int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + void **pixels, int *pitch); +void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); +int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, + Uint32 target_format, int w, int h, void *pixels, + int pitch); +void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata); + +/* FIXME: This breaks on various versions of GCC and should be rewritten using intrinsics */ +#if 0 /* (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES && !defined(__clang__) */ +#define USE_MMX_ASSEMBLY 1 +#endif + +#endif /* SDL_yuv_sw_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d/SDL_render_d3d.c b/source/3rd-party/SDL2/src/render/direct3d/SDL_render_d3d.c new file mode 100644 index 0000000..69a9dff --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d/SDL_render_d3d.c @@ -0,0 +1,1813 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "SDL_render.h" +#include "SDL_system.h" + +#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_syswm.h" +#include "../SDL_sysrender.h" +#include "../SDL_d3dmath.h" +#include "../../video/windows/SDL_windowsvideo.h" + +#if SDL_VIDEO_RENDER_D3D +#define D3D_DEBUG_INFO +#include <d3d9.h> +#endif + +#include "SDL_shaders_d3d.h" + + +/* Direct3D renderer implementation */ + +static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); +static void D3D_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static SDL_bool D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_UpdateViewport(SDL_Renderer * renderer); +static int D3D_UpdateClipRect(SDL_Renderer * renderer); +static int D3D_RenderClear(SDL_Renderer * renderer); +static int D3D_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip); +static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static void D3D_RenderPresent(SDL_Renderer * renderer); +static void D3D_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void D3D_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver D3D_RenderDriver = { + D3D_CreateRenderer, + { + "direct3d", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 1, + {SDL_PIXELFORMAT_ARGB8888}, + 0, + 0} +}; + +typedef struct +{ + void* d3dDLL; + IDirect3D9 *d3d; + IDirect3DDevice9 *device; + UINT adapter; + D3DPRESENT_PARAMETERS pparams; + SDL_bool updateSize; + SDL_bool beginScene; + SDL_bool enableSeparateAlphaBlend; + D3DTEXTUREFILTERTYPE scaleMode[8]; + IDirect3DSurface9 *defaultRenderTarget; + IDirect3DSurface9 *currentRenderTarget; + void* d3dxDLL; + LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS]; +} D3D_RenderData; + +typedef struct +{ + SDL_bool dirty; + int w, h; + DWORD usage; + Uint32 format; + D3DFORMAT d3dfmt; + IDirect3DTexture9 *texture; + IDirect3DTexture9 *staging; +} D3D_TextureRep; + +typedef struct +{ + D3D_TextureRep texture; + D3DTEXTUREFILTERTYPE scaleMode; + + /* YV12 texture support */ + SDL_bool yuv; + D3D_TextureRep utexture; + D3D_TextureRep vtexture; + Uint8 *pixels; + int pitch; + SDL_Rect locked_rect; +} D3D_TextureData; + +typedef struct +{ + float x, y, z; + DWORD color; + float u, v; +} Vertex; + +static int +D3D_SetError(const char *prefix, HRESULT result) +{ + const char *error; + + switch (result) { + case D3DERR_WRONGTEXTUREFORMAT: + error = "WRONGTEXTUREFORMAT"; + break; + case D3DERR_UNSUPPORTEDCOLOROPERATION: + error = "UNSUPPORTEDCOLOROPERATION"; + break; + case D3DERR_UNSUPPORTEDCOLORARG: + error = "UNSUPPORTEDCOLORARG"; + break; + case D3DERR_UNSUPPORTEDALPHAOPERATION: + error = "UNSUPPORTEDALPHAOPERATION"; + break; + case D3DERR_UNSUPPORTEDALPHAARG: + error = "UNSUPPORTEDALPHAARG"; + break; + case D3DERR_TOOMANYOPERATIONS: + error = "TOOMANYOPERATIONS"; + break; + case D3DERR_CONFLICTINGTEXTUREFILTER: + error = "CONFLICTINGTEXTUREFILTER"; + break; + case D3DERR_UNSUPPORTEDFACTORVALUE: + error = "UNSUPPORTEDFACTORVALUE"; + break; + case D3DERR_CONFLICTINGRENDERSTATE: + error = "CONFLICTINGRENDERSTATE"; + break; + case D3DERR_UNSUPPORTEDTEXTUREFILTER: + error = "UNSUPPORTEDTEXTUREFILTER"; + break; + case D3DERR_CONFLICTINGTEXTUREPALETTE: + error = "CONFLICTINGTEXTUREPALETTE"; + break; + case D3DERR_DRIVERINTERNALERROR: + error = "DRIVERINTERNALERROR"; + break; + case D3DERR_NOTFOUND: + error = "NOTFOUND"; + break; + case D3DERR_MOREDATA: + error = "MOREDATA"; + break; + case D3DERR_DEVICELOST: + error = "DEVICELOST"; + break; + case D3DERR_DEVICENOTRESET: + error = "DEVICENOTRESET"; + break; + case D3DERR_NOTAVAILABLE: + error = "NOTAVAILABLE"; + break; + case D3DERR_OUTOFVIDEOMEMORY: + error = "OUTOFVIDEOMEMORY"; + break; + case D3DERR_INVALIDDEVICE: + error = "INVALIDDEVICE"; + break; + case D3DERR_INVALIDCALL: + error = "INVALIDCALL"; + break; + case D3DERR_DRIVERINVALIDCALL: + error = "DRIVERINVALIDCALL"; + break; + case D3DERR_WASSTILLDRAWING: + error = "WASSTILLDRAWING"; + break; + default: + error = "UNKNOWN"; + break; + } + return SDL_SetError("%s: %s", prefix, error); +} + +static D3DFORMAT +PixelFormatToD3DFMT(Uint32 format) +{ + switch (format) { + case SDL_PIXELFORMAT_RGB565: + return D3DFMT_R5G6B5; + case SDL_PIXELFORMAT_RGB888: + return D3DFMT_X8R8G8B8; + case SDL_PIXELFORMAT_ARGB8888: + return D3DFMT_A8R8G8B8; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + return D3DFMT_L8; + default: + return D3DFMT_UNKNOWN; + } +} + +static Uint32 +D3DFMTToPixelFormat(D3DFORMAT format) +{ + switch (format) { + case D3DFMT_R5G6B5: + return SDL_PIXELFORMAT_RGB565; + case D3DFMT_X8R8G8B8: + return SDL_PIXELFORMAT_RGB888; + case D3DFMT_A8R8G8B8: + return SDL_PIXELFORMAT_ARGB8888; + default: + return SDL_PIXELFORMAT_UNKNOWN; + } +} + +static void +D3D_InitRenderState(D3D_RenderData *data) +{ + D3DMATRIX matrix; + + IDirect3DDevice9 *device = data->device; + + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE); + IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE); + IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + + /* Enable color modulation by diffuse color */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, + D3DTA_DIFFUSE); + + /* Enable alpha modulation by diffuse alpha */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2, + D3DTA_DIFFUSE); + + /* Enable separate alpha blend function, if possible */ + if (data->enableSeparateAlphaBlend) { + IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); + } + + /* Disable second texture stage, since we're done */ + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, + D3DTOP_DISABLE); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP, + D3DTOP_DISABLE); + + /* Set an identity world and view matrix */ + matrix.m[0][0] = 1.0f; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = 1.0f; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = 0.0f; + matrix.m[3][1] = 0.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix); + IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix); + + /* Reset our current scale mode */ + SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); + + /* Start the render with beginScene */ + data->beginScene = SDL_TRUE; +} + +static int +D3D_Reset(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + HRESULT result; + SDL_Texture *texture; + + /* Release the default render target before reset */ + if (data->defaultRenderTarget) { + IDirect3DSurface9_Release(data->defaultRenderTarget); + data->defaultRenderTarget = NULL; + } + if (data->currentRenderTarget != NULL) { + IDirect3DSurface9_Release(data->currentRenderTarget); + data->currentRenderTarget = NULL; + } + + /* Release application render targets */ + for (texture = renderer->textures; texture; texture = texture->next) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + D3D_DestroyTexture(renderer, texture); + } else { + D3D_RecreateTexture(renderer, texture); + } + } + + result = IDirect3DDevice9_Reset(data->device, &data->pparams); + if (FAILED(result)) { + if (result == D3DERR_DEVICELOST) { + /* Don't worry about it, we'll reset later... */ + return 0; + } else { + return D3D_SetError("Reset()", result); + } + } + + /* Allocate application render targets */ + for (texture = renderer->textures; texture; texture = texture->next) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + D3D_CreateTexture(renderer, texture); + } + } + + IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); + D3D_InitRenderState(data); + D3D_SetRenderTargetInternal(renderer, renderer->target); + D3D_UpdateViewport(renderer); + + /* Let the application know that render targets were reset */ + { + SDL_Event event; + event.type = SDL_RENDER_TARGETS_RESET; + SDL_PushEvent(&event); + } + + return 0; +} + +static int +D3D_ActivateRenderer(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + HRESULT result; + + if (data->updateSize) { + SDL_Window *window = renderer->window; + int w, h; + Uint32 window_flags = SDL_GetWindowFlags(window); + + SDL_GetWindowSize(window, &w, &h); + data->pparams.BackBufferWidth = w; + data->pparams.BackBufferHeight = h; + if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { + SDL_DisplayMode fullscreen_mode; + SDL_GetWindowDisplayMode(window, &fullscreen_mode); + data->pparams.Windowed = FALSE; + data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format); + data->pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate; + } else { + data->pparams.Windowed = TRUE; + data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; + data->pparams.FullScreen_RefreshRateInHz = 0; + } + if (D3D_Reset(renderer) < 0) { + return -1; + } + + data->updateSize = SDL_FALSE; + } + if (data->beginScene) { + result = IDirect3DDevice9_BeginScene(data->device); + if (result == D3DERR_DEVICELOST) { + if (D3D_Reset(renderer) < 0) { + return -1; + } + result = IDirect3DDevice9_BeginScene(data->device); + } + if (FAILED(result)) { + return D3D_SetError("BeginScene()", result); + } + data->beginScene = SDL_FALSE; + } + return 0; +} + +SDL_Renderer * +D3D_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + D3D_RenderData *data; + SDL_SysWMinfo windowinfo; + HRESULT result; + D3DPRESENT_PARAMETERS pparams; + IDirect3DSwapChain9 *chain; + D3DCAPS9 caps; + DWORD device_flags; + Uint32 window_flags; + int w, h; + SDL_DisplayMode fullscreen_mode; + int displayIndex; + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(renderer); + SDL_OutOfMemory(); + return NULL; + } + + if (!D3D_LoadDLL(&data->d3dDLL, &data->d3d)) { + SDL_free(renderer); + SDL_free(data); + SDL_SetError("Unable to create Direct3D interface"); + return NULL; + } + + renderer->WindowEvent = D3D_WindowEvent; + renderer->SupportsBlendMode = D3D_SupportsBlendMode; + renderer->CreateTexture = D3D_CreateTexture; + renderer->UpdateTexture = D3D_UpdateTexture; + renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; + renderer->LockTexture = D3D_LockTexture; + renderer->UnlockTexture = D3D_UnlockTexture; + renderer->SetRenderTarget = D3D_SetRenderTarget; + renderer->UpdateViewport = D3D_UpdateViewport; + renderer->UpdateClipRect = D3D_UpdateClipRect; + renderer->RenderClear = D3D_RenderClear; + renderer->RenderDrawPoints = D3D_RenderDrawPoints; + renderer->RenderDrawLines = D3D_RenderDrawLines; + renderer->RenderFillRects = D3D_RenderFillRects; + renderer->RenderCopy = D3D_RenderCopy; + renderer->RenderCopyEx = D3D_RenderCopyEx; + renderer->RenderReadPixels = D3D_RenderReadPixels; + renderer->RenderPresent = D3D_RenderPresent; + renderer->DestroyTexture = D3D_DestroyTexture; + renderer->DestroyRenderer = D3D_DestroyRenderer; + renderer->info = D3D_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + + SDL_VERSION(&windowinfo.version); + SDL_GetWindowWMInfo(window, &windowinfo); + + window_flags = SDL_GetWindowFlags(window); + SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowDisplayMode(window, &fullscreen_mode); + + SDL_zero(pparams); + pparams.hDeviceWindow = windowinfo.info.win.window; + pparams.BackBufferWidth = w; + pparams.BackBufferHeight = h; + pparams.BackBufferCount = 1; + pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; + + if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { + pparams.Windowed = FALSE; + pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format); + pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate; + } else { + pparams.Windowed = TRUE; + pparams.BackBufferFormat = D3DFMT_UNKNOWN; + pparams.FullScreen_RefreshRateInHz = 0; + } + if (flags & SDL_RENDERER_PRESENTVSYNC) { + pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + } else { + pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + } + + /* Get the adapter for the display that the window is on */ + displayIndex = SDL_GetWindowDisplayIndex(window); + data->adapter = SDL_Direct3D9GetAdapterIndex(displayIndex); + + IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); + + device_flags = D3DCREATE_FPU_PRESERVE; + if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { + device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; + } else { + device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } + + if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) { + device_flags |= D3DCREATE_MULTITHREADED; + } + + result = IDirect3D9_CreateDevice(data->d3d, data->adapter, + D3DDEVTYPE_HAL, + pparams.hDeviceWindow, + device_flags, + &pparams, &data->device); + if (FAILED(result)) { + D3D_DestroyRenderer(renderer); + D3D_SetError("CreateDevice()", result); + return NULL; + } + + /* Get presentation parameters to fill info */ + result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); + if (FAILED(result)) { + D3D_DestroyRenderer(renderer); + D3D_SetError("GetSwapChain()", result); + return NULL; + } + result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams); + if (FAILED(result)) { + IDirect3DSwapChain9_Release(chain); + D3D_DestroyRenderer(renderer); + D3D_SetError("GetPresentParameters()", result); + return NULL; + } + IDirect3DSwapChain9_Release(chain); + if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + data->pparams = pparams; + + IDirect3DDevice9_GetDeviceCaps(data->device, &caps); + renderer->info.max_texture_width = caps.MaxTextureWidth; + renderer->info.max_texture_height = caps.MaxTextureHeight; + if (caps.NumSimultaneousRTs >= 2) { + renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; + } + + if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND) { + data->enableSeparateAlphaBlend = SDL_TRUE; + } + + /* Store the default render target */ + IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); + data->currentRenderTarget = NULL; + + /* Set up parameters for rendering */ + D3D_InitRenderState(data); + + if (caps.MaxSimultaneousTextures >= 3) { + int i; + for (i = 0; i < SDL_arraysize(data->shaders); ++i) { + result = D3D9_CreatePixelShader(data->device, (D3D9_Shader)i, &data->shaders[i]); + if (FAILED(result)) { + D3D_SetError("CreatePixelShader()", result); + } + } + if (data->shaders[SHADER_YUV_JPEG] && data->shaders[SHADER_YUV_BT601] && data->shaders[SHADER_YUV_BT709]) { + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + } + } + return renderer; +} + +static void +D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + data->updateSize = SDL_TRUE; + } +} + +static D3DBLEND GetBlendFunc(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: + return D3DBLEND_ZERO; + case SDL_BLENDFACTOR_ONE: + return D3DBLEND_ONE; + case SDL_BLENDFACTOR_SRC_COLOR: + return D3DBLEND_SRCCOLOR; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return D3DBLEND_INVSRCCOLOR; + case SDL_BLENDFACTOR_SRC_ALPHA: + return D3DBLEND_SRCALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return D3DBLEND_INVSRCALPHA; + case SDL_BLENDFACTOR_DST_COLOR: + return D3DBLEND_DESTCOLOR; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return D3DBLEND_INVDESTCOLOR; + case SDL_BLENDFACTOR_DST_ALPHA: + return D3DBLEND_DESTALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return D3DBLEND_INVDESTALPHA; + default: + return (D3DBLEND)0; + } +} + +static SDL_bool +D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (!GetBlendFunc(srcColorFactor) || !GetBlendFunc(srcAlphaFactor) || + !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor)) { + return SDL_FALSE; + } + if ((srcColorFactor != srcAlphaFactor || dstColorFactor != dstAlphaFactor) && !data->enableSeparateAlphaBlend) { + return SDL_FALSE; + } + if (colorOperation != SDL_BLENDOPERATION_ADD || alphaOperation != SDL_BLENDOPERATION_ADD) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int +D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h) +{ + HRESULT result; + + texture->dirty = SDL_FALSE; + texture->w = w; + texture->h = h; + texture->usage = usage; + texture->format = format; + texture->d3dfmt = d3dfmt; + + result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage, + PixelFormatToD3DFMT(format), + D3DPOOL_DEFAULT, &texture->texture, NULL); + if (FAILED(result)) { + return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); + } + return 0; +} + + +static int +D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) +{ + HRESULT result; + + if (texture->staging == NULL) { + result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0, + texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); + if (FAILED(result)) { + return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result); + } + } + return 0; +} + +static int +D3D_BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler) +{ + HRESULT result; + + if (texture->dirty && texture->staging) { + if (!texture->texture) { + result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage, + PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL); + if (FAILED(result)) { + return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); + } + } + + result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture->staging, (IDirect3DBaseTexture9 *)texture->texture); + if (FAILED(result)) { + return D3D_SetError("UpdateTexture()", result); + } + texture->dirty = SDL_FALSE; + } + result = IDirect3DDevice9_SetTexture(device, sampler, (IDirect3DBaseTexture9 *)texture->texture); + if (FAILED(result)) { + return D3D_SetError("SetTexture()", result); + } + return 0; +} + +static int +D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture) +{ + if (texture->texture) { + IDirect3DTexture9_Release(texture->texture); + texture->texture = NULL; + } + if (texture->staging) { + IDirect3DTexture9_AddDirtyRect(texture->staging, NULL); + texture->dirty = SDL_TRUE; + } + return 0; +} + +static int +D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch) +{ + RECT d3drect; + D3DLOCKED_RECT locked; + const Uint8 *src; + Uint8 *dst; + int row, length; + HRESULT result; + + if (D3D_CreateStagingTexture(device, texture) < 0) { + return -1; + } + + d3drect.left = x; + d3drect.right = x + w; + d3drect.top = y; + d3drect.bottom = y + h; + + result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0); + if (FAILED(result)) { + return D3D_SetError("LockRect()", result); + } + + src = (const Uint8 *)pixels; + dst = (Uint8 *)locked.pBits; + length = w * SDL_BYTESPERPIXEL(texture->format); + if (length == pitch && length == locked.Pitch) { + SDL_memcpy(dst, src, length*h); + } else { + if (length > pitch) { + length = pitch; + } + if (length > locked.Pitch) { + length = locked.Pitch; + } + for (row = 0; row < h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += locked.Pitch; + } + } + result = IDirect3DTexture9_UnlockRect(texture->staging, 0); + if (FAILED(result)) { + return D3D_SetError("UnlockRect()", result); + } + texture->dirty = SDL_TRUE; + + return 0; +} + +static void +D3D_DestroyTextureRep(D3D_TextureRep *texture) +{ + if (texture->texture) { + IDirect3DTexture9_Release(texture->texture); + texture->texture = NULL; + } + if (texture->staging) { + IDirect3DTexture9_Release(texture->staging); + texture->staging = NULL; + } +} + +static int +D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_TextureData *texturedata; + DWORD usage; + + texturedata = (D3D_TextureData *) SDL_calloc(1, sizeof(*texturedata)); + if (!texturedata) { + return SDL_OutOfMemory(); + } + texturedata->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR; + + texture->driverdata = texturedata; + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + usage = D3DUSAGE_RENDERTARGET; + } else { + usage = 0; + } + + if (D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, PixelFormatToD3DFMT(texture->format), texture->w, texture->h) < 0) { + return -1; + } + + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + texturedata->yuv = SDL_TRUE; + + if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) { + return -1; + } + + if (D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; + + if (!texturedata) { + return 0; + } + + if (D3D_RecreateTextureRep(data->device, &texturedata->texture) < 0) { + return -1; + } + + if (texturedata->yuv) { + if (D3D_RecreateTextureRep(data->device, &texturedata->utexture) < 0) { + return -1; + } + + if (D3D_RecreateTextureRep(data->device, &texturedata->vtexture) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) { + return -1; + } + + if (texturedata->yuv) { + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + + if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) { + return -1; + } + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); + if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, rect->x / 2, (rect->y + 1) / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D_UpdateTextureRep(data->device, &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D_UpdateTextureRep(data->device, &texturedata->vtexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; +} + +static int +D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; + IDirect3DDevice9 *device = data->device; + + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + texturedata->locked_rect = *rect; + + if (texturedata->yuv) { + /* It's more efficient to upload directly... */ + if (!texturedata->pixels) { + texturedata->pitch = texture->w; + texturedata->pixels = (Uint8 *)SDL_malloc((texture->h * texturedata->pitch * 3) / 2); + if (!texturedata->pixels) { + return SDL_OutOfMemory(); + } + } + *pixels = + (void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = texturedata->pitch; + } else { + RECT d3drect; + D3DLOCKED_RECT locked; + HRESULT result; + + if (D3D_CreateStagingTexture(device, &texturedata->texture) < 0) { + return -1; + } + + d3drect.left = rect->x; + d3drect.right = rect->x + rect->w; + d3drect.top = rect->y; + d3drect.bottom = rect->y + rect->h; + + result = IDirect3DTexture9_LockRect(texturedata->texture.staging, 0, &locked, &d3drect, 0); + if (FAILED(result)) { + return D3D_SetError("LockRect()", result); + } + *pixels = locked.pBits; + *pitch = locked.Pitch; + } + return 0; +} + +static void +D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + /*D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;*/ + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; + + if (!texturedata) { + return; + } + + if (texturedata->yuv) { + const SDL_Rect *rect = &texturedata->locked_rect; + void *pixels = + (void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch); + } else { + IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0); + texturedata->texture.dirty = SDL_TRUE; + } +} + +static int +D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_TextureData *texturedata; + D3D_TextureRep *texturerep; + HRESULT result; + IDirect3DDevice9 *device = data->device; + + /* Release the previous render target if it wasn't the default one */ + if (data->currentRenderTarget != NULL) { + IDirect3DSurface9_Release(data->currentRenderTarget); + data->currentRenderTarget = NULL; + } + + if (texture == NULL) { + IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget); + return 0; + } + + texturedata = (D3D_TextureData *)texture->driverdata; + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + /* Make sure the render target is updated if it was locked and written to */ + texturerep = &texturedata->texture; + if (texturerep->dirty && texturerep->staging) { + if (!texturerep->texture) { + result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage, + PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL); + if (FAILED(result)) { + return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); + } + } + + result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texturerep->staging, (IDirect3DBaseTexture9 *)texturerep->texture); + if (FAILED(result)) { + return D3D_SetError("UpdateTexture()", result); + } + texturerep->dirty = SDL_FALSE; + } + + result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget); + if(FAILED(result)) { + return D3D_SetError("GetSurfaceLevel()", result); + } + result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget); + if(FAILED(result)) { + return D3D_SetError("SetRenderTarget()", result); + } + + return 0; +} + +static int +D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + return D3D_SetRenderTargetInternal(renderer, texture); +} + +static int +D3D_UpdateViewport(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3DVIEWPORT9 viewport; + D3DMATRIX matrix; + + /* Set the viewport */ + viewport.X = renderer->viewport.x; + viewport.Y = renderer->viewport.y; + viewport.Width = renderer->viewport.w; + viewport.Height = renderer->viewport.h; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); + + /* Set an orthographic projection matrix */ + if (renderer->viewport.w && renderer->viewport.h) { + matrix.m[0][0] = 2.0f / renderer->viewport.w; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = -2.0f / renderer->viewport.h; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = -1.0f; + matrix.m[3][1] = 1.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(data->device, D3DTS_PROJECTION, &matrix); + } + + return 0; +} + +static int +D3D_UpdateClipRect(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + + if (renderer->clipping_enabled) { + const SDL_Rect *rect = &renderer->clip_rect; + RECT r; + HRESULT result; + + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE); + r.left = renderer->viewport.x + rect->x; + r.top = renderer->viewport.y + rect->y; + r.right = renderer->viewport.x + rect->x + rect->w; + r.bottom = renderer->viewport.y + rect->y + rect->h; + + result = IDirect3DDevice9_SetScissorRect(data->device, &r); + if (result != D3D_OK) { + D3D_SetError("SetScissor()", result); + return -1; + } + } else { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); + } + return 0; +} + +static int +D3D_RenderClear(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + DWORD color; + HRESULT result; + int BackBufferWidth, BackBufferHeight; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + + if (renderer->target) { + BackBufferWidth = renderer->target->w; + BackBufferHeight = renderer->target->h; + } else { + BackBufferWidth = data->pparams.BackBufferWidth; + BackBufferHeight = data->pparams.BackBufferHeight; + } + + if (renderer->clipping_enabled) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); + } + + /* Don't reset the viewport if we don't have to! */ + if (!renderer->viewport.x && !renderer->viewport.y && + renderer->viewport.w == BackBufferWidth && + renderer->viewport.h == BackBufferHeight) { + result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); + } else { + D3DVIEWPORT9 viewport; + + /* Clear is defined to clear the entire render target */ + viewport.X = 0; + viewport.Y = 0; + viewport.Width = BackBufferWidth; + viewport.Height = BackBufferHeight; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); + + result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); + + /* Reset the viewport */ + viewport.X = renderer->viewport.x; + viewport.Y = renderer->viewport.y; + viewport.Width = renderer->viewport.w; + viewport.Height = renderer->viewport.h; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); + } + + if (renderer->clipping_enabled) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE); + } + + if (FAILED(result)) { + return D3D_SetError("Clear()", result); + } + return 0; +} + +static void +D3D_SetBlendMode(D3D_RenderData * data, SDL_BlendMode blendMode) +{ + if (blendMode == SDL_BLENDMODE_NONE) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, FALSE); + } else { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, TRUE); + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, + GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode))); + IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, + GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode))); + if (data->enableSeparateAlphaBlend) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA, + GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode))); + IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA, + GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode))); + } + } +} + +static int +D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + DWORD color; + Vertex *vertices; + int i; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + D3D_SetBlendMode(data, renderer->blendMode); + + result = + IDirect3DDevice9_SetTexture(data->device, 0, + (IDirect3DBaseTexture9 *) 0); + if (FAILED(result)) { + return D3D_SetError("SetTexture()", result); + } + + color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + + vertices = SDL_stack_alloc(Vertex, count); + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + vertices[i].color = color; + vertices[i].u = 0.0f; + vertices[i].v = 0.0f; + } + result = + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count, + vertices, sizeof(*vertices)); + SDL_stack_free(vertices); + if (FAILED(result)) { + return D3D_SetError("DrawPrimitiveUP()", result); + } + return 0; +} + +static int +D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + DWORD color; + Vertex *vertices; + int i; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + D3D_SetBlendMode(data, renderer->blendMode); + + result = + IDirect3DDevice9_SetTexture(data->device, 0, + (IDirect3DBaseTexture9 *) 0); + if (FAILED(result)) { + return D3D_SetError("SetTexture()", result); + } + + color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + + vertices = SDL_stack_alloc(Vertex, count); + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + vertices[i].color = color; + vertices[i].u = 0.0f; + vertices[i].v = 0.0f; + } + result = + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1, + vertices, sizeof(*vertices)); + + /* DirectX 9 has the same line rasterization semantics as GDI, + so we need to close the endpoint of the line */ + if (count == 2 || + points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + vertices[0].x = points[count-1].x; + vertices[0].y = points[count-1].y; + result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices)); + } + + SDL_stack_free(vertices); + if (FAILED(result)) { + return D3D_SetError("DrawPrimitiveUP()", result); + } + return 0; +} + +static int +D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, + int count) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + DWORD color; + int i; + float minx, miny, maxx, maxy; + Vertex vertices[4]; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + D3D_SetBlendMode(data, renderer->blendMode); + + result = + IDirect3DDevice9_SetTexture(data->device, 0, + (IDirect3DBaseTexture9 *) 0); + if (FAILED(result)) { + return D3D_SetError("SetTexture()", result); + } + + color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + + for (i = 0; i < count; ++i) { + const SDL_FRect *rect = &rects[i]; + + minx = rect->x; + miny = rect->y; + maxx = rect->x + rect->w; + maxy = rect->y + rect->h; + + vertices[0].x = minx; + vertices[0].y = miny; + vertices[0].z = 0.0f; + vertices[0].color = color; + vertices[0].u = 0.0f; + vertices[0].v = 0.0f; + + vertices[1].x = maxx; + vertices[1].y = miny; + vertices[1].z = 0.0f; + vertices[1].color = color; + vertices[1].u = 0.0f; + vertices[1].v = 0.0f; + + vertices[2].x = maxx; + vertices[2].y = maxy; + vertices[2].z = 0.0f; + vertices[2].color = color; + vertices[2].u = 0.0f; + vertices[2].v = 0.0f; + + vertices[3].x = minx; + vertices[3].y = maxy; + vertices[3].z = 0.0f; + vertices[3].color = color; + vertices[3].u = 0.0f; + vertices[3].v = 0.0f; + + result = + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, + 2, vertices, sizeof(*vertices)); + if (FAILED(result)) { + return D3D_SetError("DrawPrimitiveUP()", result); + } + } + return 0; +} + +static void +D3D_UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index) +{ + if (texturedata->scaleMode != data->scaleMode[index]) { + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MINFILTER, + texturedata->scaleMode); + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MAGFILTER, + texturedata->scaleMode); + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_ADDRESSU, + D3DTADDRESS_CLAMP); + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_ADDRESSV, + D3DTADDRESS_CLAMP); + data->scaleMode[index] = texturedata->scaleMode; + } +} + +static int +D3D_RenderSetupTextureState(SDL_Renderer * renderer, SDL_Texture * texture, LPDIRECT3DPIXELSHADER9 *shader) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_TextureData *texturedata; + + *shader = NULL; + + texturedata = (D3D_TextureData *)texture->driverdata; + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + D3D_UpdateTextureScaleMode(data, texturedata, 0); + + if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) { + return -1; + } + + if (texturedata->yuv) { + switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { + case SDL_YUV_CONVERSION_JPEG: + *shader = data->shaders[SHADER_YUV_JPEG]; + break; + case SDL_YUV_CONVERSION_BT601: + *shader = data->shaders[SHADER_YUV_BT601]; + break; + case SDL_YUV_CONVERSION_BT709: + *shader = data->shaders[SHADER_YUV_BT709]; + break; + default: + return SDL_SetError("Unsupported YUV conversion mode"); + } + + D3D_UpdateTextureScaleMode(data, texturedata, 1); + D3D_UpdateTextureScaleMode(data, texturedata, 2); + + if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) { + return -1; + } + if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + LPDIRECT3DPIXELSHADER9 shader; + float minx, miny, maxx, maxy; + float minu, maxu, minv, maxv; + DWORD color; + Vertex vertices[4]; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + minx = dstrect->x - 0.5f; + miny = dstrect->y - 0.5f; + maxx = dstrect->x + dstrect->w - 0.5f; + maxy = dstrect->y + dstrect->h - 0.5f; + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b); + + vertices[0].x = minx; + vertices[0].y = miny; + vertices[0].z = 0.0f; + vertices[0].color = color; + vertices[0].u = minu; + vertices[0].v = minv; + + vertices[1].x = maxx; + vertices[1].y = miny; + vertices[1].z = 0.0f; + vertices[1].color = color; + vertices[1].u = maxu; + vertices[1].v = minv; + + vertices[2].x = maxx; + vertices[2].y = maxy; + vertices[2].z = 0.0f; + vertices[2].color = color; + vertices[2].u = maxu; + vertices[2].v = maxv; + + vertices[3].x = minx; + vertices[3].y = maxy; + vertices[3].z = 0.0f; + vertices[3].color = color; + vertices[3].u = minu; + vertices[3].v = maxv; + + D3D_SetBlendMode(data, texture->blendMode); + + if (D3D_RenderSetupTextureState(renderer, texture, &shader) < 0) { + return -1; + } + + if (shader) { + result = IDirect3DDevice9_SetPixelShader(data->device, shader); + if (FAILED(result)) { + return D3D_SetError("SetShader()", result); + } + } + result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2, + vertices, sizeof(*vertices)); + if (FAILED(result)) { + D3D_SetError("DrawPrimitiveUP()", result); + } + if (shader) { + IDirect3DDevice9_SetPixelShader(data->device, NULL); + } + return FAILED(result) ? -1 : 0; +} + + +static int +D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + LPDIRECT3DPIXELSHADER9 shader = NULL; + float minx, miny, maxx, maxy; + float minu, maxu, minv, maxv; + float centerx, centery; + DWORD color; + Vertex vertices[4]; + Float4X4 modelMatrix; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; + } + + centerx = center->x; + centery = center->y; + + minx = -centerx; + maxx = dstrect->w - centerx; + miny = -centery; + maxy = dstrect->h - centery; + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + if (flip & SDL_FLIP_HORIZONTAL) { + float tmp = maxu; + maxu = minu; + minu = tmp; + } + if (flip & SDL_FLIP_VERTICAL) { + float tmp = maxv; + maxv = minv; + minv = tmp; + } + + color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b); + + vertices[0].x = minx; + vertices[0].y = miny; + vertices[0].z = 0.0f; + vertices[0].color = color; + vertices[0].u = minu; + vertices[0].v = minv; + + vertices[1].x = maxx; + vertices[1].y = miny; + vertices[1].z = 0.0f; + vertices[1].color = color; + vertices[1].u = maxu; + vertices[1].v = minv; + + vertices[2].x = maxx; + vertices[2].y = maxy; + vertices[2].z = 0.0f; + vertices[2].color = color; + vertices[2].u = maxu; + vertices[2].v = maxv; + + vertices[3].x = minx; + vertices[3].y = maxy; + vertices[3].z = 0.0f; + vertices[3].color = color; + vertices[3].u = minu; + vertices[3].v = maxv; + + D3D_SetBlendMode(data, texture->blendMode); + + if (D3D_RenderSetupTextureState(renderer, texture, &shader) < 0) { + return -1; + } + + /* Rotate and translate */ + modelMatrix = MatrixMultiply( + MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)), + MatrixTranslation(dstrect->x + center->x - 0.5f, dstrect->y + center->y - 0.5f, 0)); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix); + + if (shader) { + result = IDirect3DDevice9_SetPixelShader(data->device, shader); + if (FAILED(result)) { + D3D_SetError("SetShader()", result); + goto done; + } + } + result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2, + vertices, sizeof(*vertices)); + if (FAILED(result)) { + D3D_SetError("DrawPrimitiveUP()", result); + } +done: + if (shader) { + IDirect3DDevice9_SetPixelShader(data->device, NULL); + } + + modelMatrix = MatrixIdentity(); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix); + + return FAILED(result) ? -1 : 0; +} + +static int +D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3DSURFACE_DESC desc; + LPDIRECT3DSURFACE9 backBuffer; + LPDIRECT3DSURFACE9 surface; + RECT d3drect; + D3DLOCKED_RECT locked; + HRESULT result; + + if (data->currentRenderTarget) { + backBuffer = data->currentRenderTarget; + } else { + backBuffer = data->defaultRenderTarget; + } + + result = IDirect3DSurface9_GetDesc(backBuffer, &desc); + if (FAILED(result)) { + IDirect3DSurface9_Release(backBuffer); + return D3D_SetError("GetDesc()", result); + } + + result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL); + if (FAILED(result)) { + IDirect3DSurface9_Release(backBuffer); + return D3D_SetError("CreateOffscreenPlainSurface()", result); + } + + result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface); + if (FAILED(result)) { + IDirect3DSurface9_Release(surface); + IDirect3DSurface9_Release(backBuffer); + return D3D_SetError("GetRenderTargetData()", result); + } + + d3drect.left = rect->x; + d3drect.right = rect->x + rect->w; + d3drect.top = rect->y; + d3drect.bottom = rect->y + rect->h; + + result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY); + if (FAILED(result)) { + IDirect3DSurface9_Release(surface); + IDirect3DSurface9_Release(backBuffer); + return D3D_SetError("LockRect()", result); + } + + SDL_ConvertPixels(rect->w, rect->h, + D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch, + format, pixels, pitch); + + IDirect3DSurface9_UnlockRect(surface); + + IDirect3DSurface9_Release(surface); + + return 0; +} + +static void +D3D_RenderPresent(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + HRESULT result; + + if (!data->beginScene) { + IDirect3DDevice9_EndScene(data->device); + data->beginScene = SDL_TRUE; + } + + result = IDirect3DDevice9_TestCooperativeLevel(data->device); + if (result == D3DERR_DEVICELOST) { + /* We'll reset later */ + return; + } + if (result == D3DERR_DEVICENOTRESET) { + D3D_Reset(renderer); + } + result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL); + if (FAILED(result)) { + D3D_SetError("Present()", result); + } +} + +static void +D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + + if (!data) { + return; + } + D3D_DestroyTextureRep(&data->texture); + D3D_DestroyTextureRep(&data->utexture); + D3D_DestroyTextureRep(&data->vtexture); + SDL_free(data->pixels); + SDL_free(data); + texture->driverdata = NULL; +} + +static void +D3D_DestroyRenderer(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + + if (data) { + int i; + + /* Release the render target */ + if (data->defaultRenderTarget) { + IDirect3DSurface9_Release(data->defaultRenderTarget); + data->defaultRenderTarget = NULL; + } + if (data->currentRenderTarget != NULL) { + IDirect3DSurface9_Release(data->currentRenderTarget); + data->currentRenderTarget = NULL; + } + for (i = 0; i < SDL_arraysize(data->shaders); ++i) { + if (data->shaders[i]) { + IDirect3DPixelShader9_Release(data->shaders[i]); + data->shaders[i] = NULL; + } + } + if (data->device) { + IDirect3DDevice9_Release(data->device); + data->device = NULL; + } + if (data->d3d) { + IDirect3D9_Release(data->d3d); + SDL_UnloadObject(data->d3dDLL); + } + SDL_free(data); + } + SDL_free(renderer); +} +#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ + +#ifdef __WIN32__ +/* This function needs to always exist on Windows, for the Dynamic API. */ +IDirect3DDevice9 * +SDL_RenderGetD3D9Device(SDL_Renderer * renderer) +{ + IDirect3DDevice9 *device = NULL; + +#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + + /* Make sure that this is a D3D renderer */ + if (renderer->DestroyRenderer != D3D_DestroyRenderer) { + SDL_SetError("Renderer is not a D3D renderer"); + return NULL; + } + + device = data->device; + if (device) { + IDirect3DDevice9_AddRef(device); + } +#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ + + return device; +} +#endif /* __WIN32__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.c b/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.c new file mode 100644 index 0000000..b95fddc --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.c @@ -0,0 +1,274 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "SDL_render.h" +#include "SDL_system.h" + +#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED + +#include "../../core/windows/SDL_windows.h" + +#include <d3d9.h> + +#include "SDL_shaders_d3d.h" + +/* The shaders here were compiled with: + + fxc /T ps_2_0 /Fo"<OUTPUT FILE>" "<INPUT FILE>" + + Shader object code was converted to a list of DWORDs via the following + *nix style command (available separately from Windows + MSVC): + + hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE> +*/ + +/* --- D3D9_PixelShader_YUV_JPEG.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler = sampler_state + { + addressU = Clamp; + addressV = Clamp; + mipfilter = NONE; + minfilter = LINEAR; + magfilter = LINEAR; + }; + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {0.0, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.0000, 0.0000, 1.4020}; + const float3 Gcoeff = {1.0000, -0.3441, -0.7141}; + const float3 Bcoeff = {1.0000, 1.7720, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } +*/ +static const DWORD D3D9_PixelShader_YUV_JPEG[] = { + 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200, + 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003, + 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001, + 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0, + 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, + 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874, + 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004, + 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, + 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001, + 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, + 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, + 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000, + 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f800000, 0x00000000, 0x3fb374bc, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000, + 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042, + 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000, + 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000, + 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008, + 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff +}; + +/* --- D3D9_PixelShader_YUV_BT601.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler = sampler_state + { + addressU = Clamp; + addressV = Clamp; + mipfilter = NONE; + minfilter = LINEAR; + magfilter = LINEAR; + }; + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.5960}; + const float3 Gcoeff = {1.1644, -0.3918, -0.8130}; + const float3 Bcoeff = {1.1644, 2.0172, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } +*/ +static const DWORD D3D9_PixelShader_YUV_BT601[] = { + 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200, + 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003, + 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001, + 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0, + 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, + 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874, + 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004, + 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, + 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001, + 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, + 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, + 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x00000000, 0x3fcc49ba, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000, + 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042, + 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000, + 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000, + 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008, + 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff +}; + +/* --- D3D9_PixelShader_YUV_BT709.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler = sampler_state + { + addressU = Clamp; + addressV = Clamp; + mipfilter = NONE; + minfilter = LINEAR; + magfilter = LINEAR; + }; + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.7927}; + const float3 Gcoeff = {1.1644, -0.2132, -0.5329}; + const float3 Bcoeff = {1.1644, 2.1124, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } +*/ +static const DWORD D3D9_PixelShader_YUV_BT709[] = { + 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200, + 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003, + 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001, + 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0, + 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, + 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874, + 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004, + 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, + 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001, + 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, + 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, + 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x00000000, 0x3fe57732, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000, + 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042, + 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000, + 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000, + 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008, + 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff +}; + + +static const DWORD *D3D9_shaders[] = { + D3D9_PixelShader_YUV_JPEG, + D3D9_PixelShader_YUV_BT601, + D3D9_PixelShader_YUV_BT709, +}; + +HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader) +{ + return IDirect3DDevice9_CreatePixelShader(d3dDevice, D3D9_shaders[shader], pixelShader); +} + +#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.h b/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.h new file mode 100644 index 0000000..8549582 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d/SDL_shaders_d3d.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +/* D3D9 shader implementation */ + +typedef enum { + SHADER_YUV_JPEG, + SHADER_YUV_BT601, + SHADER_YUV_BT709, + NUM_SHADERS +} D3D9_Shader; + +extern HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_d3d11.c b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_d3d11.c new file mode 100644 index 0000000..7a37039 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_d3d11.c @@ -0,0 +1,2555 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#define COBJMACROS +#include "../../core/windows/SDL_windows.h" +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_syswm.h" +#include "../SDL_sysrender.h" +#include "../SDL_d3dmath.h" + +#include <d3d11_1.h> + +#include "SDL_shaders_d3d11.h" + +#ifdef __WINRT__ + +#if NTDDI_VERSION > NTDDI_WIN8 +#include <DXGI1_3.h> +#endif + +#include "SDL_render_winrt.h" + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +#include <windows.ui.xaml.media.dxinterop.h> +/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */ +extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative; +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ + +#endif /* __WINRT__ */ + + +#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str + +#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; } + + +/* Vertex shader, common values */ +typedef struct +{ + Float4X4 model; + Float4X4 projectionAndView; +} VertexShaderConstants; + +/* Per-vertex data */ +typedef struct +{ + Float3 pos; + Float2 tex; + Float4 color; +} VertexPositionColor; + +/* Per-texture data */ +typedef struct +{ + ID3D11Texture2D *mainTexture; + ID3D11ShaderResourceView *mainTextureResourceView; + ID3D11RenderTargetView *mainTextureRenderTargetView; + ID3D11Texture2D *stagingTexture; + int lockedTexturePositionX; + int lockedTexturePositionY; + D3D11_FILTER scaleMode; + + /* YV12 texture support */ + SDL_bool yuv; + ID3D11Texture2D *mainTextureU; + ID3D11ShaderResourceView *mainTextureResourceViewU; + ID3D11Texture2D *mainTextureV; + ID3D11ShaderResourceView *mainTextureResourceViewV; + + /* NV12 texture support */ + SDL_bool nv12; + ID3D11Texture2D *mainTextureNV; + ID3D11ShaderResourceView *mainTextureResourceViewNV; + + Uint8 *pixels; + int pitch; + SDL_Rect locked_rect; +} D3D11_TextureData; + +/* Blend mode data */ +typedef struct +{ + SDL_BlendMode blendMode; + ID3D11BlendState *blendState; +} D3D11_BlendMode; + +/* Private renderer data */ +typedef struct +{ + void *hDXGIMod; + void *hD3D11Mod; + IDXGIFactory2 *dxgiFactory; + IDXGIAdapter *dxgiAdapter; + ID3D11Device1 *d3dDevice; + ID3D11DeviceContext1 *d3dContext; + IDXGISwapChain1 *swapChain; + DXGI_SWAP_EFFECT swapEffect; + ID3D11RenderTargetView *mainRenderTargetView; + ID3D11RenderTargetView *currentOffscreenRenderTargetView; + ID3D11InputLayout *inputLayout; + ID3D11Buffer *vertexBuffer; + ID3D11VertexShader *vertexShader; + ID3D11PixelShader *pixelShaders[NUM_SHADERS]; + int blendModesCount; + D3D11_BlendMode *blendModes; + ID3D11SamplerState *nearestPixelSampler; + ID3D11SamplerState *linearSampler; + D3D_FEATURE_LEVEL featureLevel; + + /* Rasterizers */ + ID3D11RasterizerState *mainRasterizer; + ID3D11RasterizerState *clippedRasterizer; + + /* Vertex buffer constants */ + VertexShaderConstants vertexShaderConstantsData; + ID3D11Buffer *vertexShaderConstants; + + /* Cached renderer properties */ + DXGI_MODE_ROTATION rotation; + ID3D11RenderTargetView *currentRenderTargetView; + ID3D11RasterizerState *currentRasterizerState; + ID3D11BlendState *currentBlendState; + ID3D11PixelShader *currentShader; + ID3D11ShaderResourceView *currentShaderResource; + ID3D11SamplerState *currentSampler; +} D3D11_RenderData; + + +/* Define D3D GUIDs here so we don't have to include uuid.lib. +* +* Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437: +* The extra 'SDL_' was added to the start of each IID's name, in order +* to prevent build errors on both MinGW-w64 and WinRT/UWP. +* (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to +* linker errors in WinRT/UWP builds.) +*/ + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-const-variable" +#endif + +static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; +static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; +static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } }; +static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; +static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } }; +static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } }; +static const GUID SDL_IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } }; + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + + +/* Direct3D 11.1 renderer implementation */ +static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags); +static void D3D11_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *srcPixels, + int srcPitch); +static int D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_UpdateViewport(SDL_Renderer * renderer); +static int D3D11_UpdateClipRect(SDL_Renderer * renderer); +static int D3D11_RenderClear(SDL_Renderer * renderer); +static int D3D11_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D11_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D11_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip); +static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static void D3D11_RenderPresent(SDL_Renderer * renderer); +static void D3D11_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void D3D11_DestroyRenderer(SDL_Renderer * renderer); + +/* Direct3D 11.1 Internal Functions */ +static HRESULT D3D11_CreateDeviceResources(SDL_Renderer * renderer); +static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer); +static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer); +static HRESULT D3D11_HandleDeviceLost(SDL_Renderer * renderer); +static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer); + +SDL_RenderDriver D3D11_RenderDriver = { + D3D11_CreateRenderer, + { + "direct3d11", + ( + SDL_RENDERER_ACCELERATED | + SDL_RENDERER_PRESENTVSYNC | + SDL_RENDERER_TARGETTEXTURE + ), /* flags. see SDL_RendererFlags */ + 6, /* num_texture_formats */ + { /* texture_formats */ + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 + }, + 0, /* max_texture_width: will be filled in later */ + 0 /* max_texture_height: will be filled in later */ + } +}; + + +Uint32 +D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) +{ + switch (dxgiFormat) { + case DXGI_FORMAT_B8G8R8A8_UNORM: + return SDL_PIXELFORMAT_ARGB8888; + case DXGI_FORMAT_B8G8R8X8_UNORM: + return SDL_PIXELFORMAT_RGB888; + default: + return SDL_PIXELFORMAT_UNKNOWN; + } +} + +static DXGI_FORMAT +SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) +{ + switch (sdlFormat) { + case SDL_PIXELFORMAT_ARGB8888: + return DXGI_FORMAT_B8G8R8A8_UNORM; + case SDL_PIXELFORMAT_RGB888: + return DXGI_FORMAT_B8G8R8X8_UNORM; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: /* For the Y texture */ + case SDL_PIXELFORMAT_NV21: /* For the Y texture */ + return DXGI_FORMAT_R8_UNORM; + default: + return DXGI_FORMAT_UNKNOWN; + } +} + +SDL_Renderer * +D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + D3D11_RenderData *data; + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = D3D11_WindowEvent; + renderer->SupportsBlendMode = D3D11_SupportsBlendMode; + renderer->CreateTexture = D3D11_CreateTexture; + renderer->UpdateTexture = D3D11_UpdateTexture; + renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV; + renderer->LockTexture = D3D11_LockTexture; + renderer->UnlockTexture = D3D11_UnlockTexture; + renderer->SetRenderTarget = D3D11_SetRenderTarget; + renderer->UpdateViewport = D3D11_UpdateViewport; + renderer->UpdateClipRect = D3D11_UpdateClipRect; + renderer->RenderClear = D3D11_RenderClear; + renderer->RenderDrawPoints = D3D11_RenderDrawPoints; + renderer->RenderDrawLines = D3D11_RenderDrawLines; + renderer->RenderFillRects = D3D11_RenderFillRects; + renderer->RenderCopy = D3D11_RenderCopy; + renderer->RenderCopyEx = D3D11_RenderCopyEx; + renderer->RenderReadPixels = D3D11_RenderReadPixels; + renderer->RenderPresent = D3D11_RenderPresent; + renderer->DestroyTexture = D3D11_DestroyTexture; + renderer->DestroyRenderer = D3D11_DestroyRenderer; + renderer->info = D3D11_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + /* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1. + * Failure to use it seems to either result in: + * + * - with the D3D11 debug runtime turned OFF, vsync seemingly gets turned + * off (framerate doesn't get capped), but nothing appears on-screen + * + * - with the D3D11 debug runtime turned ON, vsync gets automatically + * turned back on, and the following gets output to the debug console: + * + * DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] + */ + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; +#else + if ((flags & SDL_RENDERER_PRESENTVSYNC)) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } +#endif + + /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in + * order to give init functions access to the underlying window handle: + */ + renderer->window = window; + + /* Initialize Direct3D resources */ + if (FAILED(D3D11_CreateDeviceResources(renderer))) { + D3D11_DestroyRenderer(renderer); + return NULL; + } + if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) { + D3D11_DestroyRenderer(renderer); + return NULL; + } + + return renderer; +} + +static void +D3D11_ReleaseAll(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + SDL_Texture *texture = NULL; + + /* Release all textures */ + for (texture = renderer->textures; texture; texture = texture->next) { + D3D11_DestroyTexture(renderer, texture); + } + + /* Release/reset everything else */ + if (data) { + int i; + + SAFE_RELEASE(data->dxgiFactory); + SAFE_RELEASE(data->dxgiAdapter); + SAFE_RELEASE(data->d3dDevice); + SAFE_RELEASE(data->d3dContext); + SAFE_RELEASE(data->swapChain); + SAFE_RELEASE(data->mainRenderTargetView); + SAFE_RELEASE(data->currentOffscreenRenderTargetView); + SAFE_RELEASE(data->inputLayout); + SAFE_RELEASE(data->vertexBuffer); + SAFE_RELEASE(data->vertexShader); + for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) { + SAFE_RELEASE(data->pixelShaders[i]); + } + if (data->blendModesCount > 0) { + for (i = 0; i < data->blendModesCount; ++i) { + SAFE_RELEASE(data->blendModes[i].blendState); + } + SDL_free(data->blendModes); + + data->blendModesCount = 0; + } + SAFE_RELEASE(data->nearestPixelSampler); + SAFE_RELEASE(data->linearSampler); + SAFE_RELEASE(data->mainRasterizer); + SAFE_RELEASE(data->clippedRasterizer); + SAFE_RELEASE(data->vertexShaderConstants); + + data->swapEffect = (DXGI_SWAP_EFFECT) 0; + data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED; + data->currentRenderTargetView = NULL; + data->currentRasterizerState = NULL; + data->currentBlendState = NULL; + data->currentShader = NULL; + data->currentShaderResource = NULL; + data->currentSampler = NULL; + + /* Unload the D3D libraries. This should be done last, in order + * to prevent IUnknown::Release() calls from crashing. + */ + if (data->hD3D11Mod) { + SDL_UnloadObject(data->hD3D11Mod); + data->hD3D11Mod = NULL; + } + if (data->hDXGIMod) { + SDL_UnloadObject(data->hDXGIMod); + data->hDXGIMod = NULL; + } + } +} + +static void +D3D11_DestroyRenderer(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_ReleaseAll(renderer); + if (data) { + SDL_free(data); + } + SDL_free(renderer); +} + +static D3D11_BLEND GetBlendFunc(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: + return D3D11_BLEND_ZERO; + case SDL_BLENDFACTOR_ONE: + return D3D11_BLEND_ONE; + case SDL_BLENDFACTOR_SRC_COLOR: + return D3D11_BLEND_SRC_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return D3D11_BLEND_INV_SRC_COLOR; + case SDL_BLENDFACTOR_SRC_ALPHA: + return D3D11_BLEND_SRC_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return D3D11_BLEND_INV_SRC_ALPHA; + case SDL_BLENDFACTOR_DST_COLOR: + return D3D11_BLEND_DEST_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return D3D11_BLEND_INV_DEST_COLOR; + case SDL_BLENDFACTOR_DST_ALPHA: + return D3D11_BLEND_DEST_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return D3D11_BLEND_INV_DEST_ALPHA; + default: + return (D3D11_BLEND)0; + } +} + +static D3D11_BLEND_OP GetBlendEquation(SDL_BlendOperation operation) +{ + switch (operation) { + case SDL_BLENDOPERATION_ADD: + return D3D11_BLEND_OP_ADD; + case SDL_BLENDOPERATION_SUBTRACT: + return D3D11_BLEND_OP_SUBTRACT; + case SDL_BLENDOPERATION_REV_SUBTRACT: + return D3D11_BLEND_OP_REV_SUBTRACT; + case SDL_BLENDOPERATION_MINIMUM: + return D3D11_BLEND_OP_MIN; + case SDL_BLENDOPERATION_MAXIMUM: + return D3D11_BLEND_OP_MAX; + default: + return (D3D11_BLEND_OP)0; + } +} + +static SDL_bool +D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + ID3D11BlendState *blendState = NULL; + D3D11_BlendMode *blendModes; + HRESULT result = S_OK; + + D3D11_BLEND_DESC blendDesc; + SDL_zero(blendDesc); + blendDesc.AlphaToCoverageEnable = FALSE; + blendDesc.IndependentBlendEnable = FALSE; + blendDesc.RenderTarget[0].BlendEnable = TRUE; + blendDesc.RenderTarget[0].SrcBlend = GetBlendFunc(srcColorFactor); + blendDesc.RenderTarget[0].DestBlend = GetBlendFunc(dstColorFactor); + blendDesc.RenderTarget[0].BlendOp = GetBlendEquation(colorOperation); + blendDesc.RenderTarget[0].SrcBlendAlpha = GetBlendFunc(srcAlphaFactor); + blendDesc.RenderTarget[0].DestBlendAlpha = GetBlendFunc(dstAlphaFactor); + blendDesc.RenderTarget[0].BlendOpAlpha = GetBlendEquation(alphaOperation); + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, &blendState); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBlendState"), result); + return SDL_FALSE; + } + + blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes)); + if (!blendModes) { + SAFE_RELEASE(blendState); + SDL_OutOfMemory(); + return SDL_FALSE; + } + blendModes[data->blendModesCount].blendMode = blendMode; + blendModes[data->blendModesCount].blendState = blendState; + data->blendModes = blendModes; + ++data->blendModesCount; + + return SDL_TRUE; +} + +/* Create resources that depend on the device. */ +static HRESULT +D3D11_CreateDeviceResources(SDL_Renderer * renderer) +{ + typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; + ID3D11Device *d3dDevice = NULL; + ID3D11DeviceContext *d3dContext = NULL; + IDXGIDevice1 *dxgiDevice = NULL; + HRESULT result = S_OK; + UINT creationFlags; + int i; + + /* This array defines the set of DirectX hardware feature levels this app will support. + * Note the ordering should be preserved. + * Don't forget to declare your application's minimum required feature level in its + * description. All applications are assumed to support 9.1 unless otherwise stated. + */ + D3D_FEATURE_LEVEL featureLevels[] = + { + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1 + }; + + D3D11_BUFFER_DESC constantBufferDesc; + D3D11_SAMPLER_DESC samplerDesc; + D3D11_RASTERIZER_DESC rasterDesc; + +#ifdef __WINRT__ + CreateDXGIFactoryFunc = CreateDXGIFactory1; + D3D11CreateDeviceFunc = D3D11CreateDevice; +#else + data->hDXGIMod = SDL_LoadObject("dxgi.dll"); + if (!data->hDXGIMod) { + result = E_FAIL; + goto done; + } + + CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); + if (!CreateDXGIFactoryFunc) { + result = E_FAIL; + goto done; + } + + data->hD3D11Mod = SDL_LoadObject("d3d11.dll"); + if (!data->hD3D11Mod) { + result = E_FAIL; + goto done; + } + + D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice"); + if (!D3D11CreateDeviceFunc) { + result = E_FAIL; + goto done; + } +#endif /* __WINRT__ */ + + result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result); + goto done; + } + + /* FIXME: Should we use the default adapter? */ + result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); + goto done; + } + + /* This flag adds support for surfaces with a different color channel ordering + * than the API default. It is required for compatibility with Direct2D. + */ + creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + + /* Make sure Direct3D's debugging feature gets used, if the app requests it. */ + if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE)) { + creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + } + + /* Create the Direct3D 11 API device object and a corresponding context. */ + result = D3D11CreateDeviceFunc( + data->dxgiAdapter, + D3D_DRIVER_TYPE_UNKNOWN, + NULL, + creationFlags, /* Set set debug and Direct2D compatibility flags. */ + featureLevels, /* List of feature levels this app can support. */ + SDL_arraysize(featureLevels), + D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */ + &d3dDevice, /* Returns the Direct3D device created. */ + &data->featureLevel, /* Returns feature level of device created. */ + &d3dContext /* Returns the device immediate context. */ + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); + goto done; + } + + result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_ID3D11Device1, (void **)&data->d3dDevice); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to ID3D11Device1"), result); + goto done; + } + + result = ID3D11DeviceContext_QueryInterface(d3dContext, &SDL_IID_ID3D11DeviceContext1, (void **)&data->d3dContext); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext to ID3D11DeviceContext1"), result); + goto done; + } + + result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_IDXGIDevice1, (void **)&dxgiDevice); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to IDXGIDevice1"), result); + goto done; + } + + /* Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and + * ensures that the application will only render after each VSync, minimizing power consumption. + */ + result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIDevice1::SetMaximumFrameLatency"), result); + goto done; + } + + /* Make note of the maximum texture size + * Max texture sizes are documented on MSDN, at: + * http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx + */ + switch (data->featureLevel) { + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 16384; + break; + + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 8192; + break; + + case D3D_FEATURE_LEVEL_9_3: + renderer->info.max_texture_width = renderer->info.max_texture_height = 4096; + break; + + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + renderer->info.max_texture_width = renderer->info.max_texture_height = 2048; + break; + + default: + SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel); + result = E_FAIL; + goto done; + } + + if (D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout) < 0) { + goto done; + } + + for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) { + if (D3D11_CreatePixelShader(data->d3dDevice, (D3D11_Shader)i, &data->pixelShaders[i]) < 0) { + goto done; + } + } + + /* Setup space to hold vertex shader constants: */ + SDL_zero(constantBufferDesc); + constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants); + constantBufferDesc.Usage = D3D11_USAGE_DEFAULT; + constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + result = ID3D11Device_CreateBuffer(data->d3dDevice, + &constantBufferDesc, + NULL, + &data->vertexShaderConstants + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex shader constants]"), result); + goto done; + } + + /* Create samplers to use when drawing textures: */ + SDL_zero(samplerDesc); + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.MipLODBias = 0.0f; + samplerDesc.MaxAnisotropy = 1; + samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; + samplerDesc.MinLOD = 0.0f; + samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + result = ID3D11Device_CreateSamplerState(data->d3dDevice, + &samplerDesc, + &data->nearestPixelSampler + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [nearest-pixel filter]"), result); + goto done; + } + + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + result = ID3D11Device_CreateSamplerState(data->d3dDevice, + &samplerDesc, + &data->linearSampler + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [linear filter]"), result); + goto done; + } + + /* Setup Direct3D rasterizer states */ + SDL_zero(rasterDesc); + rasterDesc.AntialiasedLineEnable = FALSE; + rasterDesc.CullMode = D3D11_CULL_NONE; + rasterDesc.DepthBias = 0; + rasterDesc.DepthBiasClamp = 0.0f; + rasterDesc.DepthClipEnable = TRUE; + rasterDesc.FillMode = D3D11_FILL_SOLID; + rasterDesc.FrontCounterClockwise = FALSE; + rasterDesc.MultisampleEnable = FALSE; + rasterDesc.ScissorEnable = FALSE; + rasterDesc.SlopeScaledDepthBias = 0.0f; + result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [main rasterizer]"), result); + goto done; + } + + rasterDesc.ScissorEnable = TRUE; + result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [clipped rasterizer]"), result); + goto done; + } + + /* Create blending states: */ + if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND) || + !D3D11_CreateBlendState(renderer, SDL_BLENDMODE_ADD) || + !D3D11_CreateBlendState(renderer, SDL_BLENDMODE_MOD)) { + /* D3D11_CreateBlendMode will set the SDL error, if it fails */ + goto done; + } + + /* Setup render state that doesn't change */ + ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout); + ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0); + ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants); + +done: + SAFE_RELEASE(d3dDevice); + SAFE_RELEASE(d3dContext); + SAFE_RELEASE(dxgiDevice); + return result; +} + +#ifdef __WIN32__ + +static DXGI_MODE_ROTATION +D3D11_GetCurrentRotation() +{ + /* FIXME */ + return DXGI_MODE_ROTATION_IDENTITY; +} + +#endif /* __WIN32__ */ + +static BOOL +D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) +{ + switch (rotation) { + case DXGI_MODE_ROTATION_ROTATE90: + case DXGI_MODE_ROTATION_ROTATE270: + return TRUE; + default: + return FALSE; + } +} + +static int +D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + if (data->currentOffscreenRenderTargetView) { + return DXGI_MODE_ROTATION_IDENTITY; + } else { + return data->rotation; + } +} + +static int +D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset) +{ + const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer); + switch (rotation) { + case DXGI_MODE_ROTATION_IDENTITY: + outRect->left = sdlRect->x; + outRect->right = sdlRect->x + sdlRect->w; + outRect->top = sdlRect->y; + outRect->bottom = sdlRect->y + sdlRect->h; + if (includeViewportOffset) { + outRect->left += renderer->viewport.x; + outRect->right += renderer->viewport.x; + outRect->top += renderer->viewport.y; + outRect->bottom += renderer->viewport.y; + } + break; + case DXGI_MODE_ROTATION_ROTATE270: + outRect->left = sdlRect->y; + outRect->right = sdlRect->y + sdlRect->h; + outRect->top = renderer->viewport.w - sdlRect->x - sdlRect->w; + outRect->bottom = renderer->viewport.w - sdlRect->x; + break; + case DXGI_MODE_ROTATION_ROTATE180: + outRect->left = renderer->viewport.w - sdlRect->x - sdlRect->w; + outRect->right = renderer->viewport.w - sdlRect->x; + outRect->top = renderer->viewport.h - sdlRect->y - sdlRect->h; + outRect->bottom = renderer->viewport.h - sdlRect->y; + break; + case DXGI_MODE_ROTATION_ROTATE90: + outRect->left = renderer->viewport.h - sdlRect->y - sdlRect->h; + outRect->right = renderer->viewport.h - sdlRect->y; + outRect->top = sdlRect->x; + outRect->bottom = sdlRect->x + sdlRect->h; + break; + default: + return SDL_SetError("The physical display is in an unknown or unsupported rotation"); + } + return 0; +} + +static HRESULT +D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; +#ifdef __WINRT__ + IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); + const BOOL usingXAML = (coreWindow == NULL); +#else + IUnknown *coreWindow = NULL; + const BOOL usingXAML = FALSE; +#endif + HRESULT result = S_OK; + + /* Create a swap chain using the same adapter as the existing Direct3D device. */ + DXGI_SWAP_CHAIN_DESC1 swapChainDesc; + SDL_zero(swapChainDesc); + swapChainDesc.Width = w; + swapChainDesc.Height = h; + swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */ + swapChainDesc.Stereo = FALSE; + swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */ + swapChainDesc.SampleDesc.Quality = 0; + swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */ + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */ + /* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */ +#else + if (usingXAML) { + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + } else { + swapChainDesc.Scaling = DXGI_SCALING_NONE; + } + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */ +#endif + swapChainDesc.Flags = 0; + + if (coreWindow) { + result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + coreWindow, + &swapChainDesc, + NULL, /* Allow on all displays. */ + &data->swapChain + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result); + goto done; + } + } else if (usingXAML) { + result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + &swapChainDesc, + NULL, + &data->swapChain); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForComposition"), result); + goto done; + } + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP + result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ISwapChainBackgroundPanelNative::SetSwapChain"), result); + goto done; + } +#else + SDL_SetError(SDL_COMPOSE_ERROR("XAML support is not yet available for Windows Phone")); + result = E_FAIL; + goto done; +#endif + } else { +#ifdef __WIN32__ + SDL_SysWMinfo windowinfo; + SDL_VERSION(&windowinfo.version); + SDL_GetWindowWMInfo(renderer->window, &windowinfo); + + result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + windowinfo.info.win.window, + &swapChainDesc, + NULL, + NULL, /* Allow on all displays. */ + &data->swapChain + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); + goto done; + } + + IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES); +#else + SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to"); + goto done; +#endif /* ifdef __WIN32__ / else */ + } + data->swapEffect = swapChainDesc.SwapEffect; + +done: + SAFE_RELEASE(coreWindow); + return result; +} + + +/* Initialize all resources that change when the window's size changes. */ +static HRESULT +D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + ID3D11Texture2D *backBuffer = NULL; + HRESULT result = S_OK; + int w, h; + + /* Release the previous render target view */ + D3D11_ReleaseMainRenderTargetView(renderer); + + /* The width and height of the swap chain must be based on the display's + * non-rotated size. + */ + SDL_GetWindowSize(renderer->window, &w, &h); + data->rotation = D3D11_GetCurrentRotation(); + /* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */ + if (D3D11_IsDisplayRotated90Degrees(data->rotation)) { + int tmp = w; + w = h; + h = tmp; + } + + if (data->swapChain) { + /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */ +#if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) + /* If the swap chain already exists, resize it. */ + result = IDXGISwapChain_ResizeBuffers(data->swapChain, + 0, + w, h, + DXGI_FORMAT_UNKNOWN, + 0 + ); + if (result == DXGI_ERROR_DEVICE_REMOVED) { + /* If the device was removed for any reason, a new device and swap chain will need to be created. */ + D3D11_HandleDeviceLost(renderer); + + /* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method + * and correctly set up the new device. + */ + goto done; + } else if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::ResizeBuffers"), result); + goto done; + } +#endif + } else { + result = D3D11_CreateSwapChain(renderer, w, h); + if (FAILED(result)) { + goto done; + } + } + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + /* Set the proper rotation for the swap chain. + * + * To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary + * on Windows Phone 8.0, nor is it supported there. + * + * IDXGISwapChain1::SetRotation does seem to be available on Windows Phone 8.1, + * however I've yet to find a way to make it work. It might have something to + * do with IDXGISwapChain::ResizeBuffers appearing to not being available on + * Windows Phone 8.1 (it wasn't on Windows Phone 8.0), but I'm not 100% sure of this. + * The call doesn't appear to be entirely necessary though, and is a performance-related + * call, at least according to the following page on MSDN: + * http://code.msdn.microsoft.com/windowsapps/DXGI-swap-chain-rotation-21d13d71 + * -- David L. + * + * TODO, WinRT: reexamine the docs for IDXGISwapChain1::SetRotation, see if might be available, usable, and prudent-to-call on WinPhone 8.1 + */ + if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { + result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::SetRotation"), result); + goto done; + } + } +#endif + + result = IDXGISwapChain_GetBuffer(data->swapChain, + 0, + &SDL_IID_ID3D11Texture2D, + (void **)&backBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::GetBuffer [back-buffer]"), result); + goto done; + } + + /* Create a render target view of the swap chain back buffer. */ + result = ID3D11Device_CreateRenderTargetView(data->d3dDevice, + (ID3D11Resource *)backBuffer, + NULL, + &data->mainRenderTargetView + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateRenderTargetView"), result); + goto done; + } + + if (D3D11_UpdateViewport(renderer) != 0) { + /* D3D11_UpdateViewport will set the SDL error if it fails. */ + result = E_FAIL; + goto done; + } + +done: + SAFE_RELEASE(backBuffer); + return result; +} + +/* This method is called when the window's size changes. */ +static HRESULT +D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer) +{ + return D3D11_CreateWindowSizeDependentResources(renderer); +} + +HRESULT +D3D11_HandleDeviceLost(SDL_Renderer * renderer) +{ + HRESULT result = S_OK; + + D3D11_ReleaseAll(renderer); + + result = D3D11_CreateDeviceResources(renderer); + if (FAILED(result)) { + /* D3D11_CreateDeviceResources will set the SDL error */ + return result; + } + + result = D3D11_UpdateForWindowSizeChange(renderer); + if (FAILED(result)) { + /* D3D11_UpdateForWindowSizeChange will set the SDL error */ + return result; + } + + /* Let the application know that the device has been reset */ + { + SDL_Event event; + event.type = SDL_RENDER_DEVICE_RESET; + SDL_PushEvent(&event); + } + + return S_OK; +} + +void +D3D11_Trim(SDL_Renderer * renderer) +{ +#ifdef __WINRT__ +#if NTDDI_VERSION > NTDDI_WIN8 + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + HRESULT result = S_OK; + IDXGIDevice3 *dxgiDevice = NULL; + + result = ID3D11Device_QueryInterface(data->d3dDevice, &SDL_IID_IDXGIDevice3, &dxgiDevice); + if (FAILED(result)) { + //WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result); + return; + } + + IDXGIDevice3_Trim(dxgiDevice); + SAFE_RELEASE(dxgiDevice); +#endif +#endif +} + +static void +D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + D3D11_UpdateForWindowSizeChange(renderer); + } +} + +static SDL_bool +D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (!GetBlendFunc(srcColorFactor) || !GetBlendFunc(srcAlphaFactor) || + !GetBlendEquation(colorOperation) || + !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) || + !GetBlendEquation(alphaOperation)) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int +D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData; + HRESULT result; + DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format); + D3D11_TEXTURE2D_DESC textureDesc; + D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc; + + if (textureFormat == DXGI_FORMAT_UNKNOWN) { + return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", + __FUNCTION__, texture->format); + } + + textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData)); + if (!textureData) { + SDL_OutOfMemory(); + return -1; + } + textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; + + texture->driverdata = textureData; + + SDL_zero(textureDesc); + textureDesc.Width = texture->w; + textureDesc.Height = texture->h; + textureDesc.MipLevels = 1; + textureDesc.ArraySize = 1; + textureDesc.Format = textureFormat; + textureDesc.SampleDesc.Count = 1; + textureDesc.SampleDesc.Quality = 0; + textureDesc.MiscFlags = 0; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + textureDesc.Usage = D3D11_USAGE_DYNAMIC; + textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } else { + textureDesc.Usage = D3D11_USAGE_DEFAULT; + textureDesc.CPUAccessFlags = 0; + } + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + } else { + textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + } + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTexture + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); + return -1; + } + + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + textureData->yuv = SDL_TRUE; + + textureDesc.Width = (textureDesc.Width + 1) / 2; + textureDesc.Height = (textureDesc.Height + 1) / 2; + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTextureU + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); + return -1; + } + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTextureV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); + return -1; + } + } + + if (texture->format == SDL_PIXELFORMAT_NV12 || + texture->format == SDL_PIXELFORMAT_NV21) { + D3D11_TEXTURE2D_DESC nvTextureDesc = textureDesc; + + textureData->nv12 = SDL_TRUE; + + nvTextureDesc.Format = DXGI_FORMAT_R8G8_UNORM; + nvTextureDesc.Width = (textureDesc.Width + 1) / 2; + nvTextureDesc.Height = (textureDesc.Height + 1) / 2; + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &nvTextureDesc, + NULL, + &textureData->mainTextureNV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); + return -1; + } + } + + resourceViewDesc.Format = textureDesc.Format; + resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + resourceViewDesc.Texture2D.MostDetailedMip = 0; + resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTexture, + &resourceViewDesc, + &textureData->mainTextureResourceView + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); + return -1; + } + + if (textureData->yuv) { + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTextureU, + &resourceViewDesc, + &textureData->mainTextureResourceViewU + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); + return -1; + } + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTextureV, + &resourceViewDesc, + &textureData->mainTextureResourceViewV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); + return -1; + } + } + + if (textureData->nv12) { + D3D11_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc; + + nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; + + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTextureNV, + &nvResourceViewDesc, + &textureData->mainTextureResourceViewNV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); + return -1; + } + } + + if (texture->access & SDL_TEXTUREACCESS_TARGET) { + D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc; + renderTargetViewDesc.Format = textureDesc.Format; + renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + renderTargetViewDesc.Texture2D.MipSlice = 0; + + result = ID3D11Device_CreateRenderTargetView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTexture, + &renderTargetViewDesc, + &textureData->mainTextureRenderTargetView); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); + return -1; + } + } + + return 0; +} + +static void +D3D11_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture) +{ + D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; + + if (!data) { + return; + } + + SAFE_RELEASE(data->mainTexture); + SAFE_RELEASE(data->mainTextureResourceView); + SAFE_RELEASE(data->mainTextureRenderTargetView); + SAFE_RELEASE(data->stagingTexture); + SAFE_RELEASE(data->mainTextureU); + SAFE_RELEASE(data->mainTextureResourceViewU); + SAFE_RELEASE(data->mainTextureV); + SAFE_RELEASE(data->mainTextureResourceViewV); + SDL_free(data->pixels); + SDL_free(data); + texture->driverdata = NULL; +} + +static int +D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch) +{ + ID3D11Texture2D *stagingTexture; + const Uint8 *src; + Uint8 *dst; + int row; + UINT length; + HRESULT result; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + /* Create a 'staging' texture, which will be used to write to a portion of the main texture. */ + ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc); + stagingTextureDesc.Width = w; + stagingTextureDesc.Height = h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &stagingTextureDesc, + NULL, + &stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); + return -1; + } + + /* Get a write-only pointer to data in the staging texture: */ + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); + SAFE_RELEASE(stagingTexture); + return -1; + } + + src = (const Uint8 *)pixels; + dst = textureMemory.pData; + length = w * bpp; + if (length == pitch && length == textureMemory.RowPitch) { + SDL_memcpy(dst, src, length*h); + } else { + if (length > (UINT)pitch) { + length = pitch; + } + if (length > textureMemory.RowPitch) { + length = textureMemory.RowPitch; + } + for (row = 0; row < h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += textureMemory.RowPitch; + } + } + + /* Commit the pixel buffer's changes back to the staging texture: */ + ID3D11DeviceContext_Unmap(rendererData->d3dContext, + (ID3D11Resource *)stagingTexture, + 0); + + /* Copy the staging texture's contents back to the texture: */ + ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, + (ID3D11Resource *)texture, + 0, + x, + y, + 0, + (ID3D11Resource *)stagingTexture, + 0, + NULL); + + SAFE_RELEASE(stagingTexture); + + return 0; +} + +static int +D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void * srcPixels, + int srcPitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) { + return -1; + } + + if (textureData->yuv) { + /* Skip to the correct offset into the next texture */ + srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + + if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) { + return -1; + } + + /* Skip to the correct offset into the next texture */ + srcPixels = (const void*)((const Uint8*)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); + if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) { + return -1; + } + } + + if (textureData->nv12) { + /* Skip to the correct offset into the next texture */ + srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2*((srcPitch + 1) / 2)) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; +} + +static int +D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + HRESULT result = S_OK; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (textureData->yuv || textureData->nv12) { + /* It's more efficient to upload directly... */ + if (!textureData->pixels) { + textureData->pitch = texture->w; + textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2); + if (!textureData->pixels) { + return SDL_OutOfMemory(); + } + } + textureData->locked_rect = *rect; + *pixels = + (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = textureData->pitch; + return 0; + } + + if (textureData->stagingTexture) { + return SDL_SetError("texture is already locked"); + } + + /* Create a 'staging' texture, which will be used to write to a portion + * of the main texture. This is necessary, as Direct3D 11.1 does not + * have the ability to write a CPU-bound pixel buffer to a rectangular + * subrect of a texture. Direct3D 11.1 can, however, write a pixel + * buffer to an entire texture, hence the use of a staging texture. + * + * TODO, WinRT: consider avoiding the use of a staging texture in D3D11_LockTexture if/when the entire texture is being updated + */ + ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); + stagingTextureDesc.Width = rect->w; + stagingTextureDesc.Height = rect->h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &stagingTextureDesc, + NULL, + &textureData->stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); + return -1; + } + + /* Get a write-only pointer to data in the staging texture: */ + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)textureData->stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); + SAFE_RELEASE(textureData->stagingTexture); + return -1; + } + + /* Make note of where the staging texture will be written to + * (on a call to SDL_UnlockTexture): + */ + textureData->lockedTexturePositionX = rect->x; + textureData->lockedTexturePositionY = rect->y; + + /* Make sure the caller has information on the texture's pixel buffer, + * then return: + */ + *pixels = textureMemory.pData; + *pitch = textureMemory.RowPitch; + return 0; +} + +static void +D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + + if (!textureData) { + return; + } + + if (textureData->yuv || textureData->nv12) { + const SDL_Rect *rect = &textureData->locked_rect; + void *pixels = + (void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch); + return; + } + + /* Commit the pixel buffer's changes back to the staging texture: */ + ID3D11DeviceContext_Unmap(rendererData->d3dContext, + (ID3D11Resource *)textureData->stagingTexture, + 0); + + /* Copy the staging texture's contents back to the main texture: */ + ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, + (ID3D11Resource *)textureData->mainTexture, + 0, + textureData->lockedTexturePositionX, + textureData->lockedTexturePositionY, + 0, + (ID3D11Resource *)textureData->stagingTexture, + 0, + NULL); + + SAFE_RELEASE(textureData->stagingTexture); +} + +static int +D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = NULL; + + if (texture == NULL) { + rendererData->currentOffscreenRenderTargetView = NULL; + return 0; + } + + textureData = (D3D11_TextureData *) texture->driverdata; + + if (!textureData->mainTextureRenderTargetView) { + return SDL_SetError("specified texture is not a render target"); + } + + rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView; + + return 0; +} + +static void +D3D11_SetModelMatrix(SDL_Renderer *renderer, const Float4X4 *matrix) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + + if (matrix) { + data->vertexShaderConstantsData.model = *matrix; + } else { + data->vertexShaderConstantsData.model = MatrixIdentity(); + } + + ID3D11DeviceContext_UpdateSubresource(data->d3dContext, + (ID3D11Resource *)data->vertexShaderConstants, + 0, + NULL, + &data->vertexShaderConstantsData, + 0, + 0 + ); +} + +static int +D3D11_UpdateViewport(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + Float4X4 projection; + Float4X4 view; + SDL_FRect orientationAlignedViewport; + BOOL swapDimensions; + D3D11_VIEWPORT viewport; + const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer); + + if (renderer->viewport.w == 0 || renderer->viewport.h == 0) { + /* If the viewport is empty, assume that it is because + * SDL_CreateRenderer is calling it, and will call it again later + * with a non-empty viewport. + */ + /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */ + return 0; + } + + /* Make sure the SDL viewport gets rotated to that of the physical display's rotation. + * Keep in mind here that the Y-axis will be been inverted (from Direct3D's + * default coordinate system) so rotations will be done in the opposite + * direction of the DXGI_MODE_ROTATION enumeration. + */ + switch (rotation) { + case DXGI_MODE_ROTATION_IDENTITY: + projection = MatrixIdentity(); + break; + case DXGI_MODE_ROTATION_ROTATE270: + projection = MatrixRotationZ(SDL_static_cast(float, M_PI * 0.5f)); + break; + case DXGI_MODE_ROTATION_ROTATE180: + projection = MatrixRotationZ(SDL_static_cast(float, M_PI)); + break; + case DXGI_MODE_ROTATION_ROTATE90: + projection = MatrixRotationZ(SDL_static_cast(float, -M_PI * 0.5f)); + break; + default: + return SDL_SetError("An unknown DisplayOrientation is being used"); + } + + /* Update the view matrix */ + view.m[0][0] = 2.0f / renderer->viewport.w; + view.m[0][1] = 0.0f; + view.m[0][2] = 0.0f; + view.m[0][3] = 0.0f; + view.m[1][0] = 0.0f; + view.m[1][1] = -2.0f / renderer->viewport.h; + view.m[1][2] = 0.0f; + view.m[1][3] = 0.0f; + view.m[2][0] = 0.0f; + view.m[2][1] = 0.0f; + view.m[2][2] = 1.0f; + view.m[2][3] = 0.0f; + view.m[3][0] = -1.0f; + view.m[3][1] = 1.0f; + view.m[3][2] = 0.0f; + view.m[3][3] = 1.0f; + + /* Combine the projection + view matrix together now, as both only get + * set here (as of this writing, on Dec 26, 2013). When done, store it + * for eventual transfer to the GPU. + */ + data->vertexShaderConstantsData.projectionAndView = MatrixMultiply( + view, + projection); + + /* Reset the model matrix */ + D3D11_SetModelMatrix(renderer, NULL); + + /* Update the Direct3D viewport, which seems to be aligned to the + * swap buffer's coordinate space, which is always in either + * a landscape mode, for all Windows 8/RT devices, or a portrait mode, + * for Windows Phone devices. + */ + swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation); + if (swapDimensions) { + orientationAlignedViewport.x = (float) renderer->viewport.y; + orientationAlignedViewport.y = (float) renderer->viewport.x; + orientationAlignedViewport.w = (float) renderer->viewport.h; + orientationAlignedViewport.h = (float) renderer->viewport.w; + } else { + orientationAlignedViewport.x = (float) renderer->viewport.x; + orientationAlignedViewport.y = (float) renderer->viewport.y; + orientationAlignedViewport.w = (float) renderer->viewport.w; + orientationAlignedViewport.h = (float) renderer->viewport.h; + } + /* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */ + + viewport.TopLeftX = orientationAlignedViewport.x; + viewport.TopLeftY = orientationAlignedViewport.y; + viewport.Width = orientationAlignedViewport.w; + viewport.Height = orientationAlignedViewport.h; + viewport.MinDepth = 0.0f; + viewport.MaxDepth = 1.0f; + /* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, viewport.TopLeftX, viewport.TopLeftY, viewport.Width, viewport.Height); */ + ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &viewport); + + return 0; +} + +static int +D3D11_UpdateClipRect(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + + if (!renderer->clipping_enabled) { + ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 0, NULL); + } else { + D3D11_RECT scissorRect; + if (D3D11_GetViewportAlignedD3DRect(renderer, &renderer->clip_rect, &scissorRect, TRUE) != 0) { + /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + return -1; + } + ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 1, &scissorRect); + } + + return 0; +} + +static void +D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL); + SAFE_RELEASE(data->mainRenderTargetView); +} + +static ID3D11RenderTargetView * +D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + if (data->currentOffscreenRenderTargetView) { + return data->currentOffscreenRenderTargetView; + } else { + return data->mainRenderTargetView; + } +} + +static int +D3D11_RenderClear(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + const float colorRGBA[] = { + (renderer->r / 255.0f), + (renderer->g / 255.0f), + (renderer->b / 255.0f), + (renderer->a / 255.0f) + }; + ID3D11DeviceContext_ClearRenderTargetView(data->d3dContext, + D3D11_GetCurrentRenderTargetView(renderer), + colorRGBA + ); + return 0; +} + +static int +D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, + const void * vertexData, size_t dataSizeInBytes) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_BUFFER_DESC vertexBufferDesc; + HRESULT result = S_OK; + D3D11_SUBRESOURCE_DATA vertexBufferData; + const UINT stride = sizeof(VertexPositionColor); + const UINT offset = 0; + + if (rendererData->vertexBuffer) { + ID3D11Buffer_GetDesc(rendererData->vertexBuffer, &vertexBufferDesc); + } else { + SDL_zero(vertexBufferDesc); + } + + if (rendererData->vertexBuffer && vertexBufferDesc.ByteWidth >= dataSizeInBytes) { + D3D11_MAPPED_SUBRESOURCE mappedResource; + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)rendererData->vertexBuffer, + 0, + D3D11_MAP_WRITE_DISCARD, + 0, + &mappedResource + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); + return -1; + } + SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes); + ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffer, 0); + } else { + SAFE_RELEASE(rendererData->vertexBuffer); + + vertexBufferDesc.ByteWidth = (UINT) dataSizeInBytes; + vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + SDL_zero(vertexBufferData); + vertexBufferData.pSysMem = vertexData; + vertexBufferData.SysMemPitch = 0; + vertexBufferData.SysMemSlicePitch = 0; + + result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, + &vertexBufferDesc, + &vertexBufferData, + &rendererData->vertexBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); + return -1; + } + + ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext, + 0, + 1, + &rendererData->vertexBuffer, + &stride, + &offset + ); + } + + return 0; +} + +static void +D3D11_RenderStartDrawOp(SDL_Renderer * renderer) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + ID3D11RasterizerState *rasterizerState; + ID3D11RenderTargetView *renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); + if (renderTargetView != rendererData->currentRenderTargetView) { + ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, + 1, + &renderTargetView, + NULL + ); + rendererData->currentRenderTargetView = renderTargetView; + } + + if (!renderer->clipping_enabled) { + rasterizerState = rendererData->mainRasterizer; + } else { + rasterizerState = rendererData->clippedRasterizer; + } + if (rasterizerState != rendererData->currentRasterizerState) { + ID3D11DeviceContext_RSSetState(rendererData->d3dContext, rasterizerState); + rendererData->currentRasterizerState = rasterizerState; + } +} + +static void +D3D11_RenderSetBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + ID3D11BlendState *blendState = NULL; + if (blendMode != SDL_BLENDMODE_NONE) { + int i; + for (i = 0; i < rendererData->blendModesCount; ++i) { + if (blendMode == rendererData->blendModes[i].blendMode) { + blendState = rendererData->blendModes[i].blendState; + break; + } + } + if (!blendState) { + if (D3D11_CreateBlendState(renderer, blendMode)) { + /* Successfully created the blend state, try again */ + D3D11_RenderSetBlendMode(renderer, blendMode); + } + return; + } + } + if (blendState != rendererData->currentBlendState) { + ID3D11DeviceContext_OMSetBlendState(rendererData->d3dContext, blendState, 0, 0xFFFFFFFF); + rendererData->currentBlendState = blendState; + } +} + +static void +D3D11_SetPixelShader(SDL_Renderer * renderer, + ID3D11PixelShader * shader, + int numShaderResources, + ID3D11ShaderResourceView ** shaderResources, + ID3D11SamplerState * sampler) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + ID3D11ShaderResourceView *shaderResource; + if (shader != rendererData->currentShader) { + ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, shader, NULL, 0); + rendererData->currentShader = shader; + } + if (numShaderResources > 0) { + shaderResource = shaderResources[0]; + } else { + shaderResource = NULL; + } + if (shaderResource != rendererData->currentShaderResource) { + ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, numShaderResources, shaderResources); + rendererData->currentShaderResource = shaderResource; + } + if (sampler != rendererData->currentSampler) { + ID3D11DeviceContext_PSSetSamplers(rendererData->d3dContext, 0, 1, &sampler); + rendererData->currentSampler = sampler; + } +} + +static void +D3D11_RenderFinishDrawOp(SDL_Renderer * renderer, + D3D11_PRIMITIVE_TOPOLOGY primitiveTopology, + UINT vertexCount) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + + ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, primitiveTopology); + ID3D11DeviceContext_Draw(rendererData->d3dContext, vertexCount, 0); +} + +static int +D3D11_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + VertexPositionColor *vertices; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + vertices = SDL_stack_alloc(VertexPositionColor, count); + for (i = 0; i < count; ++i) { + const VertexPositionColor v = { { points[i].x + 0.5f, points[i].y + 0.5f, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }; + vertices[i] = v; + } + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) { + SDL_stack_free(vertices); + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[SHADER_SOLID], + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, count); + SDL_stack_free(vertices); + return 0; +} + +static int +D3D11_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + VertexPositionColor *vertices; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + vertices = SDL_stack_alloc(VertexPositionColor, count); + for (i = 0; i < count; ++i) { + const VertexPositionColor v = { { points[i].x + 0.5f, points[i].y + 0.5f, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }; + vertices[i] = v; + } + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) { + SDL_stack_free(vertices); + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[SHADER_SOLID], + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, count); + + if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) { + ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + ID3D11DeviceContext_Draw(rendererData->d3dContext, 1, count - 1); + } + + SDL_stack_free(vertices); + return 0; +} + +static int +D3D11_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + for (i = 0; i < count; ++i) { + VertexPositionColor vertices[] = { + { { rects[i].x, rects[i].y, 0.0f }, { 0.0f, 0.0f}, {r, g, b, a} }, + { { rects[i].x, rects[i].y + rects[i].h, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + { { rects[i].x + rects[i].w, rects[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + { { rects[i].x + rects[i].w, rects[i].y + rects[i].h, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + }; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[SHADER_SOLID], + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, SDL_arraysize(vertices)); + } + + return 0; +} + +static int +D3D11_RenderSetupSampler(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + ID3D11SamplerState *textureSampler; + + switch (textureData->scaleMode) { + case D3D11_FILTER_MIN_MAG_MIP_POINT: + textureSampler = rendererData->nearestPixelSampler; + break; + case D3D11_FILTER_MIN_MAG_MIP_LINEAR: + textureSampler = rendererData->linearSampler; + break; + default: + return SDL_SetError("Unknown scale mode: %d\n", textureData->scaleMode); + } + + if (textureData->yuv) { + ID3D11ShaderResourceView *shaderResources[] = { + textureData->mainTextureResourceView, + textureData->mainTextureResourceViewU, + textureData->mainTextureResourceViewV + }; + D3D11_Shader shader; + + switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { + case SDL_YUV_CONVERSION_JPEG: + shader = SHADER_YUV_JPEG; + break; + case SDL_YUV_CONVERSION_BT601: + shader = SHADER_YUV_BT601; + break; + case SDL_YUV_CONVERSION_BT709: + shader = SHADER_YUV_BT709; + break; + default: + return SDL_SetError("Unsupported YUV conversion mode"); + } + + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[shader], + SDL_arraysize(shaderResources), + shaderResources, + textureSampler); + + } else if (textureData->nv12) { + ID3D11ShaderResourceView *shaderResources[] = { + textureData->mainTextureResourceView, + textureData->mainTextureResourceViewNV, + }; + D3D11_Shader shader; + + switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { + case SDL_YUV_CONVERSION_JPEG: + shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_JPEG : SHADER_NV21_JPEG; + break; + case SDL_YUV_CONVERSION_BT601: + shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_BT601 : SHADER_NV21_BT601; + break; + case SDL_YUV_CONVERSION_BT709: + shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_BT709 : SHADER_NV21_BT709; + break; + default: + return SDL_SetError("Unsupported YUV conversion mode"); + } + + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[shader], + SDL_arraysize(shaderResources), + shaderResources, + textureSampler); + + } else { + D3D11_SetPixelShader( + renderer, + rendererData->pixelShaders[SHADER_RGB], + 1, + &textureData->mainTextureResourceView, + textureSampler); + } + + return 0; +} + +static int +D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + float minu, maxu, minv, maxv; + Float4 color; + VertexPositionColor vertices[4]; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, texture->blendMode); + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + color.x = 1.0f; /* red */ + color.y = 1.0f; /* green */ + color.z = 1.0f; /* blue */ + color.w = 1.0f; /* alpha */ + if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + color.x = (float)(texture->r / 255.0f); /* red */ + color.y = (float)(texture->g / 255.0f); /* green */ + color.z = (float)(texture->b / 255.0f); /* blue */ + } + if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { + color.w = (float)(texture->a / 255.0f); /* alpha */ + } + + vertices[0].pos.x = dstrect->x; + vertices[0].pos.y = dstrect->y; + vertices[0].pos.z = 0.0f; + vertices[0].tex.x = minu; + vertices[0].tex.y = minv; + vertices[0].color = color; + + vertices[1].pos.x = dstrect->x; + vertices[1].pos.y = dstrect->y + dstrect->h; + vertices[1].pos.z = 0.0f; + vertices[1].tex.x = minu; + vertices[1].tex.y = maxv; + vertices[1].color = color; + + vertices[2].pos.x = dstrect->x + dstrect->w; + vertices[2].pos.y = dstrect->y; + vertices[2].pos.z = 0.0f; + vertices[2].tex.x = maxu; + vertices[2].tex.y = minv; + vertices[2].color = color; + + vertices[3].pos.x = dstrect->x + dstrect->w; + vertices[3].pos.y = dstrect->y + dstrect->h; + vertices[3].pos.z = 0.0f; + vertices[3].tex.x = maxu; + vertices[3].tex.y = maxv; + vertices[3].color = color; + + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + if (D3D11_RenderSetupSampler(renderer, texture) < 0) { + return -1; + } + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor)); + + return 0; +} + +static int +D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip) +{ + float minu, maxu, minv, maxv; + Float4 color; + Float4X4 modelMatrix; + float minx, maxx, miny, maxy; + VertexPositionColor vertices[4]; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, texture->blendMode); + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + color.x = 1.0f; /* red */ + color.y = 1.0f; /* green */ + color.z = 1.0f; /* blue */ + color.w = 1.0f; /* alpha */ + if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + color.x = (float)(texture->r / 255.0f); /* red */ + color.y = (float)(texture->g / 255.0f); /* green */ + color.z = (float)(texture->b / 255.0f); /* blue */ + } + if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { + color.w = (float)(texture->a / 255.0f); /* alpha */ + } + + if (flip & SDL_FLIP_HORIZONTAL) { + float tmp = maxu; + maxu = minu; + minu = tmp; + } + if (flip & SDL_FLIP_VERTICAL) { + float tmp = maxv; + maxv = minv; + minv = tmp; + } + + modelMatrix = MatrixMultiply( + MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)), + MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0) + ); + D3D11_SetModelMatrix(renderer, &modelMatrix); + + minx = -center->x; + maxx = dstrect->w - center->x; + miny = -center->y; + maxy = dstrect->h - center->y; + + vertices[0].pos.x = minx; + vertices[0].pos.y = miny; + vertices[0].pos.z = 0.0f; + vertices[0].tex.x = minu; + vertices[0].tex.y = minv; + vertices[0].color = color; + + vertices[1].pos.x = minx; + vertices[1].pos.y = maxy; + vertices[1].pos.z = 0.0f; + vertices[1].tex.x = minu; + vertices[1].tex.y = maxv; + vertices[1].color = color; + + vertices[2].pos.x = maxx; + vertices[2].pos.y = miny; + vertices[2].pos.z = 0.0f; + vertices[2].tex.x = maxu; + vertices[2].tex.y = minv; + vertices[2].color = color; + + vertices[3].pos.x = maxx; + vertices[3].pos.y = maxy; + vertices[3].pos.z = 0.0f; + vertices[3].tex.x = maxu; + vertices[3].tex.y = maxv; + vertices[3].color = color; + + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + if (D3D11_RenderSetupSampler(renderer, texture) < 0) { + return -1; + } + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor)); + + D3D11_SetModelMatrix(renderer, NULL); + + return 0; +} + +static int +D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + D3D11_RenderData * data = (D3D11_RenderData *) renderer->driverdata; + ID3D11Texture2D *backBuffer = NULL; + ID3D11Texture2D *stagingTexture = NULL; + HRESULT result; + int status = -1; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_RECT srcRect = {0, 0, 0, 0}; + D3D11_BOX srcBox; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + /* Retrieve a pointer to the back buffer: */ + result = IDXGISwapChain_GetBuffer(data->swapChain, + 0, + &SDL_IID_ID3D11Texture2D, + (void **)&backBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::GetBuffer [get back buffer]"), result); + goto done; + } + + /* Create a staging texture to copy the screen's data to: */ + ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc); + stagingTextureDesc.Width = rect->w; + stagingTextureDesc.Height = rect->h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(data->d3dDevice, + &stagingTextureDesc, + NULL, + &stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); + goto done; + } + + /* Copy the desired portion of the back buffer to the staging texture: */ + if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) { + /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + goto done; + } + + srcBox.left = srcRect.left; + srcBox.right = srcRect.right; + srcBox.top = srcRect.top; + srcBox.bottom = srcRect.bottom; + srcBox.front = 0; + srcBox.back = 1; + ID3D11DeviceContext_CopySubresourceRegion(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + 0, 0, 0, + (ID3D11Resource *)backBuffer, + 0, + &srcBox); + + /* Map the staging texture's data to CPU-accessible memory: */ + result = ID3D11DeviceContext_Map(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_READ, + 0, + &textureMemory); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); + goto done; + } + + /* Copy the data into the desired buffer, converting pixels to the + * desired format at the same time: + */ + if (SDL_ConvertPixels( + rect->w, rect->h, + D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format), + textureMemory.pData, + textureMemory.RowPitch, + format, + pixels, + pitch) != 0) { + /* When SDL_ConvertPixels fails, it'll have already set the format. + * Get the error message, and attach some extra data to it. + */ + char errorMessage[1024]; + SDL_snprintf(errorMessage, sizeof(errorMessage), "%s, Convert Pixels failed: %s", __FUNCTION__, SDL_GetError()); + SDL_SetError("%s", errorMessage); + goto done; + } + + /* Unmap the texture: */ + ID3D11DeviceContext_Unmap(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0); + + status = 0; + +done: + SAFE_RELEASE(backBuffer); + SAFE_RELEASE(stagingTexture); + return status; +} + +static void +D3D11_RenderPresent(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + UINT syncInterval; + UINT presentFlags; + HRESULT result; + DXGI_PRESENT_PARAMETERS parameters; + + SDL_zero(parameters); + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + syncInterval = 1; + presentFlags = 0; + result = IDXGISwapChain_Present(data->swapChain, syncInterval, presentFlags); +#else + if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { + syncInterval = 1; + presentFlags = 0; + } else { + syncInterval = 0; + presentFlags = DXGI_PRESENT_DO_NOT_WAIT; + } + + /* The application may optionally specify "dirty" or "scroll" + * rects to improve efficiency in certain scenarios. + * This option is not available on Windows Phone 8, to note. + */ + result = IDXGISwapChain1_Present1(data->swapChain, syncInterval, presentFlags, ¶meters); +#endif + + /* Discard the contents of the render target. + * This is a valid operation only when the existing contents will be entirely + * overwritten. If dirty or scroll rects are used, this call should be removed. + */ + ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View*)data->mainRenderTargetView); + + /* When the present flips, it unbinds the current view, so bind it again on the next draw call */ + data->currentRenderTargetView = NULL; + + if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { + /* If the device was removed either by a disconnect or a driver upgrade, we + * must recreate all device resources. + * + * TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines + */ + if ( result == DXGI_ERROR_DEVICE_REMOVED ) { + D3D11_HandleDeviceLost(renderer); + } else if (result == DXGI_ERROR_INVALID_CALL) { + /* We probably went through a fullscreen <-> windowed transition */ + D3D11_CreateWindowSizeDependentResources(renderer); + } else { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result); + } + } +} + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.cpp b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.cpp new file mode 100644 index 0000000..2f2c3e5 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.cpp @@ -0,0 +1,116 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#include "SDL_syswm.h" +#include "../../video/winrt/SDL_winrtvideo_cpp.h" +extern "C" { +#include "../SDL_sysrender.h" +} + +#include <windows.ui.core.h> +#include <windows.graphics.display.h> + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +#include <windows.ui.xaml.media.dxinterop.h> +#endif + +using namespace Windows::UI::Core; +using namespace Windows::Graphics::Display; + +#include <DXGI.h> + +#include "SDL_render_winrt.h" + + +extern "C" void * +D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer) +{ + SDL_Window * sdlWindow = renderer->window; + if ( ! renderer->window ) { + return NULL; + } + + SDL_SysWMinfo sdlWindowInfo; + SDL_VERSION(&sdlWindowInfo.version); + if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) { + return NULL; + } + + if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) { + return NULL; + } + + if (!sdlWindowInfo.info.winrt.window) { + return NULL; + } + + ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL; + if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) { + return NULL; + } + + IUnknown *coreWindowAsIUnknown = NULL; + coreWindow->QueryInterface(&coreWindowAsIUnknown); + coreWindow->Release(); + + return coreWindowAsIUnknown; +} + +extern "C" DXGI_MODE_ROTATION +D3D11_GetCurrentRotation() +{ + const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); + + switch (currentOrientation) { + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + /* Windows Phone rotations */ + case DisplayOrientations::Landscape: + return DXGI_MODE_ROTATION_ROTATE90; + case DisplayOrientations::Portrait: + return DXGI_MODE_ROTATION_IDENTITY; + case DisplayOrientations::LandscapeFlipped: + return DXGI_MODE_ROTATION_ROTATE270; + case DisplayOrientations::PortraitFlipped: + return DXGI_MODE_ROTATION_ROTATE180; +#else + /* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */ + case DisplayOrientations::Landscape: + return DXGI_MODE_ROTATION_IDENTITY; + case DisplayOrientations::Portrait: + return DXGI_MODE_ROTATION_ROTATE270; + case DisplayOrientations::LandscapeFlipped: + return DXGI_MODE_ROTATION_ROTATE180; + case DisplayOrientations::PortraitFlipped: + return DXGI_MODE_ROTATION_ROTATE90; +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */ + } + + return DXGI_MODE_ROTATION_IDENTITY; +} + + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.h b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.h new file mode 100644 index 0000000..7bb8fb7 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d11/SDL_render_winrt.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#include "SDL_render.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer); +DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.c b/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.c new file mode 100644 index 0000000..f1277b9 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.c @@ -0,0 +1,1957 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#include "SDL_stdinc.h" + +#define COBJMACROS +#include "../../core/windows/SDL_windows.h" +#include <d3d11_1.h> + +#include "SDL_shaders_d3d11.h" + +#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str + + +/* Direct3D 11.x shaders + + SDL's shaders are compiled into SDL itself, to simplify distribution. + + All Direct3D 11.x shaders were compiled with the following: + + fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>" + + Variables: + - <TYPE>: the type of shader. A table of utilized shader types is + listed below. + - <OUTPUT FILE>: where to store compiled output + - <INPUT FILE>: where to read shader source code from + + Shader types: + - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT + - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT + - ps_4_0_level_9_3: Pixel shader for Windows Phone 8 + - vs_4_0_level_9_3: Vertex shader for Windows Phone 8 + + + Shader object code was converted to a list of DWORDs via the following + *nix style command (available separately from Windows + MSVC): + + hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE> + */ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#define D3D11_USE_SHADER_MODEL_4_0_level_9_3 +#else +#define D3D11_USE_SHADER_MODEL_4_0_level_9_1 +#endif + +/* The color-only-rendering pixel shader: + + --- D3D11_PixelShader_Colors.hlsl --- + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + return input.color; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_Colors[] = { + 0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001, + 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140, + 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, + 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001, + 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000, + 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, + 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, + 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_Colors[] = { + 0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001, + 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140, + 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, + 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001, + 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000, + 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, + 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, + 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'colors' pixel shader is not defined." +#endif + +/* The texture-rendering pixel shader: + + --- D3D11_PixelShader_Textures.hlsl --- + Texture2D theTexture : register(t0); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + return theTexture.Sample(theSampler, input.tex) * input.color; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_Textures[] = { + 0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001, + 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8, + 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200, + 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, + 0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000, + 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800, + 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000, + 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003, + 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8, + 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, + 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263, + 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, + 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_Textures[] = { + 0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001, + 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8, + 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200, + 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, + 0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000, + 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800, + 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000, + 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003, + 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8, + 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, + 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263, + 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, + 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'textures' pixel shader is not defined" +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_YUV_JPEG.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {0.0, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.0000, 0.0000, 1.4020}; + const float3 Gcoeff = {1.0000, -0.3441, -0.7141}; + const float3 Bcoeff = {1.0000, 1.7720, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_YUV_JPEG[] = { + 0x43425844, 0x10359e9c, 0x92c3d2c4, 0x00bf0cd5, 0x5ce8c499, 0x00000001, + 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438, + 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200, + 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051, + 0xa00f0000, 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, + 0xa00f0001, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051, + 0xa00f0002, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, + 0xa00f0003, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, + 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, + 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, + 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001, + 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, + 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000, + 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000, + 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000, + 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001, + 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002, + 0x00000000, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, + 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f800000, 0x3fb374bc, + 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246, + 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, + 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x05000036, 0x00100082, + 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, + 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, + 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c, + 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, + 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, + 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369, + 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, + 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_YUV_JPEG[] = { + 0x43425844, 0x616d6673, 0x83174178, 0x15aac25d, 0x2a340487, 0x00000001, + 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410, + 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200, + 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051, + 0xa00f0000, 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051, + 0xa00f0001, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, + 0xa00f0002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001, + 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001, + 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000, + 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000, 0x03000008, + 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001, 0x80e40000, + 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005, + 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, + 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, + 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, + 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000, + 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062, + 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001, + 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, + 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001, + 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, + 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, + 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, + 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, 0x00000000, + 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, + 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, + 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0, + 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, + 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, + 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, + 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000, + 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000, + 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, + 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478, + 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, + 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, + 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_YUV_BT601.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.5960}; + const float3 Gcoeff = {1.1644, -0.3918, -0.8130}; + const float3 Bcoeff = {1.1644, 2.0172, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_YUV_BT601[] = { + 0x43425844, 0x628ec838, 0xbe9cec6a, 0xc9ee10bb, 0x63283218, 0x00000001, + 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438, + 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200, + 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051, + 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, + 0xa00f0001, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, + 0xa00f0002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, + 0xa00f0003, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, + 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, + 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, + 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001, + 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, + 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000, + 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000, + 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000, + 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001, + 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002, + 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, + 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, 0x3fcc49ba, + 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246, + 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, + 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002, + 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x05000036, 0x00100082, + 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, + 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, + 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c, + 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, + 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, + 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369, + 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, + 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_YUV_BT601[] = { + 0x43425844, 0x692b159b, 0xf58723cc, 0xf4ceac9e, 0x35eec738, 0x00000001, + 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410, + 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200, + 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051, + 0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, + 0xa00f0001, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051, + 0xa00f0002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001, + 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001, + 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000, + 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008, + 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, + 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005, + 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, + 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, + 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, + 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000, + 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062, + 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001, + 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, + 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001, + 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, + 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, + 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, + 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, + 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, + 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, + 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02, + 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, + 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, + 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, + 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000, + 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000, + 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, + 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478, + 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, + 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, + 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_YUV_BT709.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.7927}; + const float3 Gcoeff = {1.1644, -0.2132, -0.5329}; + const float3 Bcoeff = {1.1644, 2.1124, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_YUV_BT709[] = { + 0x43425844, 0x5045fa84, 0xc2908cce, 0x278dacc3, 0xd4276f8f, 0x00000001, + 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438, + 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200, + 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051, + 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, + 0xa00f0001, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051, + 0xa00f0002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, + 0xa00f0003, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, + 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, + 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, + 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001, + 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, + 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000, + 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000, + 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000, + 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001, + 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002, + 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, + 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, 0x3fe57732, + 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246, + 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, + 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002, + 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x05000036, 0x00100082, + 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, + 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, + 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c, + 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, + 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, + 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369, + 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, + 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_YUV_BT709[] = { + 0x43425844, 0x72d13260, 0xf6c36f65, 0x8b9b28f5, 0x5010733c, 0x00000001, + 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410, + 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200, + 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051, + 0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, + 0xa00f0001, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051, + 0xa00f0002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001, + 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001, + 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000, + 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008, + 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, + 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005, + 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, + 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, + 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, + 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000, + 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062, + 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001, + 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, + 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001, + 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, + 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, + 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, + 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, + 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, + 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, + 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a, + 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, + 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, + 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, + 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000, + 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000, + 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, + 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478, + 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, + 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, + 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV12_JPEG.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {0.0, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.0000, 0.0000, 1.4020}; + const float3 Gcoeff = {1.0000, -0.3441, -0.7141}; + const float3 Bcoeff = {1.0000, 1.7720, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV12_JPEG[] = { + 0x43425844, 0x8fb9c77a, 0xe9e39686, 0x62b0e0e9, 0xd2bf8183, 0x00000001, + 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4, + 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200, + 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000, + 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, + 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, + 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, + 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, + 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, + 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001, + 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, + 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, + 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, + 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106, + 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, + 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, + 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f800000, + 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, + 0x00100246, 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0, 0xbf36cf42, + 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, + 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x05000036, + 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, + 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, + 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003, + 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003, + 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, + 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, + 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61, + 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478, + 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, + 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036, + 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV12_JPEG[] = { + 0x43425844, 0xe33e5d8b, 0x1b5f6461, 0x1afee99f, 0xcc345c04, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051, 0xa00f0001, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000, + 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV12_BT601.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.5960}; + const float3 Gcoeff = {1.1644, -0.3918, -0.8130}; + const float3 Bcoeff = {1.1644, 2.0172, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV12_BT601[] = { + 0x43425844, 0xd1d24a0c, 0x337c447a, 0x22b55cff, 0xb5c9c74b, 0x00000001, + 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4, + 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200, + 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000, + 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, + 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, + 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, + 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, + 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, + 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001, + 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, + 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, + 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, + 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106, + 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, + 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, + 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, + 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, + 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, + 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, + 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x05000036, + 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, + 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, + 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003, + 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003, + 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, + 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, + 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61, + 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478, + 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, + 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036, + 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV12_BT601[] = { + 0x43425844, 0x84b8b692, 0x589b9edd, 0x51ef2f0b, 0xf7247962, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, + 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV12_BT709.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.7927}; + const float3 Gcoeff = {1.1644, -0.2132, -0.5329}; + const float3 Bcoeff = {1.1644, 2.1124, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV12_BT709[] = { + 0x43425844, 0x40d1b8d5, 0xaf4b78b5, 0x907fd0b5, 0xa2d23686, 0x00000001, + 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4, + 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200, + 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000, + 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, + 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, + 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, + 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, + 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, + 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001, + 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, + 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, + 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, + 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106, + 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, + 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, + 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, + 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, + 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, + 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, + 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x05000036, + 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, + 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, + 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003, + 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003, + 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, + 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, + 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61, + 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478, + 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, + 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036, + 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV12_BT709[] = { + 0x43425844, 0xa3bba187, 0x71b6afa9, 0x15998682, 0x2d545cae, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, + 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV21_JPEG.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {0.0, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.0000, 0.0000, 1.4020}; + const float3 Gcoeff = {1.0000, -0.3441, -0.7141}; + const float3 Bcoeff = {1.0000, 1.7720, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV21_JPEG[] = { + 0x43425844, 0x9c41f579, 0xfd1019d8, 0x7c27e3ae, 0x52e3a5ff, 0x00000001, + 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0, + 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200, + 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001, + 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000, + 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001, + 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, + 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, + 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, + 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, + 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, + 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, + 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081, + 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, + 0x00000000, 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, + 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, + 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, + 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, + 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, + 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, + 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, + 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, + 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, + 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, + 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV21_JPEG[] = { + 0x43425844, 0x5705ccc9, 0xeb57571d, 0x8ce556e0, 0x2adef743, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051, 0xa00f0001, + 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000, + 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV21_BT601.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.5960}; + const float3 Gcoeff = {1.1644, -0.3918, -0.8130}; + const float3 Bcoeff = {1.1644, 2.0172, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV21_BT601[] = { + 0x43425844, 0x7fc6cfdc, 0xba87a4ff, 0xa72685a6, 0xa051b38c, 0x00000001, + 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0, + 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200, + 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001, + 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000, + 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001, + 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, + 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, + 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, + 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, + 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, + 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, + 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, + 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, + 0x00000000, 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, + 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, + 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, + 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, + 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, + 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, + 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, + 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, + 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, + 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, + 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV21_BT601[] = { + 0x43425844, 0x1e92bca4, 0xfeb04e20, 0x3f4226b1, 0xc89c58ad, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, + 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_NV21_BT709.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureUV : register(t1); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; + const float3 Rcoeff = {1.1644, 0.0000, 1.7927}; + const float3 Gcoeff = {1.1644, -0.2132, -0.5329}; + const float3 Bcoeff = {1.1644, 2.1124, 0.0000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_NV21_BT709[] = { + 0x43425844, 0x754ba6c4, 0xe321a747, 0x23680787, 0x6bb1bdcc, 0x00000001, + 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0, + 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200, + 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003, + 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, + 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001, + 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000, + 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001, + 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, + 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, + 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, + 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, + 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, + 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, + 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, + 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, + 0x00000000, 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, + 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, + 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, + 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, + 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, + 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, + 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, + 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, + 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, + 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, + 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_NV21_BT709[] = { + 0x43425844, 0xb6219b20, 0xb71bbcf7, 0xf361cc45, 0xc4d5f5be, 0x00000001, + 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c, + 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200, + 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002, + 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000, + 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001, + 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051, 0xa00f0002, + 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f, 0x80000000, + 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, + 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, + 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, + 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001, + 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, + 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, + 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, + 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, + 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064, + 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, + 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062, + 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, + 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, + 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, + 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, + 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, + 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, + 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, + 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002, + 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000, + 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, + 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004, + 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002, + 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, + 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, + 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, + 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, + 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, + 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003, + 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, + 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The sole vertex shader: + + --- D3D11_VertexShader.hlsl --- + #pragma pack_matrix( row_major ) + + cbuffer VertexShaderConstants : register(b0) + { + matrix model; + matrix projectionAndView; + }; + + struct VertexShaderInput + { + float3 pos : POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + struct VertexShaderOutput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + VertexShaderOutput main(VertexShaderInput input) + { + VertexShaderOutput output; + float4 pos = float4(input.pos, 1.0f); + + // Transform the vertex position into projected space. + pos = mul(pos, model); + pos = mul(pos, projectionAndView); + output.pos = pos; + + // Pass through texture coordinates and color values without transformation + output.tex = input.tex; + output.color = input.color; + + return output; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_VertexShader[] = { + 0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001, + 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0, + 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200, + 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, + 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200, + 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, + 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, + 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, + 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002, + 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, + 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, + 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, + 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000, + 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000, + 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002, + 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059, + 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000, + 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, + 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002, + 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, + 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003, + 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001, + 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2, + 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007, + 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046, + 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000, + 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054, + 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174, + 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000, + 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000, + 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077, + 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, + 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, + 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059, + 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062, + 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50, + 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_VertexShader[] = { + 0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001, + 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0, + 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200, + 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, + 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201, + 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, + 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, + 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, + 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002, + 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, + 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, + 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, + 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000, + 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000, + 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002, + 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059, + 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000, + 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, + 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002, + 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, + 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003, + 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001, + 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2, + 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007, + 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046, + 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000, + 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054, + 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174, + 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000, + 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000, + 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077, + 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, + 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, + 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059, + 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062, + 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50, + 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f +}; +#else +#error "An appropriate vertex shader is not defined." +#endif + +static struct +{ + const void *shader_data; + SIZE_T shader_size; +} D3D11_shaders[] = { + { D3D11_PixelShader_Colors, sizeof(D3D11_PixelShader_Colors) }, + { D3D11_PixelShader_Textures, sizeof(D3D11_PixelShader_Textures) }, + { D3D11_PixelShader_YUV_JPEG, sizeof(D3D11_PixelShader_YUV_JPEG) }, + { D3D11_PixelShader_YUV_BT601, sizeof(D3D11_PixelShader_YUV_BT601) }, + { D3D11_PixelShader_YUV_BT709, sizeof(D3D11_PixelShader_YUV_BT709) }, + { D3D11_PixelShader_NV12_JPEG, sizeof(D3D11_PixelShader_NV12_JPEG) }, + { D3D11_PixelShader_NV12_BT601, sizeof(D3D11_PixelShader_NV12_BT601) }, + { D3D11_PixelShader_NV12_BT709, sizeof(D3D11_PixelShader_NV12_BT709) }, + { D3D11_PixelShader_NV21_JPEG, sizeof(D3D11_PixelShader_NV21_JPEG) }, + { D3D11_PixelShader_NV21_BT601, sizeof(D3D11_PixelShader_NV21_BT601) }, + { D3D11_PixelShader_NV21_BT709, sizeof(D3D11_PixelShader_NV21_BT709) }, +}; + +int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout) +{ + /* Declare how the input layout for SDL's vertex shader will be setup: */ + const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + HRESULT result; + + /* Load in SDL's one and only vertex shader: */ + result = ID3D11Device_CreateVertexShader(d3dDevice, + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + NULL, + vertexShader + ); + if (FAILED(result)) { + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result); + } + + /* Create an input layout for SDL's vertex shader: */ + result = ID3D11Device_CreateInputLayout(d3dDevice, + vertexDesc, + ARRAYSIZE(vertexDesc), + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + inputLayout + ); + if (FAILED(result)) { + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result); + } + return 0; +} + +int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader) +{ + HRESULT result; + + result = ID3D11Device_CreatePixelShader(d3dDevice, + D3D11_shaders[shader].shader_data, + D3D11_shaders[shader].shader_size, + NULL, + pixelShader + ); + if (FAILED(result)) { + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result); + } + return 0; +} + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.h b/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.h new file mode 100644 index 0000000..b28b572 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/direct3d11/SDL_shaders_d3d11.h @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +/* D3D11 shader implementation */ + +typedef enum { + SHADER_SOLID, + SHADER_RGB, + SHADER_YUV_JPEG, + SHADER_YUV_BT601, + SHADER_YUV_BT709, + SHADER_NV12_JPEG, + SHADER_NV12_BT601, + SHADER_NV12_BT709, + SHADER_NV21_JPEG, + SHADER_NV21_BT601, + SHADER_NV21_BT709, + NUM_SHADERS +} D3D11_Shader; + +extern int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout); +extern int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/metal/SDL_render_metal.m b/source/3rd-party/SDL2/src/render/metal/SDL_render_metal.m new file mode 100644 index 0000000..5b4d8ea --- /dev/null +++ b/source/3rd-party/SDL2/src/render/metal/SDL_render_metal.m @@ -0,0 +1,1455 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_assert.h" +#include "SDL_syswm.h" +#include "../SDL_sysrender.h" + +#ifdef __MACOSX__ +#include "../../video/cocoa/SDL_cocoametalview.h" +#else +#include "../../video/uikit/SDL_uikitmetalview.h" +#endif +#include <Availability.h> +#import <Metal/Metal.h> +#import <QuartzCore/CAMetalLayer.h> + +/* Regenerate these with build-metal-shaders.sh */ +#ifdef __MACOSX__ +#include "SDL_shaders_metal_osx.h" +#else +#include "SDL_shaders_metal_ios.h" +#endif + +/* Apple Metal renderer implementation */ + +static SDL_Renderer *METAL_CreateRenderer(SDL_Window * window, Uint32 flags); +static void METAL_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int METAL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); +static SDL_bool METAL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static int METAL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void METAL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int METAL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int METAL_UpdateViewport(SDL_Renderer * renderer); +static int METAL_UpdateClipRect(SDL_Renderer * renderer); +static int METAL_RenderClear(SDL_Renderer * renderer); +static int METAL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int METAL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int METAL_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int METAL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int METAL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); +static int METAL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void METAL_RenderPresent(SDL_Renderer * renderer); +static void METAL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void METAL_DestroyRenderer(SDL_Renderer * renderer); +static void *METAL_GetMetalLayer(SDL_Renderer * renderer); +static void *METAL_GetMetalCommandEncoder(SDL_Renderer * renderer); + +SDL_RenderDriver METAL_RenderDriver = { + METAL_CreateRenderer, + { + "metal", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 6, + { + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 + }, + 0, 0, + } +}; + +/* macOS requires constants in a buffer to have a 256 byte alignment. */ +#ifdef __MACOSX__ +#define CONSTANT_ALIGN 256 +#else +#define CONSTANT_ALIGN 4 +#endif + +#define ALIGN_CONSTANTS(size) ((size + CONSTANT_ALIGN - 1) & (~(CONSTANT_ALIGN - 1))) + +static const size_t CONSTANTS_OFFSET_IDENTITY = 0; +static const size_t CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM = ALIGN_CONSTANTS(CONSTANTS_OFFSET_IDENTITY + sizeof(float) * 16); +static const size_t CONSTANTS_OFFSET_DECODE_JPEG = ALIGN_CONSTANTS(CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM + sizeof(float) * 16); +static const size_t CONSTANTS_OFFSET_DECODE_BT601 = ALIGN_CONSTANTS(CONSTANTS_OFFSET_DECODE_JPEG + sizeof(float) * 4 * 4); +static const size_t CONSTANTS_OFFSET_DECODE_BT709 = ALIGN_CONSTANTS(CONSTANTS_OFFSET_DECODE_BT601 + sizeof(float) * 4 * 4); +static const size_t CONSTANTS_OFFSET_CLEAR_VERTS = ALIGN_CONSTANTS(CONSTANTS_OFFSET_DECODE_BT709 + sizeof(float) * 4 * 4); +static const size_t CONSTANTS_LENGTH = CONSTANTS_OFFSET_CLEAR_VERTS + sizeof(float) * 6; + +typedef enum SDL_MetalVertexFunction +{ + SDL_METAL_VERTEX_SOLID, + SDL_METAL_VERTEX_COPY, +} SDL_MetalVertexFunction; + +typedef enum SDL_MetalFragmentFunction +{ + SDL_METAL_FRAGMENT_SOLID = 0, + SDL_METAL_FRAGMENT_COPY, + SDL_METAL_FRAGMENT_YUV, + SDL_METAL_FRAGMENT_NV12, + SDL_METAL_FRAGMENT_NV21, + SDL_METAL_FRAGMENT_COUNT, +} SDL_MetalFragmentFunction; + +typedef struct METAL_PipelineState +{ + SDL_BlendMode blendMode; + void *pipe; +} METAL_PipelineState; + +typedef struct METAL_PipelineCache +{ + METAL_PipelineState *states; + int count; + SDL_MetalVertexFunction vertexFunction; + SDL_MetalFragmentFunction fragmentFunction; + MTLPixelFormat renderTargetFormat; + const char *label; +} METAL_PipelineCache; + +/* Each shader combination used by drawing functions has a separate pipeline + * cache, and we have a separate list of caches for each render target pixel + * format. This is more efficient than iterating over a global cache to find + * the pipeline based on the specified shader combination and RT pixel format, + * since we know what the RT pixel format is when we set the render target, and + * we know what the shader combination is inside each drawing function's code. */ +typedef struct METAL_ShaderPipelines +{ + MTLPixelFormat renderTargetFormat; + METAL_PipelineCache caches[SDL_METAL_FRAGMENT_COUNT]; +} METAL_ShaderPipelines; + +@interface METAL_RenderData : NSObject + @property (nonatomic, retain) id<MTLDevice> mtldevice; + @property (nonatomic, retain) id<MTLCommandQueue> mtlcmdqueue; + @property (nonatomic, retain) id<MTLCommandBuffer> mtlcmdbuffer; + @property (nonatomic, retain) id<MTLRenderCommandEncoder> mtlcmdencoder; + @property (nonatomic, retain) id<MTLLibrary> mtllibrary; + @property (nonatomic, retain) id<CAMetalDrawable> mtlbackbuffer; + @property (nonatomic, retain) id<MTLSamplerState> mtlsamplernearest; + @property (nonatomic, retain) id<MTLSamplerState> mtlsamplerlinear; + @property (nonatomic, retain) id<MTLBuffer> mtlbufconstants; + @property (nonatomic, retain) CAMetalLayer *mtllayer; + @property (nonatomic, retain) MTLRenderPassDescriptor *mtlpassdesc; + @property (nonatomic, assign) METAL_ShaderPipelines *activepipelines; + @property (nonatomic, assign) METAL_ShaderPipelines *allpipelines; + @property (nonatomic, assign) int pipelinescount; +@end + +@implementation METAL_RenderData +#if !__has_feature(objc_arc) +- (void)dealloc +{ + [_mtldevice release]; + [_mtlcmdqueue release]; + [_mtlcmdbuffer release]; + [_mtlcmdencoder release]; + [_mtllibrary release]; + [_mtlbackbuffer release]; + [_mtlsamplernearest release]; + [_mtlsamplerlinear release]; + [_mtlbufconstants release]; + [_mtllayer release]; + [_mtlpassdesc release]; + [super dealloc]; +} +#endif +@end + +@interface METAL_TextureData : NSObject + @property (nonatomic, retain) id<MTLTexture> mtltexture; + @property (nonatomic, retain) id<MTLTexture> mtltexture_uv; + @property (nonatomic, retain) id<MTLSamplerState> mtlsampler; + @property (nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction; + @property (nonatomic, assign) BOOL yuv; + @property (nonatomic, assign) BOOL nv12; + @property (nonatomic, assign) size_t conversionBufferOffset; +@end + +@implementation METAL_TextureData +#if !__has_feature(objc_arc) +- (void)dealloc +{ + [_mtltexture release]; + [_mtltexture_uv release]; + [_mtlsampler release]; + [super dealloc]; +} +#endif +@end + +static int +IsMetalAvailable(const SDL_SysWMinfo *syswm) +{ + if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) { + return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment."); + } + + // this checks a weak symbol. +#if (defined(__MACOSX__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100)) + if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower. + return SDL_SetError("Metal framework not available on this system"); + } +#endif + + return 0; +} + +static const MTLBlendOperation invalidBlendOperation = (MTLBlendOperation)0xFFFFFFFF; +static const MTLBlendFactor invalidBlendFactor = (MTLBlendFactor)0xFFFFFFFF; + +static MTLBlendOperation +GetBlendOperation(SDL_BlendOperation operation) +{ + switch (operation) { + case SDL_BLENDOPERATION_ADD: return MTLBlendOperationAdd; + case SDL_BLENDOPERATION_SUBTRACT: return MTLBlendOperationSubtract; + case SDL_BLENDOPERATION_REV_SUBTRACT: return MTLBlendOperationReverseSubtract; + case SDL_BLENDOPERATION_MINIMUM: return MTLBlendOperationMin; + case SDL_BLENDOPERATION_MAXIMUM: return MTLBlendOperationMax; + default: return invalidBlendOperation; + } +} + +static MTLBlendFactor +GetBlendFactor(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: return MTLBlendFactorZero; + case SDL_BLENDFACTOR_ONE: return MTLBlendFactorOne; + case SDL_BLENDFACTOR_SRC_COLOR: return MTLBlendFactorSourceColor; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return MTLBlendFactorOneMinusSourceColor; + case SDL_BLENDFACTOR_SRC_ALPHA: return MTLBlendFactorSourceAlpha; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; + case SDL_BLENDFACTOR_DST_COLOR: return MTLBlendFactorDestinationColor; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: return MTLBlendFactorOneMinusDestinationColor; + case SDL_BLENDFACTOR_DST_ALPHA: return MTLBlendFactorDestinationAlpha; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; + default: return invalidBlendFactor; + } +} + +static NSString * +GetVertexFunctionName(SDL_MetalVertexFunction function) +{ + switch (function) { + case SDL_METAL_VERTEX_SOLID: return @"SDL_Solid_vertex"; + case SDL_METAL_VERTEX_COPY: return @"SDL_Copy_vertex"; + default: return nil; + } +} + +static NSString * +GetFragmentFunctionName(SDL_MetalFragmentFunction function) +{ + switch (function) { + case SDL_METAL_FRAGMENT_SOLID: return @"SDL_Solid_fragment"; + case SDL_METAL_FRAGMENT_COPY: return @"SDL_Copy_fragment"; + case SDL_METAL_FRAGMENT_YUV: return @"SDL_YUV_fragment"; + case SDL_METAL_FRAGMENT_NV12: return @"SDL_NV12_fragment"; + case SDL_METAL_FRAGMENT_NV21: return @"SDL_NV21_fragment"; + default: return nil; + } +} + +static id<MTLRenderPipelineState> +MakePipelineState(METAL_RenderData *data, METAL_PipelineCache *cache, + NSString *blendlabel, SDL_BlendMode blendmode) +{ + id<MTLFunction> mtlvertfn = [data.mtllibrary newFunctionWithName:GetVertexFunctionName(cache->vertexFunction)]; + id<MTLFunction> mtlfragfn = [data.mtllibrary newFunctionWithName:GetFragmentFunctionName(cache->fragmentFunction)]; + SDL_assert(mtlvertfn != nil); + SDL_assert(mtlfragfn != nil); + + MTLRenderPipelineDescriptor *mtlpipedesc = [[MTLRenderPipelineDescriptor alloc] init]; + mtlpipedesc.vertexFunction = mtlvertfn; + mtlpipedesc.fragmentFunction = mtlfragfn; + + MTLRenderPipelineColorAttachmentDescriptor *rtdesc = mtlpipedesc.colorAttachments[0]; + + rtdesc.pixelFormat = cache->renderTargetFormat; + + if (blendmode != SDL_BLENDMODE_NONE) { + rtdesc.blendingEnabled = YES; + rtdesc.sourceRGBBlendFactor = GetBlendFactor(SDL_GetBlendModeSrcColorFactor(blendmode)); + rtdesc.destinationRGBBlendFactor = GetBlendFactor(SDL_GetBlendModeDstColorFactor(blendmode)); + rtdesc.rgbBlendOperation = GetBlendOperation(SDL_GetBlendModeColorOperation(blendmode)); + rtdesc.sourceAlphaBlendFactor = GetBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blendmode)); + rtdesc.destinationAlphaBlendFactor = GetBlendFactor(SDL_GetBlendModeDstAlphaFactor(blendmode)); + rtdesc.alphaBlendOperation = GetBlendOperation(SDL_GetBlendModeAlphaOperation(blendmode)); + } else { + rtdesc.blendingEnabled = NO; + } + + mtlpipedesc.label = [@(cache->label) stringByAppendingString:blendlabel]; + + NSError *err = nil; + id<MTLRenderPipelineState> state = [data.mtldevice newRenderPipelineStateWithDescriptor:mtlpipedesc error:&err]; + SDL_assert(err == nil); + + METAL_PipelineState pipeline; + pipeline.blendMode = blendmode; + pipeline.pipe = (void *)CFBridgingRetain(state); + + METAL_PipelineState *states = SDL_realloc(cache->states, (cache->count + 1) * sizeof(pipeline)); + +#if !__has_feature(objc_arc) + [mtlpipedesc release]; // !!! FIXME: can these be reused for each creation, or does the pipeline obtain it? + [mtlvertfn release]; + [mtlfragfn release]; + [state release]; +#endif + + if (states) { + states[cache->count++] = pipeline; + cache->states = states; + return (__bridge id<MTLRenderPipelineState>)pipeline.pipe; + } else { + CFBridgingRelease(pipeline.pipe); + SDL_OutOfMemory(); + return NULL; + } +} + +static void +MakePipelineCache(METAL_RenderData *data, METAL_PipelineCache *cache, const char *label, + MTLPixelFormat rtformat, SDL_MetalVertexFunction vertfn, SDL_MetalFragmentFunction fragfn) +{ + SDL_zerop(cache); + + cache->vertexFunction = vertfn; + cache->fragmentFunction = fragfn; + cache->renderTargetFormat = rtformat; + cache->label = label; + + /* Create pipeline states for the default blend modes. Custom blend modes + * will be added to the cache on-demand. */ + MakePipelineState(data, cache, @" (blend=none)", SDL_BLENDMODE_NONE); + MakePipelineState(data, cache, @" (blend=blend)", SDL_BLENDMODE_BLEND); + MakePipelineState(data, cache, @" (blend=add)", SDL_BLENDMODE_ADD); + MakePipelineState(data, cache, @" (blend=mod)", SDL_BLENDMODE_MOD); +} + +static void +DestroyPipelineCache(METAL_PipelineCache *cache) +{ + if (cache != NULL) { + for (int i = 0; i < cache->count; i++) { + CFBridgingRelease(cache->states[i].pipe); + } + + SDL_free(cache->states); + } +} + +void +MakeShaderPipelines(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, MTLPixelFormat rtformat) +{ + SDL_zerop(pipelines); + + pipelines->renderTargetFormat = rtformat; + + MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_SOLID], "SDL primitives pipeline", rtformat, SDL_METAL_VERTEX_SOLID, SDL_METAL_FRAGMENT_SOLID); + MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_COPY], "SDL copy pipeline", rtformat, SDL_METAL_VERTEX_COPY, SDL_METAL_FRAGMENT_COPY); + MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_YUV], "SDL YUV pipeline", rtformat, SDL_METAL_VERTEX_COPY, SDL_METAL_FRAGMENT_YUV); + MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_NV12], "SDL NV12 pipeline", rtformat, SDL_METAL_VERTEX_COPY, SDL_METAL_FRAGMENT_NV12); + MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_NV21], "SDL NV21 pipeline", rtformat, SDL_METAL_VERTEX_COPY, SDL_METAL_FRAGMENT_NV21); +} + +static METAL_ShaderPipelines * +ChooseShaderPipelines(METAL_RenderData *data, MTLPixelFormat rtformat) +{ + METAL_ShaderPipelines *allpipelines = data.allpipelines; + int count = data.pipelinescount; + + for (int i = 0; i < count; i++) { + if (allpipelines[i].renderTargetFormat == rtformat) { + return &allpipelines[i]; + } + } + + allpipelines = SDL_realloc(allpipelines, (count + 1) * sizeof(METAL_ShaderPipelines)); + + if (allpipelines == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + MakeShaderPipelines(data, &allpipelines[count], rtformat); + + data.allpipelines = allpipelines; + data.pipelinescount = count + 1; + + return &data.allpipelines[count]; +} + +static void +DestroyAllPipelines(METAL_ShaderPipelines *allpipelines, int count) +{ + if (allpipelines != NULL) { + for (int i = 0; i < count; i++) { + for (int cache = 0; cache < SDL_METAL_FRAGMENT_COUNT; cache++) { + DestroyPipelineCache(&allpipelines[i].caches[cache]); + } + } + + SDL_free(allpipelines); + } +} + +static inline id<MTLRenderPipelineState> +ChoosePipelineState(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, SDL_MetalFragmentFunction fragfn, SDL_BlendMode blendmode) +{ + METAL_PipelineCache *cache = &pipelines->caches[fragfn]; + + for (int i = 0; i < cache->count; i++) { + if (cache->states[i].blendMode == blendmode) { + return (__bridge id<MTLRenderPipelineState>)cache->states[i].pipe; + } + } + + return MakePipelineState(data, cache, [NSString stringWithFormat:@" (blend=custom 0x%x)", blendmode], blendmode); +} + +static SDL_Renderer * +METAL_CreateRenderer(SDL_Window * window, Uint32 flags) +{ @autoreleasepool { + SDL_Renderer *renderer = NULL; + METAL_RenderData *data = NULL; + id<MTLDevice> mtldevice = nil; + SDL_SysWMinfo syswm; + + SDL_VERSION(&syswm.version); + if (!SDL_GetWindowWMInfo(window, &syswm)) { + return NULL; + } + + if (IsMetalAvailable(&syswm) == -1) { + return NULL; + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + // !!! FIXME: MTLCopyAllDevices() can find other GPUs on macOS... + mtldevice = MTLCreateSystemDefaultDevice(); + + if (mtldevice == nil) { + SDL_free(renderer); + SDL_SetError("Failed to obtain Metal device"); + return NULL; + } + + // !!! FIXME: error checking on all of this. + data = [[METAL_RenderData alloc] init]; + + renderer->driverdata = (void*)CFBridgingRetain(data); + renderer->window = window; + +#ifdef __MACOSX__ + NSView *view = Cocoa_Mtl_AddMetalView(window); + CAMetalLayer *layer = (CAMetalLayer *)[view layer]; + + layer.device = mtldevice; + + //layer.colorspace = nil; + +#else + UIView *view = UIKit_Mtl_AddMetalView(window); + CAMetalLayer *layer = (CAMetalLayer *)[view layer]; +#endif + + // Necessary for RenderReadPixels. + layer.framebufferOnly = NO; + + data.mtldevice = layer.device; + data.mtllayer = layer; + id<MTLCommandQueue> mtlcmdqueue = [data.mtldevice newCommandQueue]; + data.mtlcmdqueue = mtlcmdqueue; + data.mtlcmdqueue.label = @"SDL Metal Renderer"; + data.mtlpassdesc = [MTLRenderPassDescriptor renderPassDescriptor]; + + NSError *err = nil; + + // The compiled .metallib is embedded in a static array in a header file + // but the original shader source code is in SDL_shaders_metal.metal. + dispatch_data_t mtllibdata = dispatch_data_create(sdl_metallib, sdl_metallib_len, dispatch_get_global_queue(0, 0), ^{}); + id<MTLLibrary> mtllibrary = [data.mtldevice newLibraryWithData:mtllibdata error:&err]; + data.mtllibrary = mtllibrary; + SDL_assert(err == nil); +#if !__has_feature(objc_arc) + dispatch_release(mtllibdata); +#endif + data.mtllibrary.label = @"SDL Metal renderer shader library"; + + /* Do some shader pipeline state loading up-front rather than on demand. */ + data.pipelinescount = 0; + data.allpipelines = NULL; + ChooseShaderPipelines(data, MTLPixelFormatBGRA8Unorm); + + MTLSamplerDescriptor *samplerdesc = [[MTLSamplerDescriptor alloc] init]; + + samplerdesc.minFilter = MTLSamplerMinMagFilterNearest; + samplerdesc.magFilter = MTLSamplerMinMagFilterNearest; + id<MTLSamplerState> mtlsamplernearest = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; + data.mtlsamplernearest = mtlsamplernearest; + + samplerdesc.minFilter = MTLSamplerMinMagFilterLinear; + samplerdesc.magFilter = MTLSamplerMinMagFilterLinear; + id<MTLSamplerState> mtlsamplerlinear = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; + data.mtlsamplerlinear = mtlsamplerlinear; + + /* Note: matrices are column major. */ + float identitytransform[16] = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f, + }; + + float halfpixeltransform[16] = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.0f, 1.0f, + }; + + /* Metal pads float3s to 16 bytes. */ + float decodetransformJPEG[4*4] = { + 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ + 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ + 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ + }; + + float decodetransformBT601[4*4] = { + -0.0627451017, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.1644, 0.0000, 1.5960, 0.0, /* Rcoeff */ + 1.1644, -0.3918, -0.8130, 0.0, /* Gcoeff */ + 1.1644, 2.0172, 0.0000, 0.0, /* Bcoeff */ + }; + + float decodetransformBT709[4*4] = { + 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ + 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ + 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ + }; + + float clearverts[6] = {0.0f, 0.0f, 0.0f, 2.0f, 2.0f, 0.0f}; + + id<MTLBuffer> mtlbufconstantstaging = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModeShared]; + mtlbufconstantstaging.label = @"SDL constant staging data"; + + id<MTLBuffer> mtlbufconstants = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModePrivate]; + data.mtlbufconstants = mtlbufconstants; + data.mtlbufconstants.label = @"SDL constant data"; + + char *constantdata = [mtlbufconstantstaging contents]; + SDL_memcpy(constantdata + CONSTANTS_OFFSET_IDENTITY, identitytransform, sizeof(identitytransform)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM, halfpixeltransform, sizeof(halfpixeltransform)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_JPEG, decodetransformJPEG, sizeof(decodetransformJPEG)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT601, decodetransformBT601, sizeof(decodetransformBT601)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT709, decodetransformBT709, sizeof(decodetransformBT709)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_CLEAR_VERTS, clearverts, sizeof(clearverts)); + + id<MTLCommandBuffer> cmdbuffer = [data.mtlcmdqueue commandBuffer]; + id<MTLBlitCommandEncoder> blitcmd = [cmdbuffer blitCommandEncoder]; + + [blitcmd copyFromBuffer:mtlbufconstantstaging sourceOffset:0 toBuffer:data.mtlbufconstants destinationOffset:0 size:CONSTANTS_LENGTH]; + + [blitcmd endEncoding]; + [cmdbuffer commit]; + + // !!! FIXME: force more clears here so all the drawables are sane to start, and our static buffers are definitely flushed. + + renderer->WindowEvent = METAL_WindowEvent; + renderer->GetOutputSize = METAL_GetOutputSize; + renderer->SupportsBlendMode = METAL_SupportsBlendMode; + renderer->CreateTexture = METAL_CreateTexture; + renderer->UpdateTexture = METAL_UpdateTexture; + renderer->UpdateTextureYUV = METAL_UpdateTextureYUV; + renderer->LockTexture = METAL_LockTexture; + renderer->UnlockTexture = METAL_UnlockTexture; + renderer->SetRenderTarget = METAL_SetRenderTarget; + renderer->UpdateViewport = METAL_UpdateViewport; + renderer->UpdateClipRect = METAL_UpdateClipRect; + renderer->RenderClear = METAL_RenderClear; + renderer->RenderDrawPoints = METAL_RenderDrawPoints; + renderer->RenderDrawLines = METAL_RenderDrawLines; + renderer->RenderFillRects = METAL_RenderFillRects; + renderer->RenderCopy = METAL_RenderCopy; + renderer->RenderCopyEx = METAL_RenderCopyEx; + renderer->RenderReadPixels = METAL_RenderReadPixels; + renderer->RenderPresent = METAL_RenderPresent; + renderer->DestroyTexture = METAL_DestroyTexture; + renderer->DestroyRenderer = METAL_DestroyRenderer; + renderer->GetMetalLayer = METAL_GetMetalLayer; + renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder; + + renderer->info = METAL_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + +#if defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13) + if (@available(macOS 10.13, *)) { + data.mtllayer.displaySyncEnabled = (flags & SDL_RENDERER_PRESENTVSYNC) != 0; + } else +#endif + { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + /* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ + int maxtexsize = 4096; +#if defined(__MACOSX__) + maxtexsize = 16384; +#elif defined(__TVOS__) + maxtexsize = 8192; +#ifdef __TVOS_11_0 + if (@available(tvOS 11.0, *)) { + if ([mtldevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1]) { + maxtexsize = 16384; + } + } +#endif +#else +#ifdef __IPHONE_11_0 + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) { + maxtexsize = 16384; + } else +#endif +#ifdef __IPHONE_10_0 + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) { + maxtexsize = 16384; + } else +#endif + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v2] || [mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v2]) { + maxtexsize = 8192; + } else { + maxtexsize = 4096; + } +#endif + + renderer->info.max_texture_width = maxtexsize; + renderer->info.max_texture_height = maxtexsize; + +#if !__has_feature(objc_arc) + [mtlcmdqueue release]; + [mtllibrary release]; + [samplerdesc release]; + [mtlsamplernearest release]; + [mtlsamplerlinear release]; + [mtlbufconstants release]; + [view release]; + [data release]; + [mtldevice release]; +#endif + + return renderer; +}} + +static void +METAL_ActivateRenderCommandEncoder(SDL_Renderer * renderer, MTLLoadAction load) +{ + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + /* Our SetRenderTarget just signals that the next render operation should + * set up a new render pass. This is where that work happens. */ + if (data.mtlcmdencoder == nil) { + id<MTLTexture> mtltexture = nil; + + if (renderer->target != NULL) { + METAL_TextureData *texdata = (__bridge METAL_TextureData *)renderer->target->driverdata; + mtltexture = texdata.mtltexture; + } else { + if (data.mtlbackbuffer == nil) { + /* The backbuffer's contents aren't guaranteed to persist after + * presenting, so we can leave it undefined when loading it. */ + data.mtlbackbuffer = [data.mtllayer nextDrawable]; + if (load == MTLLoadActionLoad) { + load = MTLLoadActionDontCare; + } + } + mtltexture = data.mtlbackbuffer.texture; + } + + SDL_assert(mtltexture); + + if (load == MTLLoadActionClear) { + MTLClearColor color = MTLClearColorMake(renderer->r/255.0, renderer->g/255.0, renderer->b/255.0, renderer->a/255.0); + data.mtlpassdesc.colorAttachments[0].clearColor = color; + } + + data.mtlpassdesc.colorAttachments[0].loadAction = load; + data.mtlpassdesc.colorAttachments[0].texture = mtltexture; + + data.mtlcmdbuffer = [data.mtlcmdqueue commandBuffer]; + data.mtlcmdencoder = [data.mtlcmdbuffer renderCommandEncoderWithDescriptor:data.mtlpassdesc]; + + if (data.mtlbackbuffer != nil && mtltexture == data.mtlbackbuffer.texture) { + data.mtlcmdencoder.label = @"SDL metal renderer backbuffer"; + } else { + data.mtlcmdencoder.label = @"SDL metal renderer render target"; + } + + data.activepipelines = ChooseShaderPipelines(data, mtltexture.pixelFormat); + + /* Make sure the viewport and clip rect are set on the new render pass. */ + METAL_UpdateViewport(renderer); + METAL_UpdateClipRect(renderer); + } +} + +static void +METAL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SHOWN || + event->event == SDL_WINDOWEVENT_HIDDEN) { + // !!! FIXME: write me + } +} + +static int +METAL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + if (w) { + *w = (int)data.mtllayer.drawableSize.width; + } + if (h) { + *h = (int)data.mtllayer.drawableSize.height; + } + return 0; +}} + +static SDL_bool +METAL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (GetBlendFactor(srcColorFactor) == invalidBlendFactor || + GetBlendFactor(srcAlphaFactor) == invalidBlendFactor || + GetBlendOperation(colorOperation) == invalidBlendOperation || + GetBlendFactor(dstColorFactor) == invalidBlendFactor || + GetBlendFactor(dstAlphaFactor) == invalidBlendFactor || + GetBlendOperation(alphaOperation) == invalidBlendOperation) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int +METAL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + MTLPixelFormat pixfmt; + + switch (texture->format) { + case SDL_PIXELFORMAT_ABGR8888: + pixfmt = MTLPixelFormatRGBA8Unorm; + break; + case SDL_PIXELFORMAT_ARGB8888: + pixfmt = MTLPixelFormatBGRA8Unorm; + break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + pixfmt = MTLPixelFormatR8Unorm; + break; + default: + return SDL_SetError("Texture format %s not supported by Metal", SDL_GetPixelFormatName(texture->format)); + } + + MTLTextureDescriptor *mtltexdesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixfmt + width:(NSUInteger)texture->w height:(NSUInteger)texture->h mipmapped:NO]; + + /* Not available in iOS 8. */ + if ([mtltexdesc respondsToSelector:@selector(usage)]) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget; + } else { + mtltexdesc.usage = MTLTextureUsageShaderRead; + } + } + + id<MTLTexture> mtltexture = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; + if (mtltexture == nil) { + return SDL_SetError("Texture allocation failed"); + } + + id<MTLTexture> mtltexture_uv = nil; + + BOOL yuv = (texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12); + BOOL nv12 = (texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21); + + if (yuv) { + mtltexdesc.pixelFormat = MTLPixelFormatR8Unorm; + mtltexdesc.width = (texture->w + 1) / 2; + mtltexdesc.height = (texture->h + 1) / 2; + mtltexdesc.textureType = MTLTextureType2DArray; + mtltexdesc.arrayLength = 2; + } else if (nv12) { + mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm; + mtltexdesc.width = (texture->w + 1) / 2; + mtltexdesc.height = (texture->h + 1) / 2; + } + + if (yuv || nv12) { + mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; + if (mtltexture_uv == nil) { +#if !__has_feature(objc_arc) + [mtltexture release]; +#endif + return SDL_SetError("Texture allocation failed"); + } + } + + METAL_TextureData *texturedata = [[METAL_TextureData alloc] init]; + if (texture->scaleMode == SDL_ScaleModeNearest) { + texturedata.mtlsampler = data.mtlsamplernearest; + } else { + texturedata.mtlsampler = data.mtlsamplerlinear; + } + texturedata.mtltexture = mtltexture; + texturedata.mtltexture_uv = mtltexture_uv; + + texturedata.yuv = yuv; + texturedata.nv12 = nv12; + + if (yuv) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_YUV; + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV12; + } else if (texture->format == SDL_PIXELFORMAT_NV21) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV21; + } else { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY; + } + + if (yuv || nv12) { + size_t offset = 0; + SDL_YUV_CONVERSION_MODE mode = SDL_GetYUVConversionModeForResolution(texture->w, texture->h); + switch (mode) { + case SDL_YUV_CONVERSION_JPEG: offset = CONSTANTS_OFFSET_DECODE_JPEG; break; + case SDL_YUV_CONVERSION_BT601: offset = CONSTANTS_OFFSET_DECODE_BT601; break; + case SDL_YUV_CONVERSION_BT709: offset = CONSTANTS_OFFSET_DECODE_BT709; break; + default: offset = 0; break; + } + texturedata.conversionBufferOffset = offset; + } + + texture->driverdata = (void*)CFBridgingRetain(texturedata); + +#if !__has_feature(objc_arc) + [texturedata release]; + [mtltexture release]; + [mtltexture_uv release]; +#endif + + return 0; +}} + +static int +METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + + /* !!! FIXME: replaceRegion does not do any synchronization, so it might + * !!! FIXME: stomp on a previous frame's data that's currently being read + * !!! FIXME: by the GPU. */ + [texturedata.mtltexture replaceRegion:MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h) + mipmapLevel:0 + withBytes:pixels + bytesPerRow:pitch]; + + if (texturedata.yuv) { + int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0; + int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1; + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + [texturedata.mtltexture_uv replaceRegion:MTLRegionMake2D(rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2) + mipmapLevel:0 + slice:Uslice + withBytes:pixels + bytesPerRow:(pitch + 1) / 2 + bytesPerImage:0]; + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1)/2)); + [texturedata.mtltexture_uv replaceRegion:MTLRegionMake2D(rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2) + mipmapLevel:0 + slice:Vslice + withBytes:pixels + bytesPerRow:(pitch + 1) / 2 + bytesPerImage:0]; + } + + if (texturedata.nv12) { + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + [texturedata.mtltexture_uv replaceRegion:MTLRegionMake2D(rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2) + mipmapLevel:0 + slice:0 + withBytes:pixels + bytesPerRow:2 * ((pitch + 1) / 2) + bytesPerImage:0]; + } + + return 0; +}} + +static int +METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + const int Uslice = 0; + const int Vslice = 1; + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + [texturedata.mtltexture replaceRegion:MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h) + mipmapLevel:0 + withBytes:Yplane + bytesPerRow:Ypitch]; + + [texturedata.mtltexture_uv replaceRegion:MTLRegionMake2D(rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2) + mipmapLevel:0 + slice:Uslice + withBytes:Uplane + bytesPerRow:Upitch + bytesPerImage:0]; + + [texturedata.mtltexture_uv replaceRegion:MTLRegionMake2D(rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2) + mipmapLevel:0 + slice:Vslice + withBytes:Vplane + bytesPerRow:Vpitch + bytesPerImage:0]; + + return 0; +}} + +static int +METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + return SDL_Unsupported(); // !!! FIXME: write me +} + +static void +METAL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + // !!! FIXME: write me +} + +static int +METAL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + if (data.mtlcmdencoder) { + /* End encoding for the previous render target so we can set up a new + * render pass for this one. */ + [data.mtlcmdencoder endEncoding]; + [data.mtlcmdbuffer commit]; + + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; + } + + /* We don't begin a new render pass right away - we delay it until an actual + * draw or clear happens. That way we can use hardware clears when possible, + * which are only available when beginning a new render pass. */ + return 0; +}} + +static int +METAL_SetOrthographicProjection(SDL_Renderer *renderer, int w, int h) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + float projection[4][4]; + + if (!w || !h) { + return 0; + } + + /* Prepare an orthographic projection */ + projection[0][0] = 2.0f / w; + projection[0][1] = 0.0f; + projection[0][2] = 0.0f; + projection[0][3] = 0.0f; + projection[1][0] = 0.0f; + projection[1][1] = -2.0f / h; + projection[1][2] = 0.0f; + projection[1][3] = 0.0f; + projection[2][0] = 0.0f; + projection[2][1] = 0.0f; + projection[2][2] = 0.0f; + projection[2][3] = 0.0f; + projection[3][0] = -1.0f; + projection[3][1] = 1.0f; + projection[3][2] = 0.0f; + projection[3][3] = 1.0f; + + // !!! FIXME: This should be in a buffer... + [data.mtlcmdencoder setVertexBytes:projection length:sizeof(float)*16 atIndex:2]; + return 0; +}} + +static int +METAL_UpdateViewport(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + if (data.mtlcmdencoder) { + MTLViewport viewport; + viewport.originX = renderer->viewport.x; + viewport.originY = renderer->viewport.y; + viewport.width = renderer->viewport.w; + viewport.height = renderer->viewport.h; + viewport.znear = 0.0; + viewport.zfar = 1.0; + [data.mtlcmdencoder setViewport:viewport]; + METAL_SetOrthographicProjection(renderer, renderer->viewport.w, renderer->viewport.h); + } + return 0; +}} + +static int +METAL_UpdateClipRect(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + if (data.mtlcmdencoder) { + MTLScissorRect mtlrect; + // !!! FIXME: should this care about the viewport? + if (renderer->clipping_enabled) { + const SDL_Rect *rect = &renderer->clip_rect; + mtlrect.x = renderer->viewport.x + rect->x; + mtlrect.y = renderer->viewport.x + rect->y; + mtlrect.width = rect->w; + mtlrect.height = rect->h; + } else { + mtlrect.x = renderer->viewport.x; + mtlrect.y = renderer->viewport.y; + mtlrect.width = renderer->viewport.w; + mtlrect.height = renderer->viewport.h; + } + if (mtlrect.width > 0 && mtlrect.height > 0) { + [data.mtlcmdencoder setScissorRect:mtlrect]; + } + } + return 0; +}} + +static int +METAL_RenderClear(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + /* Since we set up the render command encoder lazily when a draw is + * requested, we can do the fast path hardware clear if no draws have + * happened since the last SetRenderTarget. */ + if (data.mtlcmdencoder == nil) { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionClear); + } else { + // !!! FIXME: render color should live in a dedicated uniform buffer. + const float color[4] = { ((float)renderer->r) / 255.0f, ((float)renderer->g) / 255.0f, ((float)renderer->b) / 255.0f, ((float)renderer->a) / 255.0f }; + + MTLViewport viewport; // RenderClear ignores the viewport state, though, so reset that. + viewport.originX = viewport.originY = 0.0; + viewport.width = data.mtlpassdesc.colorAttachments[0].texture.width; + viewport.height = data.mtlpassdesc.colorAttachments[0].texture.height; + viewport.znear = 0.0; + viewport.zfar = 1.0; + + // Slow path for clearing: draw a filled fullscreen triangle. + METAL_SetOrthographicProjection(renderer, 1, 1); + [data.mtlcmdencoder setViewport:viewport]; + [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data, data.activepipelines, SDL_METAL_FRAGMENT_SOLID, SDL_BLENDMODE_NONE)]; + [data.mtlcmdencoder setVertexBuffer:data.mtlbufconstants offset:CONSTANTS_OFFSET_CLEAR_VERTS atIndex:0]; + [data.mtlcmdencoder setVertexBuffer:data.mtlbufconstants offset:CONSTANTS_OFFSET_IDENTITY atIndex:3]; + [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0]; + [data.mtlcmdencoder drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3]; + + // reset the viewport for the rest of our usual drawing work... + viewport.originX = renderer->viewport.x; + viewport.originY = renderer->viewport.y; + viewport.width = renderer->viewport.w; + viewport.height = renderer->viewport.h; + viewport.znear = 0.0; + viewport.zfar = 1.0; + [data.mtlcmdencoder setViewport:viewport]; + METAL_SetOrthographicProjection(renderer, renderer->viewport.w, renderer->viewport.h); + } + + return 0; +}} + +// normalize a value from 0.0f to len into 0.0f to 1.0f. +static inline float +normtex(const float _val, const float len) +{ + return _val / len; +} + +static int +DrawVerts(SDL_Renderer * renderer, const SDL_FPoint * points, int count, + const MTLPrimitiveType primtype) +{ @autoreleasepool { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + + const size_t vertlen = (sizeof (float) * 2) * count; + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + // !!! FIXME: render color should live in a dedicated uniform buffer. + const float color[4] = { ((float)renderer->r) / 255.0f, ((float)renderer->g) / 255.0f, ((float)renderer->b) / 255.0f, ((float)renderer->a) / 255.0f }; + + [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data, data.activepipelines, SDL_METAL_FRAGMENT_SOLID, renderer->blendMode)]; + [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0]; + + [data.mtlcmdencoder setVertexBytes:points length:vertlen atIndex:0]; + [data.mtlcmdencoder setVertexBuffer:data.mtlbufconstants offset:CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM atIndex:3]; + [data.mtlcmdencoder drawPrimitives:primtype vertexStart:0 vertexCount:count]; + + return 0; +}} + +static int +METAL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) +{ + return DrawVerts(renderer, points, count, MTLPrimitiveTypePoint); +} + +static int +METAL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) +{ + return DrawVerts(renderer, points, count, MTLPrimitiveTypeLineStrip); +} + +static int +METAL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) +{ @autoreleasepool { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + // !!! FIXME: render color should live in a dedicated uniform buffer. + const float color[4] = { ((float)renderer->r) / 255.0f, ((float)renderer->g) / 255.0f, ((float)renderer->b) / 255.0f, ((float)renderer->a) / 255.0f }; + + [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data, data.activepipelines, SDL_METAL_FRAGMENT_SOLID, renderer->blendMode)]; + [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0]; + [data.mtlcmdencoder setVertexBuffer:data.mtlbufconstants offset:CONSTANTS_OFFSET_IDENTITY atIndex:3]; + + for (int i = 0; i < count; i++, rects++) { + if ((rects->w <= 0.0f) || (rects->h <= 0.0f)) continue; + + const float verts[] = { + rects->x, rects->y + rects->h, + rects->x, rects->y, + rects->x + rects->w, rects->y + rects->h, + rects->x + rects->w, rects->y + }; + + [data.mtlcmdencoder setVertexBytes:verts length:sizeof(verts) atIndex:0]; + [data.mtlcmdencoder drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; + } + + return 0; +}} + +static void +METAL_SetupRenderCopy(METAL_RenderData *data, SDL_Texture *texture, METAL_TextureData *texturedata) +{ + float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; + if (texture->modMode) { + color[0] = ((float)texture->r) / 255.0f; + color[1] = ((float)texture->g) / 255.0f; + color[2] = ((float)texture->b) / 255.0f; + color[3] = ((float)texture->a) / 255.0f; + } + + [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data, data.activepipelines, texturedata.fragmentFunction, texture->blendMode)]; + [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0]; + [data.mtlcmdencoder setFragmentSamplerState:texturedata.mtlsampler atIndex:0]; + + [data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture atIndex:0]; + + if (texturedata.yuv || texturedata.nv12) { + [data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture_uv atIndex:1]; + [data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1]; + } +} + +static int +METAL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ @autoreleasepool { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + const float texw = (float) texturedata.mtltexture.width; + const float texh = (float) texturedata.mtltexture.height; + + METAL_SetupRenderCopy(data, texture, texturedata); + + const float xy[] = { + dstrect->x, dstrect->y + dstrect->h, + dstrect->x, dstrect->y, + dstrect->x + dstrect->w, dstrect->y + dstrect->h, + dstrect->x + dstrect->w, dstrect->y + }; + + const float uv[] = { + normtex(srcrect->x, texw), normtex(srcrect->y + srcrect->h, texh), + normtex(srcrect->x, texw), normtex(srcrect->y, texh), + normtex(srcrect->x + srcrect->w, texw), normtex(srcrect->y + srcrect->h, texh), + normtex(srcrect->x + srcrect->w, texw), normtex(srcrect->y, texh) + }; + + [data.mtlcmdencoder setVertexBytes:xy length:sizeof(xy) atIndex:0]; + [data.mtlcmdencoder setVertexBytes:uv length:sizeof(uv) atIndex:1]; + [data.mtlcmdencoder setVertexBuffer:data.mtlbufconstants offset:CONSTANTS_OFFSET_IDENTITY atIndex:3]; + [data.mtlcmdencoder drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; + + return 0; +}} + +static int +METAL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ @autoreleasepool { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + const float texw = (float) texturedata.mtltexture.width; + const float texh = (float) texturedata.mtltexture.height; + float transform[16]; + float minu, maxu, minv, maxv; + + METAL_SetupRenderCopy(data, texture, texturedata); + + minu = normtex(srcrect->x, texw); + maxu = normtex(srcrect->x + srcrect->w, texw); + minv = normtex(srcrect->y, texh); + maxv = normtex(srcrect->y + srcrect->h, texh); + + if (flip & SDL_FLIP_HORIZONTAL) { + float tmp = maxu; + maxu = minu; + minu = tmp; + } + if (flip & SDL_FLIP_VERTICAL) { + float tmp = maxv; + maxv = minv; + minv = tmp; + } + + const float uv[] = { + minu, maxv, + minu, minv, + maxu, maxv, + maxu, minv + }; + + const float xy[] = { + -center->x, dstrect->h - center->y, + -center->x, -center->y, + dstrect->w - center->x, dstrect->h - center->y, + dstrect->w - center->x, -center->y + }; + + { + float rads = (float)(M_PI * (float) angle / 180.0f); + float c = cosf(rads), s = sinf(rads); + SDL_memset(transform, 0, sizeof(transform)); + + transform[10] = transform[15] = 1.0f; + + /* Rotation */ + transform[0] = c; + transform[1] = s; + transform[4] = -s; + transform[5] = c; + + /* Translation */ + transform[12] = dstrect->x + center->x; + transform[13] = dstrect->y + center->y; + } + + [data.mtlcmdencoder setVertexBytes:xy length:sizeof(xy) atIndex:0]; + [data.mtlcmdencoder setVertexBytes:uv length:sizeof(uv) atIndex:1]; + [data.mtlcmdencoder setVertexBytes:transform length:sizeof(transform) atIndex:3]; + [data.mtlcmdencoder drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; + + return 0; +}} + +static int +METAL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + /* Make sure we have a valid MTLTexture to read from, and an active command + * buffer we can wait for. */ + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + + /* Wait for the current command buffer to finish, so we don't read from the + * texture before the GPU finishes rendering to it. */ + if (data.mtlcmdencoder) { + [data.mtlcmdencoder endEncoding]; + [data.mtlcmdbuffer commit]; + [data.mtlcmdbuffer waitUntilCompleted]; + + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; + } + + id<MTLTexture> mtltexture = data.mtlpassdesc.colorAttachments[0].texture; + MTLRegion mtlregion = MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h); + + // we only do BGRA8 or RGBA8 at the moment, so 4 will do. + const int temp_pitch = rect->w * 4; + void *temp_pixels = SDL_malloc(temp_pitch * rect->h); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + + [mtltexture getBytes:temp_pixels bytesPerRow:temp_pitch fromRegion:mtlregion mipmapLevel:0]; + + const Uint32 temp_format = (mtltexture.pixelFormat == MTLPixelFormatBGRA8Unorm) ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_ABGR8888; + const int status = SDL_ConvertPixels(rect->w, rect->h, temp_format, temp_pixels, temp_pitch, pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + /* Set up an active command buffer and encoder once we're done. It will use + * the same texture that was active before (even if it's part of the swap + * chain), since we didn't clear that when waiting for the command buffer to + * complete. */ + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + + return status; +}} + +static void +METAL_RenderPresent(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + + if (data.mtlcmdencoder != nil) { + [data.mtlcmdencoder endEncoding]; + } + if (data.mtlbackbuffer != nil) { + [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer]; + } + if (data.mtlcmdbuffer != nil) { + [data.mtlcmdbuffer commit]; + } + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; + data.mtlbackbuffer = nil; +}} + +static void +METAL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ @autoreleasepool { + CFBridgingRelease(texture->driverdata); + texture->driverdata = NULL; +}} + +static void +METAL_DestroyRenderer(SDL_Renderer * renderer) +{ @autoreleasepool { + if (renderer->driverdata) { + METAL_RenderData *data = CFBridgingRelease(renderer->driverdata); + + if (data.mtlcmdencoder != nil) { + [data.mtlcmdencoder endEncoding]; + } + + DestroyAllPipelines(data.allpipelines, data.pipelinescount); + } + + SDL_free(renderer); +}} + +static void * +METAL_GetMetalLayer(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + return (__bridge void*)data.mtllayer; +}} + +static void * +METAL_GetMetalCommandEncoder(SDL_Renderer * renderer) +{ @autoreleasepool { + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad); + METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + return (__bridge void*)data.mtlcmdencoder; +}} + +#endif /* SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal.metal b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal.metal new file mode 100644 index 0000000..8df3b75 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal.metal @@ -0,0 +1,109 @@ +#include <metal_texture> +#include <metal_matrix> + +using namespace metal; + +struct SolidVertexOutput +{ + float4 position [[position]]; + float pointSize [[point_size]]; +}; + +vertex SolidVertexOutput SDL_Solid_vertex(const device float2 *position [[buffer(0)]], + constant float4x4 &projection [[buffer(2)]], + constant float4x4 &transform [[buffer(3)]], + uint vid [[vertex_id]]) +{ + SolidVertexOutput v; + v.position = (projection * transform) * float4(position[vid], 0.0f, 1.0f); + v.pointSize = 1.0f; + return v; +} + +fragment float4 SDL_Solid_fragment(constant float4 &col [[buffer(0)]]) +{ + return col; +} + +struct CopyVertexOutput +{ + float4 position [[position]]; + float2 texcoord; +}; + +vertex CopyVertexOutput SDL_Copy_vertex(const device float2 *position [[buffer(0)]], + const device float2 *texcoords [[buffer(1)]], + constant float4x4 &projection [[buffer(2)]], + constant float4x4 &transform [[buffer(3)]], + uint vid [[vertex_id]]) +{ + CopyVertexOutput v; + v.position = (projection * transform) * float4(position[vid], 0.0f, 1.0f); + v.texcoord = texcoords[vid]; + return v; +} + +fragment float4 SDL_Copy_fragment(CopyVertexOutput vert [[stage_in]], + constant float4 &col [[buffer(0)]], + texture2d<float> tex [[texture(0)]], + sampler s [[sampler(0)]]) +{ + return tex.sample(s, vert.texcoord) * col; +} + +struct YUVDecode +{ + float3 offset; + float3 Rcoeff; + float3 Gcoeff; + float3 Bcoeff; +}; + +fragment float4 SDL_YUV_fragment(CopyVertexOutput vert [[stage_in]], + constant float4 &col [[buffer(0)]], + constant YUVDecode &decode [[buffer(1)]], + texture2d<float> texY [[texture(0)]], + texture2d_array<float> texUV [[texture(1)]], + sampler s [[sampler(0)]]) +{ + float3 yuv; + yuv.x = texY.sample(s, vert.texcoord).r; + yuv.y = texUV.sample(s, vert.texcoord, 0).r; + yuv.z = texUV.sample(s, vert.texcoord, 1).r; + + yuv += decode.offset; + + return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0); +} + +fragment float4 SDL_NV12_fragment(CopyVertexOutput vert [[stage_in]], + constant float4 &col [[buffer(0)]], + constant YUVDecode &decode [[buffer(1)]], + texture2d<float> texY [[texture(0)]], + texture2d<float> texUV [[texture(1)]], + sampler s [[sampler(0)]]) +{ + float3 yuv; + yuv.x = texY.sample(s, vert.texcoord).r; + yuv.yz = texUV.sample(s, vert.texcoord).rg; + + yuv += decode.offset; + + return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0); +} + +fragment float4 SDL_NV21_fragment(CopyVertexOutput vert [[stage_in]], + constant float4 &col [[buffer(0)]], + constant YUVDecode &decode [[buffer(1)]], + texture2d<float> texY [[texture(0)]], + texture2d<float> texUV [[texture(1)]], + sampler s [[sampler(0)]]) +{ + float3 yuv; + yuv.x = texY.sample(s, vert.texcoord).r; + yuv.yz = texUV.sample(s, vert.texcoord).gr; + + yuv += decode.offset; + + return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0); +} diff --git a/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_ios.h b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_ios.h new file mode 100644 index 0000000..1c93252 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_ios.h @@ -0,0 +1,1899 @@ +const unsigned char sdl_metallib[] = { + 0x4d, 0x54, 0x4c, 0x42, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xd8, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x54, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x4e, 0x41, 0x4d, 0x45, 0x11, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x53, 0x6f, + 0x6c, 0x69, 0x64, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x00, 0x54, + 0x59, 0x50, 0x45, 0x01, 0x00, 0x00, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, + 0xa1, 0x91, 0x35, 0x76, 0xce, 0x36, 0x38, 0x71, 0xba, 0x1c, 0x81, 0x62, + 0xda, 0x7c, 0x6b, 0x94, 0xc7, 0x88, 0x39, 0xd4, 0x91, 0xc2, 0xe7, 0xf9, + 0x21, 0x8c, 0x74, 0x25, 0xa9, 0xb0, 0x81, 0x85, 0x4f, 0x46, 0x46, 0x54, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x77, 0x00, 0x00, 0x00, + 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x43, 0x6f, + 0x70, 0x79, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x00, 0x54, 0x59, + 0x50, 0x45, 0x01, 0x00, 0x00, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, 0x71, + 0xbb, 0x07, 0x58, 0x1b, 0x7c, 0x44, 0xaa, 0x03, 0xc8, 0xab, 0x11, 0xe4, + 0x63, 0xdb, 0xe3, 0xe6, 0xce, 0x52, 0x97, 0x34, 0x82, 0xf0, 0x46, 0x70, + 0xaa, 0xa9, 0x31, 0x51, 0x3c, 0xe8, 0x39, 0x4f, 0x46, 0x46, 0x54, 0x18, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x7a, 0x00, 0x00, 0x00, 0x4e, + 0x41, 0x4d, 0x45, 0x13, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x53, 0x6f, 0x6c, + 0x69, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x00, + 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, 0x20, + 0x00, 0x4a, 0x07, 0x48, 0xd3, 0xb7, 0x7a, 0x3a, 0x01, 0x6c, 0xaa, 0x80, + 0xde, 0x84, 0x6e, 0x3c, 0x9a, 0xdd, 0x55, 0x90, 0x43, 0xa6, 0xdd, 0xbb, + 0xd6, 0xeb, 0xea, 0x81, 0x62, 0xf6, 0x50, 0x04, 0x95, 0x4f, 0x46, 0x46, + 0x54, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x16, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, 0x00, 0x00, + 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x43, + 0x6f, 0x70, 0x79, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, + 0x20, 0x00, 0x4c, 0xaa, 0x05, 0x27, 0x1a, 0x40, 0x5c, 0xe3, 0xd5, 0x46, + 0x38, 0xad, 0x07, 0xe7, 0x70, 0xdf, 0xde, 0x83, 0x74, 0x96, 0x26, 0x6e, + 0x35, 0x7b, 0xc9, 0xc5, 0x46, 0x08, 0x51, 0xb4, 0x13, 0xa8, 0x4f, 0x46, + 0x46, 0x54, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x78, 0x00, + 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x11, 0x00, 0x53, 0x44, 0x4c, 0x5f, + 0x59, 0x55, 0x56, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, + 0x20, 0x00, 0xc9, 0x73, 0x33, 0x9a, 0x36, 0x6d, 0x15, 0x10, 0xa2, 0x81, + 0xaa, 0xbf, 0x27, 0xb1, 0x22, 0xc6, 0x0a, 0x7b, 0x68, 0x66, 0xdb, 0xe9, + 0xab, 0x19, 0x22, 0x40, 0x87, 0x6b, 0x10, 0x93, 0xc5, 0xf5, 0x4f, 0x46, + 0x46, 0x54, 0x18, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x2a, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, 0x00, + 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, 0x5f, + 0x4e, 0x56, 0x31, 0x32, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, + 0x48, 0x20, 0x00, 0x59, 0x54, 0x77, 0x75, 0xe5, 0xb6, 0xd5, 0x2e, 0xf7, + 0xb1, 0x9d, 0xd1, 0x75, 0x39, 0x4c, 0x97, 0x0f, 0x40, 0x58, 0xaa, 0xc9, + 0x42, 0xe8, 0x03, 0x29, 0x1e, 0x93, 0x63, 0x0c, 0x91, 0x38, 0xc8, 0x4f, + 0x46, 0x46, 0x54, 0x18, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x38, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, + 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, + 0x00, 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, + 0x5f, 0x4e, 0x56, 0x32, 0x31, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, + 0x53, 0x48, 0x20, 0x00, 0x77, 0x01, 0x3e, 0x26, 0x2e, 0xc2, 0xe2, 0x34, + 0x70, 0xcf, 0x0c, 0x9e, 0x0d, 0xed, 0x69, 0xa4, 0x2a, 0x9c, 0x80, 0x06, + 0x52, 0xd1, 0x4b, 0x77, 0x6d, 0xda, 0x29, 0x27, 0x51, 0x25, 0xf4, 0x92, + 0x4f, 0x46, 0x46, 0x54, 0x18, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x46, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, + 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x30, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0xc9, 0x02, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0x20, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x02, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x18, + 0x80, 0x05, 0xa8, 0x36, 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x20, 0x01, 0x15, 0x31, 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, + 0x40, 0x0f, 0xec, 0x90, 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, + 0x40, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, + 0x40, 0x0e, 0xe5, 0xd0, 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, + 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, + 0x3c, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, + 0x3a, 0xb0, 0x43, 0x1b, 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, + 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, + 0x30, 0x0f, 0xf3, 0xd0, 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, + 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, + 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, + 0x3b, 0xa4, 0x43, 0x3b, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, + 0xe0, 0x0e, 0xef, 0xd0, 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, + 0xd0, 0x06, 0xf0, 0xf0, 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xe5, 0xc0, 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, + 0xe0, 0x0e, 0x6d, 0xc0, 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, + 0xf0, 0x0e, 0x6d, 0x90, 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, + 0x00, 0x0f, 0x6d, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, + 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, + 0x3d, 0xb4, 0x03, 0x3c, 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, + 0x39, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, + 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, + 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, + 0x3c, 0xa4, 0xc3, 0x39, 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, + 0x39, 0xc8, 0xc3, 0x3b, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, + 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, + 0x00, 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, + 0x20, 0x0f, 0x6d, 0x20, 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, + 0x3d, 0x84, 0x83, 0x3c, 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, + 0x39, 0x84, 0x03, 0x3d, 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, + 0x60, 0x0e, 0xf0, 0x10, 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, + 0x10, 0x0e, 0xe6, 0x50, 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, + 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, + 0x40, 0xd4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, + 0x3d, 0xb4, 0x81, 0x39, 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, + 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, 0x08, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x50, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x70, 0x9f, 0x34, 0x45, 0x94, + 0x30, 0xf9, 0xac, 0xb3, 0x20, 0xc3, 0x4b, 0x44, 0x13, 0x71, 0xa1, 0xd4, + 0xf4, 0x50, 0x93, 0xff, 0x00, 0x82, 0x42, 0x0c, 0x58, 0x08, 0x60, 0x18, + 0x41, 0x00, 0x06, 0x11, 0x86, 0x20, 0x09, 0xc2, 0x4c, 0xd3, 0x38, 0xb0, + 0x43, 0x38, 0xcc, 0xc3, 0x3c, 0xb8, 0x41, 0x3b, 0x94, 0x03, 0x3d, 0x84, + 0x03, 0x3b, 0xe8, 0x81, 0x1e, 0xb4, 0x43, 0x38, 0xd0, 0x83, 0x3c, 0xa4, + 0x03, 0x3e, 0xa0, 0xa0, 0x0c, 0x22, 0x18, 0xc2, 0x1c, 0x01, 0x18, 0x94, + 0x42, 0x90, 0x73, 0x10, 0xa5, 0x81, 0x00, 0x32, 0x73, 0x04, 0xa0, 0x30, + 0x88, 0x10, 0x08, 0x53, 0x00, 0x23, 0x00, 0xc3, 0x08, 0x04, 0x32, 0x47, + 0x10, 0x50, 0x00, 0x00, 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x74, 0x78, 0x87, 0x79, 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, + 0x0d, 0xef, 0x51, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, + 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, + 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xe9, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xf6, 0x40, 0x07, 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xf6, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, + 0x07, 0x72, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, + 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, + 0x07, 0x75, 0x10, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, + 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xee, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x43, 0x18, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x2c, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x42, + 0x25, 0x30, 0x02, 0x50, 0x80, 0x01, 0x05, 0x51, 0x04, 0x05, 0x52, 0x06, + 0xd4, 0x46, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0xb0, 0x00, 0x43, 0x0c, 0x24, 0x40, 0x08, 0x44, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0x59, 0x06, 0x24, 0x40, 0x02, 0x44, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x84, 0xe5, 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x95, 0xb9, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x96, 0x84, 0x61, 0x10, + 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, + 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, + 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, 0x16, + 0x32, 0x61, 0x69, 0x72, 0x2e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, + 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, + 0xd1, 0xd1, 0x90, 0x09, 0x4b, 0x93, 0x73, 0x09, 0x93, 0x3b, 0xfb, 0x72, + 0x0b, 0x6b, 0x2b, 0x23, 0x02, 0xf7, 0x36, 0x97, 0x46, 0x97, 0xf6, 0xe6, + 0x36, 0x44, 0x59, 0x9a, 0xc5, 0x59, 0x9e, 0x05, 0x5a, 0x22, 0x3a, 0x61, + 0x69, 0x72, 0x2e, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, + 0x65, 0x2c, 0xcc, 0xd8, 0xde, 0xc2, 0xe8, 0x98, 0xc0, 0xbd, 0xa5, 0xb9, + 0xd1, 0x4d, 0xa5, 0xe9, 0x95, 0x0d, 0x51, 0x96, 0x69, 0x71, 0x16, 0x6a, + 0x81, 0x96, 0x6a, 0x08, 0xb1, 0x48, 0x8b, 0x45, 0x25, 0x2c, 0x4d, 0xce, + 0x45, 0xac, 0xce, 0xcc, 0xac, 0x4c, 0x8e, 0x52, 0x58, 0x9a, 0x9c, 0x0b, + 0xdb, 0xdb, 0x58, 0x18, 0x5d, 0xda, 0x9b, 0xdb, 0x57, 0x9a, 0x1b, 0x59, + 0x19, 0x1e, 0x91, 0xb0, 0x34, 0x39, 0x17, 0xb9, 0xb2, 0x30, 0x32, 0x46, + 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0xbc, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, + 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xc2, 0xd8, 0xd2, 0xce, 0xdc, + 0xbe, 0xe6, 0xd2, 0xf4, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xc9, + 0x0c, 0xe1, 0x10, 0x61, 0xc1, 0x96, 0x0c, 0x11, 0x90, 0x60, 0xd1, 0x96, + 0x0d, 0x21, 0x16, 0x0e, 0x21, 0x16, 0x67, 0xe9, 0x16, 0x68, 0x89, 0xf8, + 0x84, 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, + 0xa5, 0xe9, 0x95, 0x11, 0x31, 0x63, 0x7b, 0x0b, 0xa3, 0xa3, 0xc1, 0xa3, + 0xa1, 0x02, 0x27, 0xf7, 0xa6, 0x56, 0x36, 0x46, 0x97, 0xf6, 0xe6, 0x36, + 0x04, 0x0c, 0x90, 0x60, 0xc1, 0x96, 0x0f, 0x19, 0x96, 0x0c, 0x29, 0x90, + 0x60, 0xd1, 0x96, 0x0d, 0x19, 0x16, 0x0e, 0x31, 0x16, 0x67, 0x01, 0x83, + 0x05, 0x5a, 0xc2, 0x80, 0x09, 0x9d, 0x5c, 0x98, 0xdb, 0x9c, 0xd9, 0x9b, + 0x5c, 0xdb, 0x10, 0x30, 0x40, 0x8a, 0x05, 0x5b, 0x3e, 0x64, 0x58, 0x32, + 0xe4, 0x40, 0x82, 0x45, 0x5b, 0x36, 0x64, 0x58, 0x38, 0xc4, 0x58, 0x9c, + 0x05, 0x0c, 0x16, 0x68, 0x19, 0x03, 0x36, 0x61, 0x69, 0x72, 0x2e, 0x76, + 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x64, 0x24, 0xea, 0xd2, 0xdc, + 0xe8, 0x38, 0xd8, 0xa5, 0x91, 0x0d, 0x61, 0x90, 0x63, 0x29, 0x83, 0xc5, + 0x59, 0xcc, 0x60, 0x81, 0x96, 0x33, 0x18, 0x82, 0x2c, 0xde, 0x22, 0x06, + 0x0b, 0x19, 0x2c, 0x68, 0x30, 0xc4, 0x50, 0x80, 0xe5, 0x5a, 0xd2, 0x80, + 0xcf, 0x5b, 0x9b, 0x5b, 0x1a, 0xdc, 0x1b, 0x5d, 0x99, 0x1b, 0x1d, 0xc8, + 0x18, 0x5a, 0x98, 0x1c, 0x9f, 0xa9, 0xb4, 0x36, 0x38, 0xb6, 0x32, 0x90, + 0xa1, 0x95, 0x15, 0x10, 0x2a, 0xa1, 0xa0, 0xa0, 0x21, 0xc2, 0xc2, 0x06, + 0x43, 0x8c, 0x65, 0x0d, 0x96, 0x36, 0x68, 0x90, 0x21, 0xc6, 0xe2, 0x06, + 0x8b, 0x1b, 0x34, 0xc8, 0x08, 0x85, 0x1d, 0xd8, 0xc1, 0x1e, 0xda, 0xc1, + 0x0d, 0xd2, 0x81, 0x1c, 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0x10, 0x8c, + 0x58, 0xc2, 0x21, 0x1d, 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x61, + 0x1e, 0xd2, 0xe1, 0x1d, 0xdc, 0x61, 0x4a, 0x20, 0x8c, 0xa0, 0xc2, 0x21, + 0x1d, 0xe4, 0xc1, 0x0d, 0xd8, 0x21, 0x1c, 0xdc, 0xe1, 0x1c, 0xea, 0x21, + 0x1c, 0xce, 0xa1, 0x1c, 0x7e, 0xc1, 0x1e, 0xca, 0x41, 0x1e, 0xe6, 0x21, + 0x1d, 0xde, 0xc1, 0x1d, 0xa6, 0x04, 0xc4, 0x88, 0x29, 0x1c, 0xd2, 0x41, + 0x1e, 0xdc, 0x60, 0x1c, 0xde, 0xa1, 0x1d, 0xe0, 0x21, 0x1d, 0xd8, 0xa1, + 0x1c, 0x7e, 0xe1, 0x1d, 0xe0, 0x81, 0x1e, 0xd2, 0xe1, 0x1d, 0xdc, 0x61, + 0x1e, 0xa6, 0x10, 0x06, 0xa2, 0x30, 0x23, 0x94, 0x70, 0x48, 0x07, 0x79, + 0x70, 0x03, 0x7b, 0x28, 0x07, 0x79, 0xa0, 0x87, 0x72, 0xc0, 0x87, 0x29, + 0x81, 0x1a, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, + 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, + 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, + 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, + 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, + 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, + 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, + 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, + 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, + 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, + 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, + 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, + 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, + 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, + 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0xb1, 0x5d, 0xf9, 0xb3, 0xce, 0x82, + 0x0c, 0x7f, 0x45, 0x44, 0x13, 0x71, 0x01, 0x00, 0x61, 0x20, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x13, 0x04, 0x47, 0x2c, 0x10, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x14, 0xe7, 0x20, 0x84, 0x60, 0x9a, 0x46, 0x00, + 0xa8, 0x95, 0x41, 0x11, 0x94, 0x00, 0xa1, 0x42, 0x98, 0x01, 0xa0, 0x31, + 0x03, 0x40, 0x62, 0x06, 0x80, 0xc2, 0x0c, 0x00, 0x81, 0x11, 0x80, 0x31, + 0x02, 0x10, 0x04, 0x41, 0xfc, 0x03, 0x00, 0x00, 0x33, 0x11, 0x0c, 0x12, + 0x14, 0x33, 0x11, 0x0c, 0x12, 0x14, 0xe3, 0x11, 0xd1, 0x94, 0x4d, 0x14, + 0x94, 0x59, 0x82, 0x60, 0xa0, 0x02, 0xb1, 0x03, 0xe0, 0x0c, 0x86, 0x0b, + 0x9a, 0x8c, 0x47, 0x50, 0x57, 0x17, 0x50, 0x50, 0x06, 0x19, 0x82, 0x65, + 0xb2, 0xc0, 0x90, 0xcf, 0x2c, 0x81, 0x30, 0x50, 0x81, 0x90, 0x42, 0x50, + 0x09, 0x03, 0x15, 0x01, 0x11, 0x44, 0xc2, 0x18, 0x42, 0x21, 0xcc, 0x31, + 0x40, 0x01, 0x19, 0x0c, 0x32, 0x04, 0x51, 0x76, 0x45, 0x93, 0xf1, 0x88, + 0x2f, 0x0c, 0xce, 0x20, 0xa0, 0xa0, 0x58, 0x40, 0xc8, 0xc7, 0x02, 0x04, + 0x3e, 0xa6, 0xb0, 0x01, 0x0c, 0x86, 0x1b, 0x02, 0x0e, 0x0c, 0x66, 0x19, + 0x06, 0x21, 0x18, 0x8f, 0xb0, 0xce, 0xa0, 0x0d, 0xa2, 0xc1, 0x88, 0x80, + 0x28, 0x00, 0x9b, 0xde, 0x00, 0x06, 0xc3, 0x0d, 0xc1, 0x07, 0x06, 0xb3, + 0x0c, 0x44, 0x10, 0x8c, 0x47, 0x64, 0x6a, 0x00, 0x07, 0x6a, 0x40, 0x41, + 0x19, 0x8f, 0xd8, 0xd8, 0x40, 0x0e, 0xc6, 0x80, 0x82, 0x32, 0x1e, 0xd1, + 0xb9, 0x01, 0x1d, 0x98, 0x01, 0x05, 0x65, 0x3c, 0xe2, 0x83, 0x03, 0x3b, + 0x48, 0x03, 0x0a, 0xca, 0x78, 0x04, 0x18, 0xc8, 0x01, 0x1e, 0xc8, 0xc1, + 0x60, 0x44, 0x80, 0x14, 0xc0, 0x78, 0x44, 0x18, 0xcc, 0x41, 0x1e, 0xa8, + 0xc1, 0x60, 0x44, 0x70, 0x14, 0xc0, 0x78, 0x84, 0x18, 0xd0, 0x81, 0x1e, + 0xb0, 0xc1, 0x60, 0x44, 0x60, 0x14, 0xc0, 0x78, 0xc4, 0x18, 0xd4, 0xc1, + 0x1e, 0xb8, 0xc1, 0x60, 0x44, 0x50, 0x14, 0xc0, 0xc9, 0x41, 0x8b, 0xf1, + 0x04, 0x3b, 0x08, 0x28, 0x20, 0x83, 0x0c, 0x41, 0x1b, 0xd0, 0xc1, 0x1c, + 0x43, 0xb0, 0x06, 0x7d, 0x30, 0xc7, 0x10, 0xac, 0x01, 0x1f, 0x0c, 0x32, + 0x04, 0x6e, 0x60, 0x07, 0x16, 0x48, 0xf2, 0x99, 0x25, 0x28, 0x06, 0x2a, + 0x10, 0x95, 0x20, 0xaa, 0x62, 0xa0, 0x22, 0x20, 0x88, 0xa8, 0x18, 0x43, + 0x28, 0x84, 0x39, 0x86, 0x39, 0x08, 0x4e, 0x61, 0x90, 0x21, 0xa0, 0x03, + 0x3e, 0xb8, 0xa2, 0xc9, 0x78, 0x84, 0x1c, 0x90, 0x82, 0x2a, 0x04, 0x14, + 0x14, 0x0b, 0x08, 0xf9, 0x58, 0x80, 0xc0, 0xc7, 0x94, 0x57, 0x80, 0xc1, + 0x70, 0x43, 0xf0, 0x07, 0x60, 0x30, 0xcb, 0x60, 0x14, 0xc1, 0x6c, 0x43, + 0x1f, 0x0c, 0xc0, 0x6c, 0x43, 0xb0, 0x07, 0x41, 0x06, 0x01, 0x31, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x21, 0x78, 0x83, 0x2d, 0x03, 0x12, + 0xbc, 0xc1, 0x96, 0x61, 0x0a, 0xde, 0x60, 0xcb, 0xa0, 0x05, 0x6f, 0xb0, + 0x65, 0x80, 0x83, 0xe0, 0x0d, 0xb6, 0x0c, 0x7e, 0x10, 0xbc, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, + 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x88, 0x0b, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, + 0xdf, 0x02, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, + 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, + 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, + 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, + 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, + 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, + 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0x20, 0x00, 0x16, 0xa0, 0xda, 0x60, 0x08, 0x02, 0xb0, 0x00, + 0xd5, 0x06, 0x63, 0x18, 0x80, 0x05, 0xa8, 0x36, 0x18, 0x04, 0x01, 0x2c, + 0x40, 0xb5, 0x81, 0x5c, 0x8a, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x09, + 0xa8, 0x88, 0x71, 0x78, 0x07, 0x79, 0x90, 0x87, 0x72, 0x18, 0x07, 0x7a, + 0x60, 0x87, 0x7c, 0x68, 0x03, 0x79, 0x78, 0x87, 0x7a, 0x70, 0x07, 0x72, + 0x28, 0x07, 0x72, 0x68, 0x03, 0x72, 0x48, 0x07, 0x7b, 0x48, 0x07, 0x72, + 0x28, 0x87, 0x36, 0x98, 0x87, 0x78, 0x90, 0x07, 0x7a, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xcc, 0x21, + 0x1c, 0xd8, 0x61, 0x1e, 0xca, 0x01, 0x20, 0xc8, 0x21, 0x1d, 0xe6, 0x21, + 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0xa1, 0x0d, 0xe8, 0x21, 0x1c, 0xd2, 0x81, + 0x1d, 0xda, 0x60, 0x1c, 0xc2, 0x81, 0x1d, 0xd8, 0x61, 0x1e, 0x00, 0x73, + 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x76, 0x28, 0x87, 0x79, + 0x98, 0x87, 0x36, 0x80, 0x07, 0x79, 0x28, 0x87, 0x71, 0x48, 0x87, 0x79, + 0x28, 0x87, 0x36, 0x30, 0x07, 0x78, 0x68, 0x87, 0x70, 0x20, 0x07, 0x80, + 0x1e, 0xe4, 0xa1, 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0xc0, + 0x1c, 0xe4, 0x21, 0x1c, 0xda, 0xa1, 0x1c, 0xda, 0x00, 0x1e, 0xde, 0x21, + 0x1d, 0xdc, 0x81, 0x1e, 0xca, 0x41, 0x1e, 0xda, 0xa0, 0x1c, 0xd8, 0x21, + 0x1d, 0xda, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x06, 0x77, + 0x78, 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, + 0x80, 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, + 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x68, 0x03, 0x77, 0x78, 0x07, 0x77, + 0x68, 0x03, 0x76, 0x28, 0x87, 0x70, 0x30, 0x07, 0x80, 0x70, 0x87, 0x77, + 0x68, 0x83, 0x74, 0x70, 0x07, 0x73, 0x98, 0x87, 0x36, 0x30, 0x07, 0x78, + 0x68, 0x83, 0x76, 0x08, 0x07, 0x7a, 0x40, 0x07, 0x80, 0x1e, 0xe4, 0xa1, + 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x40, 0x1d, 0xea, 0xa1, + 0x1d, 0xe0, 0xa1, 0x0d, 0xe8, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, + 0x1e, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x77, + 0x78, 0x87, 0x36, 0x70, 0x87, 0x70, 0x70, 0x87, 0x79, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, + 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xe6, 0x21, + 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, 0xda, 0x40, 0x1f, 0xca, 0x41, + 0x1e, 0xde, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, + 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, + 0x00, 0x88, 0x79, 0xa0, 0x87, 0x70, 0x18, 0x87, 0x75, 0x68, 0x03, 0x78, + 0x90, 0x87, 0x77, 0xa0, 0x87, 0x72, 0x18, 0x07, 0x7a, 0x78, 0x07, 0x79, + 0x68, 0x03, 0x71, 0xa8, 0x07, 0x73, 0x30, 0x87, 0x72, 0x90, 0x87, 0x36, + 0x98, 0x87, 0x74, 0xd0, 0x87, 0x72, 0x00, 0xf0, 0x00, 0x20, 0xe8, 0x21, + 0x1c, 0xe4, 0xe1, 0x1c, 0xca, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xca, 0x21, + 0x1c, 0xe8, 0xa1, 0x1e, 0xe4, 0xa1, 0x1c, 0xe6, 0x01, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x38, 0xb0, 0x03, 0x80, 0xa8, 0x07, 0x77, 0x98, 0x87, 0x70, + 0x30, 0x87, 0x72, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, + 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xa2, + 0x1e, 0xe6, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xde, 0xc1, 0x1c, 0xe8, 0xa1, + 0x0d, 0xcc, 0x81, 0x1d, 0xde, 0x21, 0x1c, 0xe8, 0x01, 0x30, 0x87, 0x70, + 0x60, 0x87, 0x79, 0x28, 0x07, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x8a, 0x40, 0x18, 0x88, 0x02, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x50, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0xe7, + 0x49, 0x53, 0x44, 0x09, 0x93, 0xcf, 0x39, 0x0f, 0xf6, 0x12, 0xd1, 0x44, + 0x5c, 0x28, 0x35, 0x3d, 0xd4, 0xe4, 0x3f, 0x80, 0xa0, 0x10, 0x03, 0x16, + 0x82, 0x18, 0x44, 0x10, 0x82, 0x24, 0x08, 0x33, 0x4d, 0xe3, 0xc0, 0x0e, + 0xe1, 0x30, 0x0f, 0xf3, 0xe0, 0x06, 0xed, 0x50, 0x0e, 0xf4, 0x10, 0x0e, + 0xec, 0xa0, 0x07, 0x7a, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xf2, 0x90, 0x0e, + 0xf8, 0x80, 0x82, 0x32, 0x88, 0x60, 0x08, 0x73, 0x04, 0x60, 0x50, 0x8c, + 0x41, 0xc8, 0x39, 0x88, 0xd2, 0x40, 0x00, 0x99, 0x39, 0x02, 0x50, 0x18, + 0x44, 0x08, 0x84, 0x29, 0x80, 0x11, 0x80, 0x61, 0x04, 0x02, 0x99, 0x23, + 0x08, 0x28, 0x00, 0x00, 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x74, 0x78, 0x87, 0x79, 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, + 0x0d, 0xef, 0x51, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, + 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, + 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xe9, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xf6, 0x40, 0x07, 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xf6, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, + 0x07, 0x72, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, + 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, + 0x07, 0x75, 0x10, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, + 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xee, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x43, 0x18, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x2c, 0x10, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x42, + 0x25, 0x50, 0x10, 0x23, 0x00, 0x05, 0x18, 0x50, 0x04, 0x05, 0x52, 0x06, + 0x85, 0x40, 0x6d, 0x04, 0x00, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0xd3, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, + 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, + 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, + 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, + 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0xb0, 0x00, 0x43, 0x0c, 0x24, 0x40, + 0x04, 0x64, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0x59, 0x06, + 0x24, 0x40, 0x02, 0x64, 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, + 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, + 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, 0x0a, + 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x84, 0xe5, 0x20, 0x19, 0x84, 0xa5, + 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, + 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, + 0xd1, 0x8d, 0xa1, 0x7d, 0x95, 0xb9, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, + 0x96, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, + 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, + 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0x58, 0x16, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, + 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, + 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x90, 0x09, 0x4b, 0x93, 0x73, 0x09, + 0x93, 0x3b, 0xfb, 0x72, 0x0b, 0x6b, 0x2b, 0x23, 0x02, 0xf7, 0x36, 0x97, + 0x46, 0x97, 0xf6, 0xe6, 0x36, 0x44, 0x59, 0x9a, 0xc5, 0x59, 0x9e, 0x05, + 0x5a, 0x22, 0x46, 0x61, 0x69, 0x72, 0x2e, 0x76, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0xcc, 0xce, 0xca, 0xdc, + 0xca, 0xe4, 0xc2, 0xe8, 0xca, 0xc8, 0x50, 0x70, 0xe8, 0xca, 0xf0, 0xc6, + 0xde, 0xde, 0xe4, 0xc8, 0x88, 0xec, 0x64, 0xbe, 0xcc, 0x52, 0x68, 0x98, + 0xb1, 0xbd, 0x85, 0xd1, 0xc9, 0x10, 0xa1, 0x2b, 0xc3, 0x1b, 0x7b, 0x7b, + 0x93, 0x23, 0x1b, 0xc2, 0x2c, 0xd3, 0x42, 0x2d, 0xce, 0x52, 0x2d, 0xd0, + 0x62, 0x0d, 0x21, 0x16, 0x69, 0xb9, 0xa8, 0x84, 0xa5, 0xc9, 0xb9, 0x88, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, + 0x1b, 0x0b, 0xa3, 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, + 0x23, 0x12, 0x96, 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, + 0x4d, 0xce, 0x25, 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, + 0x2e, 0x4d, 0xaf, 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, + 0x17, 0x5d, 0x1e, 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, + 0x5c, 0x9a, 0x5e, 0xd9, 0x10, 0x0e, 0x19, 0x96, 0x6c, 0xd1, 0x90, 0x01, + 0x09, 0x96, 0x6d, 0xe1, 0x10, 0x61, 0xe9, 0x10, 0x61, 0x71, 0x96, 0x6a, + 0x81, 0x96, 0x88, 0x09, 0x5d, 0x19, 0xde, 0xd8, 0xdb, 0x9b, 0x1c, 0xd9, + 0xdc, 0x10, 0x0e, 0x09, 0x96, 0x6c, 0xd1, 0x90, 0x00, 0x09, 0x96, 0x6d, + 0xe1, 0x10, 0x61, 0xe9, 0x10, 0x61, 0x71, 0x96, 0x6a, 0x81, 0x96, 0x8f, + 0x4f, 0x58, 0x9a, 0x9c, 0x8b, 0x58, 0x9d, 0x99, 0x59, 0x99, 0xdc, 0xd7, + 0x5c, 0x9a, 0x5e, 0x19, 0x11, 0x33, 0xb6, 0xb7, 0x30, 0x3a, 0x1a, 0x3c, + 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x43, 0xc0, 0x00, 0x29, 0x96, 0x6c, 0x09, 0x03, 0x84, 0x58, 0x34, 0xa4, + 0x40, 0x82, 0x65, 0x5b, 0x38, 0x84, 0x58, 0x3a, 0xc4, 0x58, 0x9c, 0x45, + 0x0c, 0x16, 0x68, 0x19, 0x03, 0x26, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, + 0x6f, 0x72, 0x6d, 0x43, 0xc0, 0x00, 0x39, 0x96, 0x6c, 0x09, 0x03, 0x84, + 0x58, 0x34, 0xe4, 0x40, 0x82, 0x65, 0x5b, 0x38, 0x84, 0x58, 0x3a, 0xc4, + 0x58, 0x9c, 0x45, 0x0c, 0x16, 0x68, 0x29, 0x03, 0x36, 0x61, 0x69, 0x72, + 0x2e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x64, 0x24, 0xea, + 0xd2, 0xdc, 0xe8, 0x38, 0xd8, 0xa5, 0x91, 0x0d, 0x61, 0x10, 0x64, 0x39, + 0x83, 0xc5, 0x59, 0xd0, 0x60, 0x81, 0x96, 0x34, 0x18, 0xa2, 0x2c, 0xde, + 0x02, 0x06, 0x0b, 0x19, 0x2c, 0x66, 0xb0, 0xa8, 0xc1, 0x10, 0x43, 0x01, + 0x16, 0x6c, 0x59, 0x03, 0x3e, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, + 0x65, 0x6e, 0x74, 0x20, 0x63, 0x68, 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, + 0xe0, 0xd8, 0xca, 0x40, 0x86, 0x56, 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, + 0x86, 0x08, 0x8b, 0x1b, 0x0c, 0x31, 0x96, 0x36, 0x58, 0xde, 0xa0, 0x49, + 0x86, 0x18, 0x0b, 0x1c, 0x2c, 0x70, 0xd0, 0x24, 0x23, 0x14, 0x76, 0x60, + 0x07, 0x7b, 0x68, 0x07, 0x37, 0x48, 0x07, 0x72, 0x28, 0x07, 0x77, 0xa0, + 0x87, 0x29, 0x41, 0x30, 0x62, 0x09, 0x87, 0x74, 0x90, 0x07, 0x37, 0xb0, + 0x87, 0x72, 0x90, 0x87, 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x81, + 0x30, 0x82, 0x0a, 0x87, 0x74, 0x90, 0x07, 0x37, 0x60, 0x87, 0x70, 0x70, + 0x87, 0x73, 0xa8, 0x87, 0x70, 0x38, 0x87, 0x72, 0xf8, 0x05, 0x7b, 0x28, + 0x07, 0x79, 0x98, 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x10, 0x23, + 0xa6, 0x70, 0x48, 0x07, 0x79, 0x70, 0x83, 0x71, 0x78, 0x87, 0x76, 0x80, + 0x87, 0x74, 0x60, 0x87, 0x72, 0xf8, 0x85, 0x77, 0x80, 0x07, 0x7a, 0x48, + 0x87, 0x77, 0x70, 0x87, 0x79, 0x98, 0x42, 0x18, 0x88, 0xc2, 0x8c, 0x50, + 0xc2, 0x21, 0x1d, 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x81, 0x1e, + 0xca, 0x01, 0x1f, 0xa6, 0x04, 0x6c, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, + 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, + 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, + 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, + 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, + 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, + 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, + 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, + 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0xf0, 0xb0, 0x5d, + 0xf9, 0x73, 0xce, 0x83, 0xfd, 0x15, 0x11, 0x4d, 0xc4, 0x05, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x13, 0x04, 0x47, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x14, 0xe7, 0x20, 0x86, + 0x80, 0xa2, 0x46, 0x00, 0xa8, 0x95, 0x41, 0x11, 0x94, 0x00, 0xa1, 0x19, + 0x00, 0x1a, 0x33, 0x00, 0x24, 0x66, 0x00, 0x28, 0xcc, 0x00, 0x10, 0x18, + 0x23, 0x00, 0x41, 0x10, 0xc4, 0xbf, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x33, 0x11, 0x0c, 0x12, 0x14, 0x33, 0x11, 0x0c, 0x12, 0x14, 0xe3, 0x11, + 0xd0, 0x94, 0x4d, 0x14, 0x94, 0x59, 0x82, 0x60, 0xa0, 0x02, 0xb1, 0x03, + 0xe0, 0x0c, 0x86, 0x0b, 0x9a, 0x8c, 0x47, 0x4c, 0x57, 0x17, 0x50, 0x50, + 0x06, 0x19, 0x82, 0x45, 0xb2, 0xc0, 0x90, 0xcf, 0x2c, 0x81, 0x30, 0x50, + 0x81, 0x98, 0x42, 0x50, 0x09, 0x03, 0x15, 0x01, 0x11, 0x44, 0xc2, 0x18, + 0x42, 0x21, 0xcc, 0x31, 0x40, 0x01, 0x19, 0x0c, 0x32, 0x04, 0x11, 0x76, + 0x45, 0x93, 0xf1, 0x08, 0x2f, 0x0c, 0xce, 0x20, 0xa0, 0xa0, 0x58, 0x40, + 0xc8, 0xc7, 0x02, 0x04, 0x3e, 0xa6, 0xb4, 0x01, 0x0c, 0x86, 0x1b, 0x82, + 0x33, 0x00, 0x83, 0x59, 0x86, 0x41, 0x08, 0xc6, 0x23, 0xac, 0x33, 0x68, + 0x83, 0x68, 0x30, 0x22, 0x20, 0x0a, 0xc0, 0x26, 0x38, 0x80, 0xc1, 0x70, + 0x43, 0xa0, 0x06, 0x60, 0x30, 0xcb, 0x40, 0x04, 0xc1, 0x78, 0x44, 0xa6, + 0x06, 0x70, 0xa0, 0x06, 0x14, 0x94, 0xf1, 0x88, 0x8d, 0x0d, 0xe4, 0x40, + 0x0c, 0x28, 0x28, 0xe3, 0x11, 0x9d, 0x1b, 0xd0, 0x41, 0x19, 0x50, 0x50, + 0xc6, 0x23, 0x3e, 0x38, 0xb0, 0x03, 0x34, 0xa0, 0xa0, 0x8c, 0x47, 0x80, + 0x81, 0x1c, 0xe0, 0x81, 0x1c, 0x0c, 0x46, 0x04, 0x48, 0x01, 0x8c, 0x47, + 0x84, 0xc1, 0x1c, 0xe4, 0x41, 0x1a, 0x0c, 0x46, 0x04, 0x47, 0x01, 0x8c, + 0x47, 0x88, 0x01, 0x1d, 0xe8, 0xc1, 0x1a, 0x0c, 0x46, 0x04, 0x46, 0x01, + 0x8c, 0x47, 0x8c, 0x41, 0x1d, 0xec, 0x41, 0x1b, 0x0c, 0x46, 0x04, 0x45, + 0x01, 0x5c, 0x1c, 0xb4, 0x18, 0x4f, 0xb0, 0x83, 0x80, 0x02, 0x32, 0xc8, + 0x10, 0xb0, 0xc1, 0x1c, 0xcc, 0x31, 0x04, 0x6a, 0xe0, 0x07, 0x73, 0x0c, + 0x01, 0x1b, 0xf4, 0xc1, 0x20, 0x43, 0xe0, 0x06, 0x75, 0x60, 0x81, 0x24, + 0x9f, 0x59, 0x82, 0x62, 0xa0, 0x02, 0x61, 0x09, 0xa2, 0x2a, 0x06, 0x2a, + 0x02, 0x82, 0x88, 0x8a, 0x31, 0x84, 0x42, 0x98, 0x63, 0x98, 0x83, 0xe0, + 0x14, 0x06, 0x19, 0x02, 0x3a, 0xd8, 0x83, 0x2b, 0x9a, 0x8c, 0x47, 0xc8, + 0x01, 0x29, 0xa8, 0x42, 0x40, 0x41, 0xb1, 0x80, 0x90, 0x8f, 0x05, 0x08, + 0x7c, 0x4c, 0x81, 0x05, 0x18, 0x0c, 0x37, 0x04, 0xaa, 0x00, 0x06, 0xb3, + 0x0c, 0x46, 0x11, 0x8c, 0x27, 0xa0, 0x02, 0x45, 0x01, 0x99, 0x6d, 0x00, + 0x85, 0x02, 0x98, 0x6d, 0x08, 0x84, 0x20, 0x83, 0x80, 0x18, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x21, 0x88, 0x83, 0x2d, 0x03, 0x12, + 0xc4, 0xc1, 0x96, 0x61, 0x0a, 0xe2, 0x60, 0xcb, 0xa0, 0x05, 0x71, 0xb0, + 0x65, 0x80, 0x83, 0x20, 0x0e, 0xb6, 0x0c, 0x7e, 0x10, 0xc4, 0xc1, 0x96, + 0xa1, 0x14, 0x82, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, + 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x90, 0x08, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, + 0x21, 0x02, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, + 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, + 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, + 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, + 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, + 0x24, 0x07, 0xc8, 0x08, 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, + 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0x20, 0x00, 0x16, 0xa0, 0xda, 0x40, 0x2e, 0xc2, 0xff, 0xff, + 0xff, 0xff, 0x0f, 0x80, 0x04, 0x54, 0xc4, 0x38, 0xbc, 0x83, 0x3c, 0xc8, + 0x43, 0x39, 0x8c, 0x03, 0x3d, 0xb0, 0x43, 0x3e, 0xb4, 0x81, 0x3c, 0xbc, + 0x43, 0x3d, 0xb8, 0x03, 0x39, 0x94, 0x03, 0x39, 0xb4, 0x01, 0x39, 0xa4, + 0x83, 0x3d, 0xa4, 0x03, 0x39, 0x94, 0x43, 0x1b, 0xcc, 0x43, 0x3c, 0xc8, + 0x03, 0x3d, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, + 0x03, 0x3a, 0x00, 0xe6, 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x10, + 0xe4, 0x90, 0x0e, 0xf3, 0x10, 0x0e, 0xe2, 0xc0, 0x0e, 0xe5, 0xd0, 0x06, + 0xf4, 0x10, 0x0e, 0xe9, 0xc0, 0x0e, 0x6d, 0x30, 0x0e, 0xe1, 0xc0, 0x0e, + 0xec, 0x30, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, + 0x04, 0x3b, 0x94, 0xc3, 0x3c, 0xcc, 0x43, 0x1b, 0xc0, 0x83, 0x3c, 0x94, + 0xc3, 0x38, 0xa4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, + 0x43, 0x38, 0x90, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, + 0xee, 0xf0, 0x0e, 0x6d, 0x60, 0x0e, 0xf2, 0x10, 0x0e, 0xed, 0x50, 0x0e, + 0x6d, 0x00, 0x0f, 0xef, 0x90, 0x0e, 0xee, 0x40, 0x0f, 0xe5, 0x20, 0x0f, + 0x6d, 0x50, 0x0e, 0xec, 0x90, 0x0e, 0xed, 0x00, 0xd0, 0x83, 0x3c, 0xd4, + 0x43, 0x39, 0x00, 0x83, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, 0x84, + 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, 0x3b, 0xa4, 0x83, 0x3b, 0xd0, + 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, 0xb4, + 0x81, 0x3b, 0xbc, 0x83, 0x3b, 0xb4, 0x01, 0x3b, 0x94, 0x43, 0x38, 0x98, + 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0x41, 0x3a, 0xb8, 0x83, 0x39, 0xcc, + 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, 0xa0, + 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, 0x0e, + 0x6d, 0xa0, 0x0e, 0xf5, 0xd0, 0x0e, 0xf0, 0xd0, 0x06, 0xf4, 0x10, 0x0e, + 0xe2, 0xc0, 0x0e, 0xe5, 0x30, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, + 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xb8, 0x43, 0x38, 0xb8, + 0xc3, 0x3c, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, + 0x03, 0x3a, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0xe1, 0x0e, + 0xef, 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xe7, 0xe0, 0x0e, 0xe5, 0x40, 0x0e, + 0x6d, 0xa0, 0x0f, 0xe5, 0x20, 0x0f, 0xef, 0x30, 0x0f, 0x6d, 0x60, 0x0e, + 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, 0x39, 0x84, + 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0xc4, 0x3c, 0xd0, 0x43, 0x38, 0x8c, + 0xc3, 0x3a, 0xb4, 0x01, 0x3c, 0xc8, 0xc3, 0x3b, 0xd0, 0x43, 0x39, 0x8c, + 0x03, 0x3d, 0xbc, 0x83, 0x3c, 0xb4, 0x81, 0x38, 0xd4, 0x83, 0x39, 0x98, + 0x43, 0x39, 0xc8, 0x43, 0x1b, 0xcc, 0x43, 0x3a, 0xe8, 0x43, 0x39, 0x00, + 0x78, 0x00, 0x10, 0xf4, 0x10, 0x0e, 0xf2, 0x70, 0x0e, 0xe5, 0x40, 0x0f, + 0x6d, 0x60, 0x0e, 0xe5, 0x10, 0x0e, 0xf4, 0x50, 0x0f, 0xf2, 0x50, 0x0e, + 0xf3, 0x00, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1c, 0xd8, 0x01, 0x40, 0xd4, + 0x83, 0x3b, 0xcc, 0x43, 0x38, 0x98, 0x43, 0x39, 0xb4, 0x81, 0x39, 0xc0, + 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, 0x00, 0xf4, 0x20, 0x0f, + 0xf5, 0x50, 0x0e, 0x00, 0x51, 0x0f, 0xf3, 0x50, 0x0e, 0x6d, 0x30, 0x0f, + 0xef, 0x60, 0x0e, 0xf4, 0xd0, 0x06, 0xe6, 0xc0, 0x0e, 0xef, 0x10, 0x0e, + 0xf4, 0x00, 0x98, 0x43, 0x38, 0xb0, 0xc3, 0x3c, 0x94, 0x03, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x84, 0x40, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x22, 0x08, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x13, 0x22, 0xa4, 0x84, 0x04, 0x13, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, 0x0b, 0x84, 0x84, 0x4c, + 0x10, 0x24, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x88, 0x10, 0x08, 0x45, + 0x08, 0xa1, 0x19, 0x08, 0x98, 0x23, 0x00, 0x83, 0x39, 0x02, 0x50, 0x18, + 0x01, 0x00, 0x00, 0x00, 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x74, 0x78, 0x87, 0x79, 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, + 0x0d, 0xef, 0x51, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, + 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, + 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xe9, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xf6, 0x40, 0x07, 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xf6, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, + 0x07, 0x72, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, + 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, + 0x07, 0x75, 0x10, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, + 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xee, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x43, 0x18, 0x02, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x2c, 0x10, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x0c, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xb2, + 0x11, 0x80, 0x12, 0x28, 0x90, 0x82, 0xa0, 0x1b, 0x01, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, + 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, + 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, + 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, + 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x50, 0x00, + 0x43, 0x0c, 0x43, 0x30, 0x08, 0x23, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, + 0x36, 0x04, 0x29, 0x06, 0x43, 0x30, 0x04, 0x23, 0xe0, 0x16, 0x96, 0x26, + 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, + 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0x28, 0x0a, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, + 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x84, 0xe2, + 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, + 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, + 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, 0x95, 0xb9, 0x85, 0x89, + 0xb1, 0x95, 0x0d, 0x11, 0x8a, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, 0x32, + 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, 0x66, + 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x28, 0x16, 0x46, 0x61, 0x69, 0x72, + 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, + 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, + 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0x8a, 0xc6, 0x08, 0x0a, 0xa7, 0x78, 0x86, + 0x08, 0x05, 0x44, 0x25, 0x2c, 0x4d, 0xce, 0x45, 0xac, 0xce, 0xcc, 0xac, + 0x4c, 0x8e, 0x4f, 0x58, 0x9a, 0x9c, 0x8b, 0x58, 0x9d, 0x99, 0x59, 0x99, + 0xdc, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0xa5, 0xb0, 0x34, 0x39, 0x17, 0xb6, + 0xb7, 0xb1, 0x30, 0xba, 0xb4, 0x37, 0xb7, 0xaf, 0x34, 0x37, 0xb2, 0x32, + 0x3c, 0x22, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x8c, 0xc2, + 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, + 0xe6, 0xd2, 0xf4, 0xca, 0x78, 0x85, 0xa5, 0xc9, 0xb9, 0x84, 0xc9, 0x9d, + 0x7d, 0xd1, 0xe5, 0xc1, 0x95, 0x7d, 0x85, 0xb1, 0xa5, 0x9d, 0xb9, 0x7d, + 0xcd, 0xa5, 0xe9, 0x95, 0x91, 0x09, 0x4b, 0x93, 0x73, 0x09, 0x93, 0x3b, + 0xfb, 0x72, 0x0b, 0x6b, 0x2b, 0xe3, 0x30, 0xf6, 0xc6, 0x36, 0x04, 0x0c, + 0x8c, 0xa0, 0x90, 0x8a, 0xc9, 0x18, 0x0a, 0xca, 0x08, 0x0c, 0xa1, 0xa8, + 0x0a, 0xcb, 0x18, 0x8a, 0xcb, 0x18, 0x0a, 0xa7, 0x78, 0x0a, 0xac, 0xc8, + 0x86, 0x08, 0x85, 0x36, 0xc4, 0x20, 0x80, 0x22, 0x2a, 0x36, 0x3e, 0x6f, + 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, 0x20, 0x63, 0x68, + 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, 0xe0, 0xd8, 0xca, 0x40, 0x86, 0x56, + 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, 0x86, 0x08, 0x85, 0x37, 0xc4, 0x28, + 0xba, 0xe2, 0x3b, 0x8a, 0x21, 0x46, 0x01, 0x06, 0x05, 0x18, 0x1c, 0xc5, + 0x08, 0x85, 0x1d, 0xd8, 0xc1, 0x1e, 0xda, 0xc1, 0x0d, 0xd2, 0x81, 0x1c, + 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0x10, 0x8c, 0x58, 0xc2, 0x21, 0x1d, + 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x61, 0x1e, 0xd2, 0xe1, 0x1d, + 0xdc, 0x61, 0x4a, 0x20, 0x8c, 0xa0, 0xc2, 0x21, 0x1d, 0xe4, 0xc1, 0x0d, + 0xd8, 0x21, 0x1c, 0xdc, 0xe1, 0x1c, 0xea, 0x21, 0x1c, 0xce, 0xa1, 0x1c, + 0x7e, 0xc1, 0x1e, 0xca, 0x41, 0x1e, 0xe6, 0x21, 0x1d, 0xde, 0xc1, 0x1d, + 0xa6, 0x04, 0xc4, 0x88, 0x29, 0x1c, 0xd2, 0x41, 0x1e, 0xdc, 0x60, 0x1c, + 0xde, 0xa1, 0x1d, 0xe0, 0x21, 0x1d, 0xd8, 0xa1, 0x1c, 0x7e, 0xe1, 0x1d, + 0xe0, 0x81, 0x1e, 0xd2, 0xe1, 0x1d, 0xdc, 0x61, 0x1e, 0xa6, 0x10, 0x06, + 0xa2, 0x30, 0x23, 0x98, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x73, 0x90, + 0x87, 0x70, 0x38, 0x87, 0x76, 0x28, 0x07, 0x77, 0xa0, 0x87, 0x29, 0x01, + 0x07, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, + 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, + 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, + 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, + 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, + 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, + 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, + 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, + 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, + 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, + 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, + 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, + 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, + 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, + 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x20, 0xb1, 0x5d, 0xf9, 0xb3, 0xce, 0x82, + 0x0c, 0x7f, 0x11, 0x01, 0x06, 0x43, 0x34, 0x13, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x04, 0x01, 0x05, + 0x25, 0x83, 0x80, 0x18, 0x02, 0x00, 0x00, 0x00, 0x5b, 0x06, 0x20, 0x08, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x60, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x95, 0x02, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, + 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, + 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, + 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, + 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, + 0x89, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, 0x16, 0xa0, 0xda, 0x60, + 0x08, 0x05, 0xb0, 0x00, 0xd5, 0x06, 0x73, 0x19, 0xfe, 0xff, 0xff, 0xff, + 0x7f, 0x00, 0x18, 0x40, 0x02, 0x2a, 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, + 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xd8, 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, + 0xa1, 0x1e, 0xdc, 0x81, 0x1c, 0xca, 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, + 0xc1, 0x1e, 0xd2, 0x81, 0x1c, 0xca, 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, + 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, + 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, + 0x72, 0x48, 0x87, 0x79, 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, + 0x7a, 0x08, 0x87, 0x74, 0x60, 0x87, 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x98, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, + 0x82, 0x1d, 0xca, 0x61, 0x1e, 0xe6, 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, + 0x61, 0x1c, 0xd2, 0x61, 0x1e, 0xca, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, + 0x21, 0x1c, 0xc8, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, + 0x77, 0x78, 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, + 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, + 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, + 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, + 0xa1, 0x1d, 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, + 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, + 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, + 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, + 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, + 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, + 0x36, 0x50, 0x87, 0x7a, 0x68, 0x07, 0x78, 0x68, 0x03, 0x7a, 0x08, 0x07, + 0x71, 0x60, 0x87, 0x72, 0x98, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, + 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xdc, 0x21, 0x1c, 0xdc, + 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, + 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, 0x70, 0x87, + 0x77, 0x68, 0x83, 0x79, 0x48, 0x87, 0x73, 0x70, 0x87, 0x72, 0x20, 0x87, + 0x36, 0xd0, 0x87, 0x72, 0x90, 0x87, 0x77, 0x98, 0x87, 0x36, 0x30, 0x07, + 0x78, 0x68, 0x83, 0x76, 0x08, 0x07, 0x7a, 0x40, 0x07, 0xc0, 0x1c, 0xc2, + 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x62, 0x1e, 0xe8, 0x21, 0x1c, 0xc6, + 0x61, 0x1d, 0xda, 0x00, 0x1e, 0xe4, 0xe1, 0x1d, 0xe8, 0xa1, 0x1c, 0xc6, + 0x81, 0x1e, 0xde, 0x41, 0x1e, 0xda, 0x40, 0x1c, 0xea, 0xc1, 0x1c, 0xcc, + 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xf4, 0xa1, 0x1c, 0x00, + 0x3c, 0x00, 0x08, 0x7a, 0x08, 0x07, 0x79, 0x38, 0x87, 0x72, 0xa0, 0x87, + 0x36, 0x30, 0x87, 0x72, 0x08, 0x07, 0x7a, 0xa8, 0x07, 0x79, 0x28, 0x87, + 0x79, 0x00, 0xda, 0xc0, 0x1c, 0xe0, 0x21, 0x0e, 0xec, 0x00, 0x20, 0xea, + 0xc1, 0x1d, 0xe6, 0x21, 0x1c, 0xcc, 0xa1, 0x1c, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, + 0x7a, 0x28, 0x07, 0x80, 0xa8, 0x87, 0x79, 0x28, 0x87, 0x36, 0x98, 0x87, + 0x77, 0x30, 0x07, 0x7a, 0x68, 0x03, 0x73, 0x60, 0x87, 0x77, 0x08, 0x07, + 0x7a, 0x00, 0xcc, 0x21, 0x1c, 0xd8, 0x61, 0x1e, 0xca, 0x01, 0xd8, 0x40, + 0x10, 0x01, 0xb0, 0x6c, 0x20, 0x0a, 0x01, 0x58, 0x36, 0x20, 0xc6, 0xff, + 0xff, 0xff, 0xff, 0x0f, 0x00, 0x03, 0x48, 0x40, 0x05, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x13, 0x86, 0x40, 0x18, + 0x26, 0x0c, 0x44, 0x61, 0x00, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, + 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x48, 0x33, 0x00, + 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, 0x08, 0x81, 0x70, 0x94, + 0x34, 0x45, 0x94, 0x30, 0xf9, 0xff, 0x44, 0x5c, 0x13, 0x15, 0x11, 0xbf, + 0x3d, 0xfc, 0xd3, 0x18, 0x01, 0x30, 0x88, 0x40, 0x04, 0x17, 0x49, 0x53, + 0x44, 0x09, 0x93, 0xff, 0x4b, 0x00, 0xf3, 0x2c, 0x44, 0xf4, 0x4f, 0x63, + 0x04, 0xc0, 0x20, 0x82, 0x21, 0x14, 0x23, 0x04, 0x31, 0xca, 0x21, 0x34, + 0x47, 0x10, 0xcc, 0x11, 0x80, 0xc1, 0x30, 0x82, 0xb0, 0x14, 0x24, 0x94, + 0x23, 0x14, 0x53, 0x80, 0xda, 0x40, 0xc0, 0x1c, 0x01, 0x28, 0x8c, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x74, 0x78, 0x87, 0x79, 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, + 0x0d, 0xef, 0x51, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, + 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, + 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xe9, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, + 0x06, 0xf6, 0x40, 0x07, 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xf6, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, + 0x07, 0x72, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, + 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, + 0x07, 0x75, 0x10, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, + 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, + 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, + 0x06, 0xee, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x43, 0x98, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x21, 0x8c, 0x03, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x16, + 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x5a, + 0x25, 0x30, 0x02, 0x50, 0x20, 0x05, 0x51, 0x04, 0x65, 0x50, 0x08, 0x04, + 0x47, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0xf0, 0x00, 0x43, 0x8c, 0x45, 0x58, 0x8a, 0x65, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0x79, 0x86, 0x45, 0x58, 0x84, 0x65, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x78, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x84, 0xe7, 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x95, 0xb9, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x9e, 0x84, 0x61, 0x10, + 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, + 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, + 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x78, 0x16, + 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, + 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, + 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0x9e, 0x66, 0x19, + 0x1e, 0xe7, 0x79, 0x86, 0x08, 0x0f, 0x44, 0x26, 0x2c, 0x4d, 0xce, 0x05, + 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, 0x9c, + 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, 0x17, + 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, 0x34, + 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, + 0x86, 0x40, 0xcb, 0xf0, 0x48, 0xcf, 0xf4, 0x50, 0x8f, 0xf3, 0x3c, 0x4f, + 0xf5, 0x58, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, 0xda, + 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, 0x95, + 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, 0xe1, + 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, 0xf0, + 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, 0xa3, + 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, 0x84, + 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0xb4, 0x08, 0x0f, + 0xf6, 0x64, 0xcf, 0xf4, 0x68, 0x8f, 0xf3, 0x6c, 0x4f, 0xf5, 0x70, 0x54, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, 0x84, + 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, + 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, + 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, + 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, + 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, + 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, + 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, + 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, 0xb0, 0x18, 0x8f, 0xf7, 0x7c, + 0x0b, 0xf1, 0x80, 0xc1, 0x32, 0x2c, 0xc2, 0x13, 0x06, 0x8f, 0x18, 0x2c, + 0xc4, 0x33, 0x06, 0x0b, 0xf1, 0x38, 0xcf, 0xf3, 0x54, 0x0f, 0x19, 0x70, + 0x09, 0x4b, 0x93, 0x73, 0xa1, 0x2b, 0xc3, 0xa3, 0xab, 0x93, 0x2b, 0xa3, + 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, 0x46, 0x8c, + 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, 0x4c, 0x86, 0x8c, 0xc7, 0x8c, 0xed, + 0x2d, 0x8c, 0x8e, 0x05, 0x64, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0xcc, 0x87, + 0x03, 0x5d, 0x19, 0xde, 0x10, 0x6a, 0x39, 0x1e, 0x33, 0x78, 0xc0, 0x60, + 0x19, 0x16, 0xe1, 0x39, 0x83, 0xc7, 0x79, 0xd0, 0xe0, 0xa9, 0x9e, 0x34, + 0xe0, 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, 0x26, + 0xc7, 0x63, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, 0x10, + 0x69, 0x41, 0x9e, 0x35, 0x78, 0xc0, 0x60, 0x19, 0x16, 0xe1, 0x71, 0x1e, + 0x36, 0x78, 0xaa, 0xa7, 0x0d, 0x86, 0x28, 0xcf, 0xf5, 0x74, 0x4f, 0x19, + 0x3c, 0x6a, 0xf0, 0xb8, 0xc1, 0x10, 0x23, 0x01, 0x9e, 0xe8, 0x79, 0x03, + 0x3e, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, 0x20, + 0x63, 0x68, 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, 0xe0, 0xd8, 0xca, 0x40, + 0x86, 0x56, 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, 0x86, 0x08, 0x8f, 0x1c, + 0x0c, 0x31, 0x9e, 0x38, 0x78, 0xe6, 0x00, 0x4a, 0x86, 0x18, 0x0f, 0x1d, + 0x3c, 0x74, 0x00, 0x25, 0x23, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, + 0x37, 0x48, 0x07, 0x72, 0x28, 0x07, 0x77, 0xa0, 0x87, 0x29, 0x41, 0x30, + 0x62, 0x09, 0x87, 0x74, 0x90, 0x07, 0x37, 0xb0, 0x87, 0x72, 0x90, 0x87, + 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x81, 0x30, 0x82, 0x0a, 0x87, + 0x74, 0x90, 0x07, 0x37, 0x60, 0x87, 0x70, 0x70, 0x87, 0x73, 0xa8, 0x87, + 0x70, 0x38, 0x87, 0x72, 0xf8, 0x05, 0x7b, 0x28, 0x07, 0x79, 0x98, 0x87, + 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x10, 0x23, 0xa6, 0x70, 0x48, 0x07, + 0x79, 0x70, 0x83, 0x71, 0x78, 0x87, 0x76, 0x80, 0x87, 0x74, 0x60, 0x87, + 0x72, 0xf8, 0x85, 0x77, 0x80, 0x07, 0x7a, 0x48, 0x87, 0x77, 0x70, 0x87, + 0x79, 0x98, 0x42, 0x18, 0x88, 0xc2, 0x8c, 0x60, 0xc2, 0x21, 0x1d, 0xe4, + 0xc1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xe1, 0x1c, 0xda, 0xa1, 0x1c, 0xdc, + 0x81, 0x1e, 0xa6, 0x04, 0x70, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, + 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, + 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, + 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, + 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, + 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, + 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, + 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, + 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x10, 0xb1, 0x5d, + 0xf9, 0x73, 0xce, 0x83, 0xfd, 0x45, 0x04, 0x18, 0x0c, 0xd1, 0x4c, 0x16, + 0xb0, 0x01, 0x48, 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, 0xd7, + 0x44, 0x45, 0xc4, 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x0d, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc4, 0x46, 0x00, 0x48, + 0xd5, 0xc0, 0x08, 0x00, 0x81, 0x11, 0x00, 0x00, 0x23, 0x06, 0x8a, 0x10, + 0x48, 0x46, 0x81, 0x0c, 0x84, 0x10, 0x10, 0x52, 0x2c, 0x10, 0xe4, 0x93, + 0x41, 0x40, 0x0c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x20, 0xa8, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x6c, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x98, 0x03, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, + 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, + 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, + 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, + 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, + 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, 0x16, 0xa0, 0xda, 0x60, + 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, 0x80, 0x05, 0xa8, 0x36, + 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0x00, 0x12, 0x31, + 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xec, 0x90, + 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, 0x40, 0x0e, 0xe5, 0x40, + 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, 0x40, 0x0e, 0xe5, 0xd0, + 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, 0x39, 0x84, 0x03, 0x3b, + 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, 0x3c, 0x84, 0x83, 0x38, + 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, 0x3a, 0xb0, 0x43, 0x1b, + 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, + 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, 0x30, 0x0f, 0xf3, 0xd0, + 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, 0x30, 0x0f, 0xe5, 0xd0, + 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, 0x00, 0xd0, 0x83, 0x3c, + 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, + 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, 0x3b, 0xa4, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, + 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, 0xe0, 0x0e, 0xef, 0xd0, + 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, 0xd0, 0x06, 0xf0, 0xf0, + 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xe5, 0xc0, + 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, 0xe0, 0x0e, 0x6d, 0xc0, + 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x90, + 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0x6d, 0xd0, + 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, + 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, 0x3d, 0xb4, 0x03, 0x3c, + 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xcc, 0x03, 0x60, + 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, + 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, + 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, 0x3c, 0xa4, 0xc3, 0x39, + 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, 0x39, 0xc8, 0xc3, 0x3b, + 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, + 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0x31, + 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, 0x00, 0x0f, 0xf2, 0xf0, + 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, 0x20, 0x0f, 0x6d, 0x20, + 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xf3, 0x90, + 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, 0x3d, 0x84, 0x83, 0x3c, + 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, 0x39, 0x84, 0x03, 0x3d, + 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, 0x60, 0x0e, 0xf0, 0x10, + 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, 0x10, 0x0e, 0xe6, 0x50, + 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, + 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xd4, 0xc3, 0x3c, + 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, 0x3d, 0xb4, 0x81, 0x39, + 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, 0x10, 0x0e, 0xec, 0x30, + 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xd8, + 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, 0xdc, 0x81, 0x1c, 0xca, + 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, 0xd2, 0x81, 0x1c, 0xca, + 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, 0x87, 0x79, 0x08, 0x07, + 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, 0x87, 0x74, 0x60, 0x87, + 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, 0x07, 0xc0, 0x1c, 0xc2, + 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, 0xca, 0x61, 0x1e, 0xe6, + 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xd2, 0x61, 0x1e, 0xca, + 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, 0xc8, 0x01, 0xa0, 0x07, + 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x30, 0x07, + 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, + 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, + 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, + 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, 0xca, 0xa1, 0x0d, 0xe0, + 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, + 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, + 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, + 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, + 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, + 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, 0x87, 0x70, 0x70, 0x87, + 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, + 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, + 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, 0xda, + 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, 0x87, 0x70, 0x18, 0x87, + 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, 0x87, 0x72, 0x18, 0x07, + 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, 0x07, 0x73, 0x30, 0x87, + 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, 0x87, 0x72, 0x00, 0xf0, + 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, 0xca, 0x81, 0x1e, 0xda, + 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, 0xe4, 0xa1, 0x1c, 0xe6, + 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, 0x03, 0x80, 0xa8, 0x07, + 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, 0x03, 0x73, 0x80, 0x87, + 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, + 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xde, + 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, 0xde, 0x21, 0x1c, 0xe8, + 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, 0x07, 0x60, 0x03, 0x61, + 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, 0x80, 0x20, 0xff, 0xff, + 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, 0x06, 0x22, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, 0x88, 0x09, 0x41, 0x31, + 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, + 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x78, 0x33, 0x00, + 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, 0x08, 0x81, 0x30, 0x8c, + 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, 0x2f, 0xbb, 0x6f, 0x47, + 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, 0x11, 0x0a, 0xe1, 0x28, + 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, 0x26, 0x2a, 0x22, 0x7e, + 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, 0x08, 0x4e, 0x93, 0xa6, + 0x88, 0x12, 0x26, 0xff, 0x9f, 0x88, 0x6b, 0xa2, 0x22, 0xe2, 0xb7, 0x87, + 0x1f, 0x88, 0x22, 0x00, 0xfb, 0xa7, 0x31, 0x02, 0x60, 0x10, 0x21, 0x09, + 0x2e, 0x92, 0xa6, 0x88, 0x12, 0x26, 0xff, 0x97, 0x00, 0xe6, 0x59, 0x88, + 0xe8, 0x9f, 0xc6, 0x08, 0x80, 0x41, 0x84, 0x45, 0x28, 0x48, 0x08, 0x62, + 0x18, 0xa4, 0x18, 0xb5, 0x32, 0x00, 0x42, 0xe8, 0xcd, 0x11, 0x80, 0xc1, + 0x1c, 0x41, 0x30, 0x8c, 0x20, 0x44, 0x25, 0x09, 0x8a, 0x89, 0x28, 0xa7, + 0x04, 0x44, 0x0b, 0x12, 0x10, 0x13, 0x72, 0x4a, 0x40, 0x76, 0x20, 0x60, + 0x18, 0x61, 0x88, 0x86, 0x11, 0x88, 0x68, 0x8e, 0x00, 0x14, 0x06, 0x11, + 0x08, 0x61, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa8, 0x70, 0x48, + 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, + 0x87, 0x72, 0x68, 0x83, 0x74, 0x78, 0x87, 0x79, 0xc8, 0x03, 0x37, 0x80, + 0x03, 0x37, 0x80, 0x83, 0x0d, 0xef, 0x51, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, + 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, + 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, + 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xf6, + 0x20, 0x07, 0x74, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0xd0, 0x06, 0xf6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x40, 0x07, 0x78, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, 0x60, 0x07, 0x74, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xf6, + 0x90, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, + 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0x60, 0x0f, 0x71, 0x90, 0x07, 0x72, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, + 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, + 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xd0, 0x06, 0xf6, + 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xd0, 0x06, 0xe6, + 0x80, 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, + 0x20, 0x07, 0x78, 0xd0, 0x06, 0xee, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x43, 0x18, 0x07, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x21, 0x0c, 0x04, 0x04, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x10, 0xa6, 0x02, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x08, 0x73, 0x01, 0x01, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x90, 0x05, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x8a, + 0x23, 0x00, 0x25, 0x50, 0x20, 0x05, 0x18, 0x50, 0x10, 0x45, 0x50, 0x06, + 0x05, 0x54, 0x60, 0x85, 0x50, 0x0a, 0xc5, 0x40, 0x7b, 0x04, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x15, 0x01, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, + 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, + 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, + 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, + 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x80, 0x01, + 0x43, 0x8c, 0xa8, 0x88, 0x90, 0x88, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, + 0x36, 0x04, 0xc1, 0x86, 0xa8, 0x88, 0x8a, 0x88, 0xe0, 0x16, 0x96, 0x26, + 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, + 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0xc0, 0x0a, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, + 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x04, 0xec, + 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, + 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, + 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, 0x95, 0xb9, 0x85, 0x89, + 0xb1, 0x95, 0x0d, 0x11, 0xb0, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, 0x32, + 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, 0x66, + 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xc0, 0x16, 0x46, 0x61, 0x69, 0x72, + 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, + 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, + 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0xb0, 0x26, 0x22, 0x30, 0x07, 0x7b, 0x86, + 0x08, 0x18, 0x44, 0x26, 0x2c, 0x4d, 0xce, 0x05, 0xee, 0x6d, 0x2e, 0x8d, + 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x58, 0x99, 0x1b, + 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, 0x17, 0xb7, 0xb7, 0x2f, 0xb8, + 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, 0x34, 0xbb, 0x32, 0x32, 0x61, + 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x44, + 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, 0x86, 0x40, 0x11, 0x81, + 0x49, 0xd8, 0x84, 0x51, 0x98, 0x83, 0x3d, 0x58, 0x85, 0x59, 0x94, 0xc2, + 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, 0xda, 0xca, 0xdc, 0xe8, 0xbe, + 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, 0x95, 0xb9, 0x95, 0xc9, 0x85, + 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, 0xe1, 0x8d, 0xbd, 0xbd, 0xc9, + 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, 0xf0, 0x09, 0x4b, 0x93, 0x73, + 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, 0xa3, 0x4b, 0xb3, 0x2b, 0xa3, + 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, 0x84, 0xae, 0x0c, 0x6f, 0xec, + 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0x14, 0x15, 0x18, 0x86, 0x65, 0xd8, 0x84, + 0x69, 0x98, 0x83, 0x6d, 0x58, 0x85, 0x71, 0x54, 0xc2, 0xd2, 0xe4, 0x5c, + 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, 0x84, 0xa5, 0xc9, 0xb9, 0x88, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, 0xe9, 0x95, 0x51, 0x0a, + 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, 0x4b, 0x7b, 0x73, 0xfb, + 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, 0x26, 0xe7, 0x22, 0x57, + 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, 0x4c, 0xee, 0xec, 0x8b, + 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, 0x8c, 0x57, 0x58, 0x9a, + 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, 0x5c, 0xd9, 0x57, 0x18, + 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0x87, 0xb1, 0x37, + 0xb6, 0x21, 0x60, 0x10, 0x25, 0x98, 0x87, 0x7d, 0x91, 0x81, 0x81, 0x41, + 0x44, 0x44, 0x05, 0x16, 0x06, 0x98, 0x18, 0x44, 0x06, 0x36, 0x06, 0x91, + 0x81, 0x39, 0xd8, 0x83, 0x55, 0x18, 0x19, 0x90, 0x0a, 0x4b, 0x93, 0x73, + 0x99, 0xa3, 0x93, 0xab, 0x1b, 0xa3, 0xfb, 0xa2, 0xcb, 0x83, 0x2b, 0xfb, + 0x4a, 0x73, 0x33, 0x7b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x37, 0x43, + 0xe3, 0xcd, 0xcc, 0x6c, 0xae, 0x8c, 0x8e, 0x86, 0xd4, 0xd8, 0x5b, 0x99, + 0x99, 0x19, 0x8d, 0xa3, 0xb1, 0xb7, 0x32, 0x33, 0x33, 0x1a, 0x42, 0x63, + 0x6f, 0x65, 0x66, 0x66, 0x43, 0xd0, 0x20, 0x22, 0x22, 0x23, 0x22, 0xb0, + 0x33, 0xc0, 0xd0, 0x20, 0x32, 0x22, 0x23, 0x22, 0xb0, 0x33, 0xc0, 0xd2, + 0x20, 0x5a, 0x22, 0x23, 0x22, 0xb0, 0x33, 0xc0, 0xd4, 0x20, 0x62, 0x22, + 0x23, 0x22, 0xb0, 0x33, 0xc0, 0xd6, 0x80, 0x49, 0x56, 0x95, 0x15, 0x51, + 0xd9, 0xd8, 0x1b, 0x59, 0x19, 0x0d, 0xb2, 0xb2, 0xb1, 0x37, 0xb2, 0xb2, + 0x21, 0x64, 0x10, 0x29, 0x98, 0x87, 0x7d, 0xd1, 0x81, 0x81, 0x41, 0x54, + 0x44, 0x05, 0x16, 0x06, 0x98, 0x19, 0x60, 0x6c, 0x80, 0x89, 0x41, 0x74, + 0x60, 0x63, 0x10, 0x19, 0x98, 0x83, 0xb5, 0x01, 0x56, 0x61, 0x6e, 0xc0, + 0x25, 0x2c, 0x4d, 0xce, 0x85, 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, 0x8c, + 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x19, 0x31, + 0xba, 0x32, 0x3c, 0xba, 0x3a, 0xb9, 0x32, 0x19, 0x32, 0x1e, 0x33, 0xb6, + 0xb7, 0x30, 0x3a, 0x16, 0x90, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, 0x1f, + 0x12, 0x74, 0x65, 0x78, 0x59, 0x43, 0xa8, 0xa8, 0xc1, 0xe0, 0x00, 0x03, + 0x83, 0x88, 0x88, 0x0a, 0x2c, 0x0e, 0x30, 0x07, 0x93, 0x03, 0xac, 0xc2, + 0xe6, 0x80, 0x1e, 0x5d, 0x19, 0x1e, 0x5d, 0x9d, 0x5c, 0x99, 0x0c, 0xd9, + 0x57, 0x98, 0x9c, 0x5c, 0x58, 0x1e, 0x8f, 0x19, 0xdb, 0x5b, 0x18, 0x1d, + 0x0b, 0xc8, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x99, 0x0f, 0x0b, 0xba, 0x32, + 0xbc, 0x2a, 0xab, 0x21, 0x54, 0xe4, 0x60, 0x70, 0x80, 0x81, 0x41, 0x54, + 0x44, 0x05, 0x16, 0x07, 0x98, 0x83, 0xd5, 0x01, 0x56, 0x61, 0x76, 0xc0, + 0x25, 0x2c, 0x4d, 0xce, 0x65, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, 0x8e, + 0xc7, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x99, 0x1c, 0x83, 0xb9, 0x21, 0x52, + 0xf4, 0x60, 0x78, 0x80, 0x81, 0x41, 0x44, 0x44, 0x05, 0xe6, 0x60, 0x79, + 0x80, 0x55, 0x98, 0x1e, 0x0c, 0x71, 0xb0, 0x0b, 0xeb, 0xb0, 0x32, 0xc0, + 0xde, 0x00, 0xa3, 0x03, 0xec, 0x0e, 0xb0, 0x3d, 0x18, 0x62, 0x38, 0x00, + 0x16, 0x61, 0x7c, 0xc0, 0xe7, 0xad, 0xcd, 0x2d, 0x0d, 0xee, 0x8d, 0xae, + 0xcc, 0x8d, 0x0e, 0x64, 0x0c, 0x2d, 0x4c, 0x8e, 0xcf, 0x54, 0x5a, 0x1b, + 0x1c, 0x5b, 0x19, 0xc8, 0xd0, 0xca, 0x0a, 0x08, 0x95, 0x50, 0x50, 0xd0, + 0x10, 0x01, 0xfb, 0x83, 0x21, 0x06, 0xe6, 0x07, 0x18, 0x28, 0x6c, 0xd0, + 0x10, 0x03, 0x0b, 0x05, 0x2c, 0x14, 0x36, 0x68, 0x84, 0xc2, 0x0e, 0xec, + 0x60, 0x0f, 0xed, 0xe0, 0x06, 0xe9, 0x40, 0x0e, 0xe5, 0xe0, 0x0e, 0xf4, + 0x30, 0x25, 0x08, 0x46, 0x2c, 0xe1, 0x90, 0x0e, 0xf2, 0xe0, 0x06, 0xf6, + 0x50, 0x0e, 0xf2, 0x30, 0x0f, 0xe9, 0xf0, 0x0e, 0xee, 0x30, 0x25, 0x10, + 0x46, 0x50, 0xe1, 0x90, 0x0e, 0xf2, 0xe0, 0x06, 0xec, 0x10, 0x0e, 0xee, + 0x70, 0x0e, 0xf5, 0x10, 0x0e, 0xe7, 0x50, 0x0e, 0xbf, 0x60, 0x0f, 0xe5, + 0x20, 0x0f, 0xf3, 0x90, 0x0e, 0xef, 0xe0, 0x0e, 0x53, 0x02, 0x62, 0xc4, + 0x14, 0x0e, 0xe9, 0x20, 0x0f, 0x6e, 0x30, 0x0e, 0xef, 0xd0, 0x0e, 0xf0, + 0x90, 0x0e, 0xec, 0x50, 0x0e, 0xbf, 0xf0, 0x0e, 0xf0, 0x40, 0x0f, 0xe9, + 0xf0, 0x0e, 0xee, 0x30, 0x0f, 0x53, 0x08, 0x03, 0x51, 0x98, 0x11, 0x4c, + 0x38, 0xa4, 0x83, 0x3c, 0xb8, 0x81, 0x39, 0xc8, 0x43, 0x38, 0x9c, 0x43, + 0x3b, 0x94, 0x83, 0x3b, 0xd0, 0xc3, 0x94, 0xa0, 0x0f, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, + 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, + 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, + 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, + 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, + 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, + 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, + 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, + 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, + 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x26, 0x10, 0x06, 0x00, 0x12, 0xf9, 0x12, 0xc0, 0x3c, 0x0b, 0xf1, 0x4f, + 0xc4, 0x35, 0x51, 0x11, 0xf1, 0xdb, 0xc3, 0x0f, 0x44, 0x11, 0x80, 0xf9, + 0x15, 0x5e, 0xdc, 0xb6, 0x05, 0x34, 0x00, 0x12, 0xf9, 0x83, 0x33, 0xf9, + 0xd5, 0x5d, 0xdc, 0xb6, 0x0d, 0x6c, 0x00, 0x12, 0xf9, 0x12, 0xc0, 0x3c, + 0x0b, 0xf1, 0x4f, 0xc4, 0x35, 0x51, 0x11, 0xf1, 0xdb, 0x83, 0x5f, 0xe1, + 0xc5, 0x6d, 0x1b, 0x00, 0xc4, 0x76, 0xe5, 0x2f, 0xbb, 0xef, 0x5f, 0x44, + 0x80, 0xc1, 0x10, 0xcd, 0x04, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa4, 0xe7, 0x20, 0x88, 0x22, 0xe1, 0x28, 0xcf, + 0x31, 0x10, 0x1c, 0x37, 0xd6, 0x00, 0x04, 0x02, 0xcd, 0x11, 0x00, 0x8a, + 0x33, 0x00, 0x24, 0x6b, 0x60, 0x04, 0x80, 0xc8, 0x0c, 0x00, 0x85, 0x19, + 0x00, 0x02, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf8, 0x37, 0x02, 0x00, 0x00, + 0x23, 0x06, 0xca, 0x10, 0x80, 0x81, 0xc3, 0x44, 0x06, 0x52, 0x04, 0x23, + 0x06, 0xcb, 0x10, 0x88, 0x81, 0xd3, 0x48, 0x60, 0x70, 0x24, 0x86, 0x30, + 0x86, 0x10, 0x84, 0xc1, 0x20, 0xc3, 0x60, 0x34, 0x73, 0x0c, 0x81, 0x20, + 0x06, 0x23, 0x06, 0xcb, 0x10, 0x98, 0x81, 0x14, 0x59, 0x63, 0xb0, 0x34, + 0x8a, 0x31, 0x86, 0x10, 0x94, 0xc1, 0x1c, 0xc3, 0x10, 0x84, 0xc1, 0x20, + 0x43, 0xc0, 0x4c, 0x87, 0x8d, 0xa5, 0xa0, 0xd8, 0x10, 0xc0, 0x87, 0xb8, + 0x32, 0xc8, 0x20, 0x40, 0xd6, 0x78, 0x43, 0x17, 0x06, 0x6c, 0x70, 0xc1, + 0x58, 0x0a, 0xca, 0x20, 0x43, 0x40, 0x69, 0x23, 0x06, 0x05, 0x11, 0xd0, + 0x41, 0x11, 0xcc, 0x31, 0x58, 0x81, 0x1c, 0x8c, 0x37, 0x8c, 0xc1, 0x19, + 0xb8, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, 0x81, 0x06, 0x06, 0x23, + 0x06, 0x05, 0x11, 0xe8, 0xc1, 0x12, 0xcc, 0x31, 0x18, 0xc1, 0x1d, 0x8c, + 0x37, 0xa4, 0x41, 0x1b, 0xcc, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, + 0x01, 0x18, 0x98, 0xc1, 0x88, 0x41, 0x41, 0x04, 0xa0, 0x10, 0x05, 0x73, + 0x0c, 0x46, 0x90, 0x07, 0x73, 0x0c, 0x81, 0x18, 0xe4, 0x81, 0x05, 0x95, + 0x7c, 0x32, 0x08, 0x88, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x5b, 0x06, 0x26, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf0, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x79, 0x03, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, + 0x80, 0x05, 0xa8, 0x36, 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xc0, 0x00, 0x12, 0x31, 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, + 0x40, 0x0f, 0xec, 0x90, 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, + 0x40, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, + 0x40, 0x0e, 0xe5, 0xd0, 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, + 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, + 0x3c, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, + 0x3a, 0xb0, 0x43, 0x1b, 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, + 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, + 0x30, 0x0f, 0xf3, 0xd0, 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, + 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, + 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, + 0x3b, 0xa4, 0x43, 0x3b, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, + 0xe0, 0x0e, 0xef, 0xd0, 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, + 0xd0, 0x06, 0xf0, 0xf0, 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xe5, 0xc0, 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, + 0xe0, 0x0e, 0x6d, 0xc0, 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, + 0xf0, 0x0e, 0x6d, 0x90, 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, + 0x00, 0x0f, 0x6d, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, + 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, + 0x3d, 0xb4, 0x03, 0x3c, 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, + 0x39, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, + 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, + 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, + 0x3c, 0xa4, 0xc3, 0x39, 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, + 0x39, 0xc8, 0xc3, 0x3b, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, + 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, + 0x00, 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, + 0x20, 0x0f, 0x6d, 0x20, 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, + 0x3d, 0x84, 0x83, 0x3c, 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, + 0x39, 0x84, 0x03, 0x3d, 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, + 0x60, 0x0e, 0xf0, 0x10, 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, + 0x10, 0x0e, 0xe6, 0x50, 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, + 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, + 0x40, 0xd4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, + 0x3d, 0xb4, 0x81, 0x39, 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, + 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, + 0xff, 0xff, 0xff, 0x07, 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, + 0xc6, 0x81, 0x1e, 0xd8, 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, + 0xdc, 0x81, 0x1c, 0xca, 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, + 0xd2, 0x81, 0x1c, 0xca, 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, + 0x87, 0x79, 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, + 0x87, 0x74, 0x60, 0x87, 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, + 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, + 0xca, 0x61, 0x1e, 0xe6, 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, + 0xd2, 0x61, 0x1e, 0xca, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, + 0xc8, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, + 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, + 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, + 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, + 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, + 0xe4, 0xa1, 0x0d, 0xca, 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, + 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, + 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, + 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, + 0x87, 0x70, 0x70, 0x87, 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, + 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, + 0xca, 0x81, 0x1c, 0xda, 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, + 0x87, 0x70, 0x18, 0x87, 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, + 0x87, 0x72, 0x18, 0x07, 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, + 0x07, 0x73, 0x30, 0x87, 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, + 0x87, 0x72, 0x00, 0xf0, 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, + 0xca, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, + 0xe4, 0xa1, 0x1c, 0xe6, 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, + 0x03, 0x80, 0xa8, 0x07, 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, + 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, + 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, + 0xda, 0x60, 0x1e, 0xde, 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, + 0xde, 0x21, 0x1c, 0xe8, 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, + 0x07, 0x60, 0x03, 0x61, 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, + 0x80, 0x20, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, + 0x06, 0x22, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, + 0x88, 0x09, 0x41, 0x31, 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x68, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, + 0x08, 0x81, 0x30, 0x8c, 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, + 0x2f, 0xbb, 0x6f, 0x47, 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, + 0x11, 0x0a, 0xe1, 0x28, 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, + 0x26, 0x2a, 0x22, 0x7e, 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, + 0x08, 0x2e, 0x92, 0xa6, 0x88, 0x12, 0x26, 0xff, 0x97, 0x00, 0xe6, 0x59, + 0x88, 0xe8, 0x9f, 0xc6, 0x08, 0x80, 0x41, 0x84, 0x44, 0x28, 0x48, 0x08, + 0x62, 0x18, 0x84, 0x14, 0xad, 0x32, 0x00, 0x42, 0xa8, 0xcd, 0x11, 0x04, + 0x73, 0x04, 0x60, 0x30, 0x8c, 0x20, 0x40, 0x05, 0x09, 0x48, 0x89, 0x17, + 0x1f, 0x20, 0x39, 0x10, 0x30, 0x8c, 0x30, 0x40, 0xc3, 0x08, 0x04, 0x34, + 0x47, 0x00, 0x0a, 0x83, 0x08, 0x84, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, + 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, 0x74, 0x78, 0x87, 0x79, + 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, 0x0d, 0xef, 0x51, 0x0e, + 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x7a, 0x80, 0x07, + 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x78, 0xa0, 0x07, + 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, + 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, + 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, 0x07, + 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, + 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, + 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x40, 0x07, + 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, + 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x20, 0x07, + 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, 0x07, 0x72, 0xa0, 0x07, + 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, + 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, + 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x75, 0x10, 0x07, + 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, + 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, + 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, + 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, + 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xee, 0x80, 0x07, + 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x43, 0x18, 0x06, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x21, 0x8c, 0x03, 0x04, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x10, 0x66, 0x02, 0x02, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0b, 0x04, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, + 0xc6, 0x04, 0x43, 0x82, 0x23, 0x00, 0x25, 0x50, 0x20, 0x05, 0x18, 0x50, + 0x10, 0x45, 0x50, 0x06, 0x05, 0x54, 0x60, 0x85, 0x50, 0x0a, 0xc5, 0x40, + 0x77, 0x04, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x0d, 0x01, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0x40, 0x01, 0x43, 0x0c, 0x88, 0x80, 0x0e, 0x68, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0xa1, 0x06, 0x88, 0x80, 0x08, 0x68, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x04, 0xea, 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x95, 0xb9, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0xa8, 0x84, 0x61, 0x10, + 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, + 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, + 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x16, + 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, + 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, + 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0xa8, 0x06, 0x1a, + 0x28, 0x87, 0x7a, 0x86, 0x08, 0x14, 0x44, 0x26, 0x2c, 0x4d, 0xce, 0x05, + 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, 0x9c, + 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, 0x17, + 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, 0x34, + 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, + 0x86, 0x40, 0xd0, 0x40, 0x49, 0xd4, 0x44, 0x51, 0x94, 0x43, 0x3d, 0x54, + 0x45, 0x59, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, 0xda, + 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, 0x95, + 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, 0xe1, + 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, 0xf0, + 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, 0xa3, + 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, 0x84, + 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0x04, 0x11, 0x14, + 0x46, 0x65, 0xd4, 0x44, 0x69, 0x94, 0x43, 0x6d, 0x54, 0x45, 0x71, 0x54, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, 0x84, + 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, + 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, + 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, + 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, + 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, + 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, + 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, + 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, 0x00, 0x21, 0x94, 0x47, 0x7d, + 0x50, 0x41, 0x81, 0x01, 0x34, 0x40, 0x04, 0x15, 0x06, 0x94, 0x18, 0x40, + 0x05, 0x35, 0x06, 0x50, 0x41, 0x39, 0xd4, 0x43, 0x55, 0x14, 0x19, 0x90, + 0x0a, 0x4b, 0x93, 0x73, 0x99, 0xa3, 0x93, 0xab, 0x1b, 0xa3, 0xfb, 0xa2, + 0xcb, 0x83, 0x2b, 0xfb, 0x4a, 0x73, 0x33, 0x7b, 0xa3, 0x61, 0xc6, 0xf6, + 0x16, 0x46, 0x37, 0x43, 0xe3, 0xcd, 0xcc, 0x6c, 0xae, 0x8c, 0x8e, 0x86, + 0xd4, 0xd8, 0x5b, 0x99, 0x99, 0x19, 0x8d, 0xa3, 0xb1, 0xb7, 0x32, 0x33, + 0x33, 0x1a, 0x42, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x43, 0xd0, 0x00, 0x1a, + 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd0, 0x00, 0x2a, 0xa0, 0x02, 0x1a, + 0xa8, 0x33, 0xa0, 0xd2, 0x00, 0x52, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, + 0xd4, 0x00, 0x5a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd6, 0x80, 0x49, + 0x56, 0x95, 0x15, 0x51, 0xd9, 0xd8, 0x1b, 0x59, 0x19, 0x0d, 0xb2, 0xb2, + 0xb1, 0x37, 0xb2, 0xb2, 0x21, 0x64, 0x00, 0x25, 0x94, 0x47, 0x7d, 0x90, + 0x41, 0x81, 0x01, 0x44, 0x40, 0x04, 0x15, 0x06, 0x94, 0x19, 0x50, 0x6c, + 0x40, 0x89, 0x01, 0x64, 0x50, 0x63, 0x00, 0x15, 0x94, 0x43, 0xb5, 0x01, + 0x55, 0x51, 0x6e, 0xc0, 0x25, 0x2c, 0x4d, 0xce, 0x85, 0xae, 0x0c, 0x8f, + 0xae, 0x4e, 0xae, 0x8c, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x5c, 0x58, 0x1b, + 0x1c, 0x5b, 0x19, 0x31, 0xba, 0x32, 0x3c, 0xba, 0x3a, 0xb9, 0x32, 0x19, + 0x32, 0x1e, 0x33, 0xb6, 0xb7, 0x30, 0x3a, 0x16, 0x90, 0xb9, 0xb0, 0x36, + 0x38, 0xb6, 0x32, 0x1f, 0x12, 0x74, 0x65, 0x78, 0x59, 0x43, 0x28, 0x88, + 0xa1, 0xe0, 0x80, 0x02, 0x03, 0x68, 0x80, 0x08, 0x2a, 0x0e, 0x28, 0x87, + 0x92, 0x03, 0xaa, 0xa2, 0xe6, 0x80, 0x05, 0x5d, 0x19, 0x5e, 0x95, 0xd5, + 0x10, 0x0a, 0x6a, 0x28, 0x38, 0xa0, 0xc0, 0x00, 0x22, 0x20, 0x82, 0x8a, + 0x03, 0xca, 0xa1, 0xe4, 0x80, 0xaa, 0xa8, 0x3a, 0xe0, 0x12, 0x96, 0x26, + 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, 0x26, 0xc7, 0x63, 0x2e, 0xac, + 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, 0x10, 0x09, 0x72, 0xa8, 0x3b, + 0xa0, 0xc0, 0x00, 0x1a, 0x20, 0x82, 0x72, 0x28, 0x3c, 0xa0, 0x2a, 0x2a, + 0x0f, 0x86, 0x38, 0xd4, 0x45, 0x75, 0x54, 0x19, 0x50, 0x6f, 0x40, 0xd1, + 0x01, 0x65, 0x07, 0x94, 0x1e, 0x0c, 0x31, 0x18, 0x80, 0x8a, 0xa8, 0x3d, + 0xe0, 0xf3, 0xd6, 0xe6, 0x96, 0x06, 0xf7, 0x46, 0x57, 0xe6, 0x46, 0x07, + 0x32, 0x86, 0x16, 0x26, 0xc7, 0x67, 0x2a, 0xad, 0x0d, 0x8e, 0xad, 0x0c, + 0x64, 0x68, 0x65, 0x05, 0x84, 0x4a, 0x28, 0x28, 0x68, 0x88, 0x40, 0xf9, + 0xc1, 0x10, 0x83, 0xea, 0x03, 0xea, 0x0f, 0xae, 0x67, 0x88, 0x41, 0x81, + 0x02, 0x05, 0x0a, 0xd7, 0x33, 0x42, 0x61, 0x07, 0x76, 0xb0, 0x87, 0x76, + 0x70, 0x83, 0x74, 0x20, 0x87, 0x72, 0x70, 0x07, 0x7a, 0x98, 0x12, 0x04, + 0x23, 0x96, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x7b, 0x28, 0x07, 0x79, + 0x98, 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x08, 0x23, 0xa8, 0x70, + 0x48, 0x07, 0x79, 0x70, 0x03, 0x76, 0x08, 0x07, 0x77, 0x38, 0x87, 0x7a, + 0x08, 0x87, 0x73, 0x28, 0x87, 0x5f, 0xb0, 0x87, 0x72, 0x90, 0x87, 0x79, + 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x01, 0x31, 0x62, 0x0a, 0x87, 0x74, + 0x90, 0x07, 0x37, 0x18, 0x87, 0x77, 0x68, 0x07, 0x78, 0x48, 0x07, 0x76, + 0x28, 0x87, 0x5f, 0x78, 0x07, 0x78, 0xa0, 0x87, 0x74, 0x78, 0x07, 0x77, + 0x98, 0x87, 0x29, 0x84, 0x81, 0x28, 0xcc, 0x08, 0x26, 0x1c, 0xd2, 0x41, + 0x1e, 0xdc, 0xc0, 0x1c, 0xe4, 0x21, 0x1c, 0xce, 0xa1, 0x1d, 0xca, 0xc1, + 0x1d, 0xe8, 0x61, 0x4a, 0xc0, 0x07, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, + 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, + 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, + 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, + 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, + 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, + 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, + 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, + 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x16, 0xd0, 0x00, 0x48, + 0xe4, 0x0f, 0xce, 0xe4, 0x57, 0x77, 0x71, 0xdb, 0x26, 0xb0, 0x01, 0x48, + 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, 0xd7, 0x44, 0x45, 0xc4, + 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x6d, 0x00, 0x11, 0xdb, 0x95, 0xff, + 0xf9, 0xd6, 0xf6, 0x5f, 0x44, 0x80, 0xc1, 0x10, 0xcd, 0x04, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x64, 0xe7, 0x20, 0x06, + 0x02, 0xe9, 0xa8, 0x8e, 0x35, 0x00, 0x03, 0x31, 0xc7, 0x30, 0x10, 0xdd, + 0x1c, 0xc3, 0xd0, 0x75, 0xf4, 0x6a, 0x60, 0x04, 0x80, 0xe0, 0x0c, 0x00, + 0xc5, 0x11, 0x00, 0xaa, 0x63, 0x0d, 0x40, 0x20, 0x10, 0x99, 0x01, 0xa0, + 0x30, 0x03, 0x40, 0x60, 0x8c, 0x00, 0x04, 0x41, 0x10, 0xff, 0x46, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x23, 0x06, 0xca, 0x10, 0x88, 0x01, 0xe4, 0x4c, + 0x89, 0x81, 0x04, 0x23, 0x06, 0xca, 0x10, 0x8c, 0x01, 0xf4, 0x50, 0xca, + 0x91, 0x08, 0x83, 0x0c, 0x42, 0xc1, 0x0c, 0x32, 0x08, 0x86, 0x33, 0xc8, + 0x20, 0x04, 0xd0, 0x20, 0x43, 0x90, 0x48, 0x77, 0x8d, 0xa5, 0xa0, 0xd8, + 0x10, 0xc0, 0x87, 0xb6, 0x32, 0xc8, 0x20, 0x34, 0xcf, 0x78, 0x03, 0x07, + 0x06, 0x6b, 0x70, 0xc1, 0x58, 0x0a, 0xca, 0x20, 0x43, 0x10, 0x4d, 0x23, + 0x06, 0x05, 0x11, 0xc8, 0x41, 0x11, 0xcc, 0x31, 0x4c, 0x41, 0x1c, 0x8c, + 0x37, 0x88, 0x81, 0x19, 0xb4, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, + 0xc1, 0x95, 0x8d, 0x18, 0x14, 0x44, 0x80, 0x07, 0x4b, 0x30, 0xc7, 0x60, + 0x04, 0x76, 0x30, 0xde, 0x80, 0x06, 0x6c, 0x20, 0x07, 0x17, 0x8c, 0xa5, + 0xa0, 0x0c, 0x32, 0x04, 0xdd, 0x37, 0x62, 0x50, 0x10, 0x81, 0x1f, 0x44, + 0xc1, 0x1c, 0x83, 0x11, 0xe0, 0xc1, 0x1c, 0x43, 0xf0, 0xe1, 0x81, 0x05, + 0x95, 0x7c, 0x32, 0x08, 0x88, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x5b, 0x86, 0x24, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf8, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x7b, 0x03, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, + 0x80, 0x05, 0xa8, 0x36, 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xc0, 0x00, 0x12, 0x31, 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, + 0x40, 0x0f, 0xec, 0x90, 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, + 0x40, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, + 0x40, 0x0e, 0xe5, 0xd0, 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, + 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, + 0x3c, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, + 0x3a, 0xb0, 0x43, 0x1b, 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, + 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, + 0x30, 0x0f, 0xf3, 0xd0, 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, + 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, + 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, + 0x3b, 0xa4, 0x43, 0x3b, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, + 0xe0, 0x0e, 0xef, 0xd0, 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, + 0xd0, 0x06, 0xf0, 0xf0, 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xe5, 0xc0, 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, + 0xe0, 0x0e, 0x6d, 0xc0, 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, + 0xf0, 0x0e, 0x6d, 0x90, 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, + 0x00, 0x0f, 0x6d, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, + 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, + 0x3d, 0xb4, 0x03, 0x3c, 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, + 0x39, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, + 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, + 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, + 0x3c, 0xa4, 0xc3, 0x39, 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, + 0x39, 0xc8, 0xc3, 0x3b, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, + 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, + 0x00, 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, + 0x20, 0x0f, 0x6d, 0x20, 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, + 0x3d, 0x84, 0x83, 0x3c, 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, + 0x39, 0x84, 0x03, 0x3d, 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, + 0x60, 0x0e, 0xf0, 0x10, 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, + 0x10, 0x0e, 0xe6, 0x50, 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, + 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, + 0x40, 0xd4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, + 0x3d, 0xb4, 0x81, 0x39, 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, + 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, + 0xff, 0xff, 0xff, 0x07, 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, + 0xc6, 0x81, 0x1e, 0xd8, 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, + 0xdc, 0x81, 0x1c, 0xca, 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, + 0xd2, 0x81, 0x1c, 0xca, 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, + 0x87, 0x79, 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, + 0x87, 0x74, 0x60, 0x87, 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, + 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, + 0xca, 0x61, 0x1e, 0xe6, 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, + 0xd2, 0x61, 0x1e, 0xca, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, + 0xc8, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, + 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, + 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, + 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, + 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, + 0xe4, 0xa1, 0x0d, 0xca, 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, + 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, + 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, + 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, + 0x87, 0x70, 0x70, 0x87, 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, + 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, + 0xca, 0x81, 0x1c, 0xda, 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, + 0x87, 0x70, 0x18, 0x87, 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, + 0x87, 0x72, 0x18, 0x07, 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, + 0x07, 0x73, 0x30, 0x87, 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, + 0x87, 0x72, 0x00, 0xf0, 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, + 0xca, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, + 0xe4, 0xa1, 0x1c, 0xe6, 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, + 0x03, 0x80, 0xa8, 0x07, 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, + 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, + 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, + 0xda, 0x60, 0x1e, 0xde, 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, + 0xde, 0x21, 0x1c, 0xe8, 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, + 0x07, 0x60, 0x03, 0x61, 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, + 0x80, 0x20, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, + 0x06, 0x22, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, + 0x88, 0x09, 0x41, 0x31, 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x68, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, + 0x08, 0x81, 0x30, 0x8c, 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, + 0x2f, 0xbb, 0x6f, 0x47, 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, + 0x11, 0x0a, 0xe1, 0x28, 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, + 0x26, 0x2a, 0x22, 0x7e, 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, + 0x08, 0x2e, 0x92, 0xa6, 0x88, 0x12, 0x26, 0xff, 0x97, 0x00, 0xe6, 0x59, + 0x88, 0xe8, 0x9f, 0xc6, 0x08, 0x80, 0x41, 0x84, 0x44, 0x28, 0x48, 0x08, + 0x62, 0x18, 0x84, 0x14, 0xad, 0x32, 0x00, 0x42, 0xa8, 0xcd, 0x11, 0x04, + 0x73, 0x04, 0x60, 0x30, 0x8c, 0x20, 0x40, 0x05, 0x09, 0x48, 0x89, 0x17, + 0x1f, 0x20, 0x39, 0x10, 0x30, 0x8c, 0x30, 0x40, 0xc3, 0x08, 0x04, 0x34, + 0x47, 0x00, 0x0a, 0x83, 0x08, 0x84, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x13, 0xa8, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, + 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, 0x74, 0x78, 0x87, 0x79, + 0xc8, 0x03, 0x37, 0x80, 0x03, 0x37, 0x80, 0x83, 0x0d, 0xef, 0x51, 0x0e, + 0x6d, 0x00, 0x0f, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x7a, 0x80, 0x07, + 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x78, 0xa0, 0x07, + 0x78, 0xd0, 0x06, 0xe9, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, + 0x7a, 0x10, 0x07, 0x76, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, + 0xe6, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, 0x07, + 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, + 0xf6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, + 0x76, 0xd0, 0x06, 0xf6, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xf6, 0x40, 0x07, + 0x78, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, + 0xf6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xd0, 0x06, 0xf6, 0x90, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x20, 0x07, + 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x90, 0x07, 0x72, 0xa0, 0x07, + 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, + 0xf6, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, + 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x75, 0x10, 0x07, + 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, 0x72, 0xa0, 0x07, 0x75, 0x10, 0x07, + 0x72, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, + 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, + 0x74, 0xd0, 0x06, 0xe6, 0x80, 0x07, 0x70, 0xa0, 0x07, 0x71, 0x20, 0x07, + 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xee, 0x80, 0x07, + 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x43, 0x18, 0x06, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x21, 0x8c, 0x03, 0x04, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x10, 0x66, 0x02, 0x02, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0b, 0x04, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, + 0xc6, 0x04, 0x43, 0x82, 0x23, 0x00, 0x25, 0x50, 0x20, 0x05, 0x18, 0x50, + 0x10, 0x45, 0x50, 0x06, 0x05, 0x54, 0x60, 0x85, 0x50, 0x0a, 0xc5, 0x40, + 0x77, 0x04, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x0d, 0x01, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0x40, 0x01, 0x43, 0x0c, 0x88, 0x80, 0x0e, 0x68, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0xa1, 0x06, 0x88, 0x80, 0x08, 0x68, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x04, 0xea, 0x20, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x95, 0xb9, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0xa8, 0x84, 0x61, 0x10, + 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, + 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, + 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x16, + 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, + 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, + 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0xa8, 0x06, 0x1a, + 0x28, 0x87, 0x7a, 0x86, 0x08, 0x14, 0x44, 0x26, 0x2c, 0x4d, 0xce, 0x05, + 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, 0x9c, + 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, 0x17, + 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, 0x34, + 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, + 0x86, 0x40, 0xd0, 0x40, 0x49, 0xd4, 0x44, 0x51, 0x94, 0x43, 0x3d, 0x54, + 0x45, 0x59, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, 0xda, + 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, 0x95, + 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, 0xe1, + 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, 0xf0, + 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, 0xa3, + 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, 0x84, + 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0x04, 0x11, 0x14, + 0x46, 0x65, 0xd4, 0x44, 0x69, 0x94, 0x43, 0x6d, 0x54, 0x45, 0x71, 0x54, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, 0x84, + 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, + 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, + 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, + 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, + 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, + 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, + 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, + 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, 0x00, 0x21, 0x94, 0x47, 0x7d, + 0x50, 0x41, 0x81, 0x01, 0x34, 0x40, 0x04, 0x15, 0x06, 0x94, 0x18, 0x40, + 0x05, 0x35, 0x06, 0x50, 0x41, 0x39, 0xd4, 0x43, 0x55, 0x14, 0x19, 0x90, + 0x0a, 0x4b, 0x93, 0x73, 0x99, 0xa3, 0x93, 0xab, 0x1b, 0xa3, 0xfb, 0xa2, + 0xcb, 0x83, 0x2b, 0xfb, 0x4a, 0x73, 0x33, 0x7b, 0xa3, 0x61, 0xc6, 0xf6, + 0x16, 0x46, 0x37, 0x43, 0xe3, 0xcd, 0xcc, 0x6c, 0xae, 0x8c, 0x8e, 0x86, + 0xd4, 0xd8, 0x5b, 0x99, 0x99, 0x19, 0x8d, 0xa3, 0xb1, 0xb7, 0x32, 0x33, + 0x33, 0x1a, 0x42, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x43, 0xd0, 0x00, 0x1a, + 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd0, 0x00, 0x2a, 0xa0, 0x02, 0x1a, + 0xa8, 0x33, 0xa0, 0xd2, 0x00, 0x52, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, + 0xd4, 0x00, 0x5a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd6, 0x80, 0x49, + 0x56, 0x95, 0x15, 0x51, 0xd9, 0xd8, 0x1b, 0x59, 0x19, 0x0d, 0xb2, 0xb2, + 0xb1, 0x37, 0xb2, 0xb2, 0x21, 0x64, 0x00, 0x25, 0x94, 0x47, 0x7d, 0x90, + 0x41, 0x81, 0x01, 0x44, 0x40, 0x04, 0x15, 0x06, 0x94, 0x19, 0x50, 0x6c, + 0x40, 0x89, 0x01, 0x64, 0x50, 0x63, 0x00, 0x15, 0x94, 0x43, 0xb5, 0x01, + 0x55, 0x51, 0x6e, 0xc0, 0x25, 0x2c, 0x4d, 0xce, 0x85, 0xae, 0x0c, 0x8f, + 0xae, 0x4e, 0xae, 0x8c, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x5c, 0x58, 0x1b, + 0x1c, 0x5b, 0x19, 0x31, 0xba, 0x32, 0x3c, 0xba, 0x3a, 0xb9, 0x32, 0x19, + 0x32, 0x1e, 0x33, 0xb6, 0xb7, 0x30, 0x3a, 0x16, 0x90, 0xb9, 0xb0, 0x36, + 0x38, 0xb6, 0x32, 0x1f, 0x12, 0x74, 0x65, 0x78, 0x59, 0x43, 0x28, 0x88, + 0xa1, 0xe0, 0x80, 0x02, 0x03, 0x68, 0x80, 0x08, 0x2a, 0x0e, 0x28, 0x87, + 0x92, 0x03, 0xaa, 0xa2, 0xe6, 0x80, 0x05, 0x5d, 0x19, 0x5e, 0x95, 0xd5, + 0x10, 0x0a, 0x6a, 0x28, 0x38, 0xa0, 0xc0, 0x00, 0x22, 0x20, 0x82, 0x8a, + 0x03, 0xca, 0xa1, 0xe4, 0x80, 0xaa, 0xa8, 0x3a, 0xe0, 0x12, 0x96, 0x26, + 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, 0x26, 0xc7, 0x63, 0x2e, 0xac, + 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, 0x10, 0x09, 0x72, 0xa8, 0x3b, + 0xa0, 0xc0, 0x00, 0x1a, 0x20, 0x82, 0x72, 0x28, 0x3c, 0xa0, 0x2a, 0x2a, + 0x0f, 0x86, 0x38, 0xd4, 0x45, 0x75, 0x54, 0x19, 0x50, 0x6f, 0x40, 0xd1, + 0x01, 0x65, 0x07, 0x94, 0x1e, 0x0c, 0x31, 0x18, 0x80, 0x8a, 0xa8, 0x3d, + 0xe0, 0xf3, 0xd6, 0xe6, 0x96, 0x06, 0xf7, 0x46, 0x57, 0xe6, 0x46, 0x07, + 0x32, 0x86, 0x16, 0x26, 0xc7, 0x67, 0x2a, 0xad, 0x0d, 0x8e, 0xad, 0x0c, + 0x64, 0x68, 0x65, 0x05, 0x84, 0x4a, 0x28, 0x28, 0x68, 0x88, 0x40, 0xf9, + 0xc1, 0x10, 0x83, 0xea, 0x03, 0xea, 0x0f, 0xae, 0x67, 0x88, 0x41, 0x81, + 0x02, 0x05, 0x0a, 0xd7, 0x33, 0x42, 0x61, 0x07, 0x76, 0xb0, 0x87, 0x76, + 0x70, 0x83, 0x74, 0x20, 0x87, 0x72, 0x70, 0x07, 0x7a, 0x98, 0x12, 0x04, + 0x23, 0x96, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x7b, 0x28, 0x07, 0x79, + 0x98, 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x08, 0x23, 0xa8, 0x70, + 0x48, 0x07, 0x79, 0x70, 0x03, 0x76, 0x08, 0x07, 0x77, 0x38, 0x87, 0x7a, + 0x08, 0x87, 0x73, 0x28, 0x87, 0x5f, 0xb0, 0x87, 0x72, 0x90, 0x87, 0x79, + 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x01, 0x31, 0x62, 0x0a, 0x87, 0x74, + 0x90, 0x07, 0x37, 0x18, 0x87, 0x77, 0x68, 0x07, 0x78, 0x48, 0x07, 0x76, + 0x28, 0x87, 0x5f, 0x78, 0x07, 0x78, 0xa0, 0x87, 0x74, 0x78, 0x07, 0x77, + 0x98, 0x87, 0x29, 0x84, 0x81, 0x28, 0xcc, 0x08, 0x26, 0x1c, 0xd2, 0x41, + 0x1e, 0xdc, 0xc0, 0x1c, 0xe4, 0x21, 0x1c, 0xce, 0xa1, 0x1d, 0xca, 0xc1, + 0x1d, 0xe8, 0x61, 0x4a, 0xc0, 0x07, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, + 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, + 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, + 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, + 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, + 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, + 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, + 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, + 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x16, 0xd0, 0x00, 0x48, + 0xe4, 0x0f, 0xce, 0xe4, 0x57, 0x77, 0x71, 0xdb, 0x26, 0xb0, 0x01, 0x48, + 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, 0xd7, 0x44, 0x45, 0xc4, + 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x6d, 0x00, 0x11, 0xdb, 0x95, 0xff, + 0xf9, 0xda, 0xf5, 0x5f, 0x44, 0x80, 0xc1, 0x10, 0xcd, 0x04, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x64, 0xe7, 0x20, 0x06, + 0x02, 0xf1, 0xa8, 0x8e, 0x35, 0x00, 0x03, 0x31, 0xc7, 0x30, 0x10, 0xde, + 0x1c, 0xc3, 0xe0, 0x79, 0x63, 0x0d, 0x40, 0x20, 0xd0, 0xab, 0x81, 0x11, + 0x00, 0x82, 0x33, 0x00, 0x14, 0x47, 0x00, 0xc6, 0x12, 0x02, 0x80, 0xc8, + 0x0c, 0x00, 0x89, 0x19, 0x00, 0x0a, 0x33, 0x00, 0x04, 0xc6, 0x08, 0x40, + 0x10, 0x04, 0xf1, 0x6f, 0x04, 0x00, 0x00, 0x00, 0x23, 0x06, 0xca, 0x10, + 0x90, 0x81, 0x04, 0x55, 0xca, 0x91, 0x04, 0x23, 0x06, 0xca, 0x10, 0x94, + 0x81, 0x14, 0x59, 0x0b, 0xa2, 0x08, 0x83, 0x0c, 0x41, 0x81, 0x0c, 0x32, + 0x0c, 0xc6, 0x33, 0xc8, 0x20, 0x20, 0xd1, 0x20, 0x83, 0x10, 0x4c, 0x83, + 0x0c, 0xc1, 0x52, 0x9d, 0x36, 0x96, 0x82, 0x62, 0x43, 0x00, 0x1f, 0xf2, + 0xca, 0x20, 0x83, 0xe0, 0x58, 0xe3, 0x0d, 0xdf, 0x18, 0xb8, 0xc1, 0x05, + 0x63, 0x29, 0x28, 0x83, 0x0c, 0x81, 0xa4, 0x8d, 0x18, 0x14, 0x44, 0x50, + 0x07, 0x45, 0x30, 0xc7, 0x40, 0x05, 0x74, 0x30, 0xde, 0x50, 0x06, 0x69, + 0x00, 0x07, 0x17, 0x8c, 0xa5, 0xa0, 0x0c, 0x32, 0x04, 0x18, 0x18, 0x8c, + 0x18, 0x14, 0x44, 0xb0, 0x07, 0x4b, 0x30, 0xc7, 0x60, 0x04, 0x79, 0x30, + 0xde, 0xb0, 0x06, 0x6f, 0x50, 0x07, 0x17, 0x8c, 0xa5, 0xa0, 0x0c, 0x32, + 0x04, 0x9e, 0x19, 0x8c, 0x18, 0x14, 0x44, 0x10, 0x0a, 0x51, 0x30, 0xc7, + 0x60, 0x04, 0x7b, 0x30, 0xc7, 0x10, 0x80, 0xc1, 0x1e, 0x58, 0x50, 0xc9, + 0x27, 0x83, 0x80, 0x18, 0x02, 0x00, 0x00, 0x00, 0x5b, 0x06, 0x25, 0x08, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; +const unsigned int sdl_metallib_len = 22744; diff --git a/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_osx.h b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_osx.h new file mode 100644 index 0000000..787c6fe --- /dev/null +++ b/source/3rd-party/SDL2/src/render/metal/SDL_shaders_metal_osx.h @@ -0,0 +1,1903 @@ +const unsigned char sdl_metallib[] = { + 0x4d, 0x54, 0x4c, 0x42, 0x01, 0x80, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x54, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x4e, 0x41, 0x4d, 0x45, 0x11, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x53, 0x6f, + 0x6c, 0x69, 0x64, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x00, 0x54, + 0x59, 0x50, 0x45, 0x01, 0x00, 0x00, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, + 0xcb, 0x86, 0x8e, 0x78, 0x90, 0x1d, 0xa9, 0xc3, 0xb9, 0xec, 0xcd, 0xec, + 0x69, 0xba, 0x3d, 0x7e, 0x97, 0xb5, 0xa9, 0x05, 0x01, 0xbe, 0x87, 0xd8, + 0x0c, 0xca, 0x1a, 0xb4, 0x91, 0x54, 0x7e, 0x29, 0x4f, 0x46, 0x46, 0x54, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x77, 0x00, 0x00, 0x00, + 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x43, 0x6f, + 0x70, 0x79, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x00, 0x54, 0x59, + 0x50, 0x45, 0x01, 0x00, 0x00, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, 0xf5, + 0xc6, 0xe3, 0x26, 0x71, 0xe3, 0x1c, 0x45, 0x4d, 0xb1, 0xdb, 0x0e, 0x1a, + 0x29, 0x85, 0x9d, 0xa7, 0x04, 0x40, 0x91, 0x18, 0x99, 0x5c, 0x9f, 0xdb, + 0x7c, 0x30, 0xd1, 0x67, 0x59, 0xd8, 0xa4, 0x4f, 0x46, 0x46, 0x54, 0x18, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x7a, 0x00, 0x00, 0x00, 0x4e, + 0x41, 0x4d, 0x45, 0x13, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x53, 0x6f, 0x6c, + 0x69, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x00, + 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, 0x20, + 0x00, 0x31, 0xa8, 0x6b, 0xb7, 0x4d, 0x8a, 0x56, 0xc7, 0x91, 0xa4, 0x37, + 0xfd, 0xa6, 0xbf, 0x79, 0xd1, 0x55, 0x8c, 0xd5, 0x1b, 0x88, 0x69, 0x8e, + 0x6c, 0xf0, 0x53, 0x1b, 0xd3, 0x35, 0xfe, 0x3f, 0x01, 0x4f, 0x46, 0x46, + 0x54, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, 0x08, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, 0x00, 0x00, + 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, 0x5f, 0x43, + 0x6f, 0x70, 0x79, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, + 0x20, 0x00, 0x52, 0xe7, 0xfc, 0x67, 0x4e, 0xed, 0x7a, 0xa8, 0x44, 0x82, + 0xb2, 0x41, 0x3c, 0xdb, 0x9e, 0xe8, 0x5b, 0xbb, 0x30, 0x60, 0xf8, 0xa1, + 0x94, 0xac, 0xb4, 0x80, 0xaa, 0x08, 0xa6, 0xa0, 0xe6, 0xfd, 0x4f, 0x46, + 0x46, 0x54, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x78, 0x00, + 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x11, 0x00, 0x53, 0x44, 0x4c, 0x5f, + 0x59, 0x55, 0x56, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, 0x48, + 0x20, 0x00, 0x28, 0x59, 0x9d, 0x20, 0x32, 0xc7, 0x94, 0x63, 0xa8, 0xda, + 0x9c, 0xac, 0x28, 0xb8, 0x01, 0xc3, 0x5f, 0x48, 0xf6, 0x74, 0x09, 0x1a, + 0xd9, 0x84, 0x91, 0x19, 0xc6, 0xe7, 0x4e, 0x94, 0x47, 0xce, 0x4f, 0x46, + 0x46, 0x54, 0x18, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x2a, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, 0x00, + 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, 0x5f, + 0x4e, 0x56, 0x31, 0x32, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, 0x53, + 0x48, 0x20, 0x00, 0x08, 0x35, 0xd4, 0x21, 0x2f, 0xca, 0x8d, 0x22, 0xb2, + 0xa3, 0x9a, 0xd8, 0xd9, 0x46, 0x6d, 0x01, 0x7d, 0x06, 0x95, 0x04, 0x7a, + 0x94, 0xdf, 0x2b, 0xd2, 0x21, 0xea, 0x99, 0x9f, 0x2b, 0xda, 0x65, 0x4f, + 0x46, 0x46, 0x54, 0x18, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x38, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x01, + 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x79, + 0x00, 0x00, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x12, 0x00, 0x53, 0x44, 0x4c, + 0x5f, 0x4e, 0x56, 0x32, 0x31, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x00, 0x54, 0x59, 0x50, 0x45, 0x01, 0x00, 0x01, 0x48, 0x41, + 0x53, 0x48, 0x20, 0x00, 0xe0, 0x53, 0xda, 0x06, 0xef, 0x80, 0x49, 0x61, + 0xf6, 0x9e, 0xee, 0xfe, 0x49, 0xb6, 0xd2, 0xce, 0xb8, 0xea, 0x5f, 0x9a, + 0xf4, 0x77, 0x35, 0xe7, 0xd3, 0xfc, 0x0f, 0xf6, 0x01, 0xe5, 0x90, 0xd6, + 0x4f, 0x46, 0x46, 0x54, 0x18, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x46, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, + 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, + 0x04, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x04, 0x00, 0x00, 0x00, + 0x45, 0x4e, 0x44, 0x54, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x38, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0xcb, 0x02, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0x20, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x02, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x18, + 0x80, 0x05, 0xa8, 0x36, 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x20, 0x01, 0x15, 0x31, 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, + 0x40, 0x0f, 0xec, 0x90, 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, + 0x40, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, + 0x40, 0x0e, 0xe5, 0xd0, 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, + 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, + 0x3c, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, + 0x3a, 0xb0, 0x43, 0x1b, 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, + 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, + 0x30, 0x0f, 0xf3, 0xd0, 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, + 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, + 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, + 0x3b, 0xa4, 0x43, 0x3b, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, + 0xe0, 0x0e, 0xef, 0xd0, 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, + 0xd0, 0x06, 0xf0, 0xf0, 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xe5, 0xc0, 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, + 0xe0, 0x0e, 0x6d, 0xc0, 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, + 0xf0, 0x0e, 0x6d, 0x90, 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, + 0x00, 0x0f, 0x6d, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, + 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, + 0x3d, 0xb4, 0x03, 0x3c, 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, + 0x39, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, + 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, + 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, + 0x3c, 0xa4, 0xc3, 0x39, 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, + 0x39, 0xc8, 0xc3, 0x3b, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, + 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, + 0x00, 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, + 0x20, 0x0f, 0x6d, 0x20, 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, + 0x3d, 0x84, 0x83, 0x3c, 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, + 0x39, 0x84, 0x03, 0x3d, 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, + 0x60, 0x0e, 0xf0, 0x10, 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, + 0x10, 0x0e, 0xe6, 0x50, 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, + 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, + 0x40, 0xd4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, + 0x3d, 0xb4, 0x81, 0x39, 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, + 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, 0x08, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x50, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x70, 0x9f, 0x34, 0x45, 0x94, + 0x30, 0xf9, 0xac, 0xb3, 0x20, 0xc3, 0x4b, 0x44, 0x13, 0x71, 0xa1, 0xd4, + 0xf4, 0x50, 0x93, 0xff, 0x00, 0x82, 0x42, 0x0c, 0x58, 0x08, 0x60, 0x18, + 0x41, 0x00, 0x06, 0x11, 0x86, 0x20, 0x09, 0xc2, 0x4c, 0xd3, 0x38, 0xb0, + 0x43, 0x38, 0xcc, 0xc3, 0x3c, 0xb8, 0x41, 0x3b, 0x94, 0x03, 0x3d, 0x84, + 0x03, 0x3b, 0xe8, 0x81, 0x1e, 0xb4, 0x43, 0x38, 0xd0, 0x83, 0x3c, 0xa4, + 0x03, 0x3e, 0xa0, 0xa0, 0x0c, 0x22, 0x18, 0xc2, 0x1c, 0x01, 0x18, 0x94, + 0x42, 0x90, 0x73, 0x10, 0xa5, 0x81, 0x00, 0x32, 0x73, 0x04, 0xa0, 0x30, + 0x88, 0x10, 0x08, 0x53, 0x00, 0x23, 0x00, 0xc3, 0x08, 0x04, 0x32, 0x47, + 0x10, 0x50, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, 0x87, 0x38, 0x80, 0x03, + 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, 0xf0, 0x1e, 0xe5, 0xd0, + 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x78, 0xa0, + 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, + 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, + 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, 0x10, + 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, + 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, 0x20, 0x07, 0x7a, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x74, 0x80, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, + 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x20, + 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, 0x20, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, + 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x50, 0x07, 0x71, 0x20, + 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, + 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, + 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0x30, 0x84, 0x51, 0x00, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x01, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x42, 0x25, 0x30, 0x02, 0x50, + 0x80, 0x01, 0x05, 0x51, 0x04, 0x05, 0x52, 0x06, 0xd4, 0x46, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, + 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, + 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, + 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, + 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0xb0, 0x00, + 0x43, 0x0c, 0x24, 0x40, 0x08, 0x44, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, + 0x36, 0x04, 0x59, 0x06, 0x24, 0x40, 0x02, 0x44, 0xe0, 0x16, 0x96, 0x26, + 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, + 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0x58, 0x0a, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, + 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x84, 0xe5, + 0x60, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, + 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, + 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, 0x91, 0xa5, 0xcd, 0x85, + 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x96, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, + 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, + 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, + 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, 0x16, 0x32, 0x61, 0x69, + 0x72, 0x2e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x8c, 0xc2, + 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, + 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x90, + 0x09, 0x4b, 0x93, 0x73, 0x09, 0x93, 0x3b, 0xfb, 0x72, 0x0b, 0x6b, 0x2b, + 0x23, 0x02, 0xf7, 0x36, 0x97, 0x46, 0x97, 0xf6, 0xe6, 0x36, 0x44, 0x59, + 0x9a, 0xc5, 0x59, 0x9e, 0x05, 0x5a, 0x22, 0x3a, 0x61, 0x69, 0x72, 0x2e, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2c, 0xcc, + 0xd8, 0xde, 0xc2, 0xe8, 0x98, 0xc0, 0xbd, 0xa5, 0xb9, 0xd1, 0x4d, 0xa5, + 0xe9, 0x95, 0x0d, 0x51, 0x96, 0x69, 0x71, 0x16, 0x6a, 0x81, 0x96, 0x6a, + 0x08, 0xb1, 0x48, 0x8b, 0x45, 0x25, 0x2c, 0x4d, 0xce, 0x45, 0xac, 0xce, + 0xcc, 0xac, 0x4c, 0x8e, 0x52, 0x58, 0x9a, 0x9c, 0x0b, 0xdb, 0xdb, 0x58, + 0x18, 0x5d, 0xda, 0x9b, 0xdb, 0x57, 0x9a, 0x1b, 0x59, 0x19, 0x1e, 0x91, + 0xb0, 0x34, 0x39, 0x17, 0xb9, 0xb2, 0x30, 0x32, 0x46, 0x61, 0x69, 0x72, + 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0xbc, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, + 0xf2, 0xe0, 0xca, 0xbe, 0xc2, 0xd8, 0xd2, 0xce, 0xdc, 0xbe, 0xe6, 0xd2, + 0xf4, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xc9, 0x0c, 0xe1, 0x10, + 0x61, 0xc1, 0x96, 0x0c, 0x11, 0x90, 0x60, 0xd1, 0x96, 0x0d, 0x21, 0x16, + 0x0e, 0x21, 0x16, 0x67, 0xe9, 0x16, 0x68, 0x89, 0xf8, 0x84, 0xa5, 0xc9, + 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, 0xe9, 0x95, + 0x11, 0x31, 0x63, 0x7b, 0x0b, 0xa3, 0xa3, 0xc1, 0xa3, 0xa1, 0x02, 0x27, + 0xf7, 0xa6, 0x56, 0x36, 0x46, 0x97, 0xf6, 0xe6, 0x36, 0x04, 0x0c, 0x90, + 0x60, 0xc1, 0x96, 0x0f, 0x19, 0x96, 0x0c, 0x29, 0x90, 0x60, 0xd1, 0x96, + 0x0d, 0x19, 0x16, 0x0e, 0x31, 0x16, 0x67, 0x01, 0x83, 0x05, 0x5a, 0xc2, + 0x80, 0x09, 0x9d, 0x5c, 0x98, 0xdb, 0x9c, 0xd9, 0x9b, 0x5c, 0xdb, 0x10, + 0x30, 0x40, 0x8a, 0x05, 0x5b, 0x3e, 0x64, 0x58, 0x32, 0xe4, 0x40, 0x82, + 0x45, 0x5b, 0x36, 0x64, 0x58, 0x38, 0xc4, 0x58, 0x9c, 0x05, 0x0c, 0x16, + 0x68, 0x19, 0x03, 0x36, 0x61, 0x69, 0x72, 0x2e, 0x76, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x5f, 0x69, 0x64, 0x24, 0xea, 0xd2, 0xdc, 0xe8, 0x38, 0xd8, + 0xa5, 0x91, 0x0d, 0x61, 0x90, 0x63, 0x29, 0x83, 0xc5, 0x59, 0xcc, 0x60, + 0x81, 0x96, 0x33, 0x18, 0x82, 0x2c, 0xde, 0x22, 0x06, 0x0b, 0x19, 0x2c, + 0x68, 0x30, 0xc4, 0x50, 0x80, 0xe5, 0x5a, 0xd2, 0x80, 0xcf, 0x5b, 0x9b, + 0x5b, 0x1a, 0xdc, 0x1b, 0x5d, 0x99, 0x1b, 0x1d, 0xc8, 0x18, 0x5a, 0x98, + 0x1c, 0x9f, 0xa9, 0xb4, 0x36, 0x38, 0xb6, 0x32, 0x90, 0xa1, 0x95, 0x15, + 0x10, 0x2a, 0xa1, 0xa0, 0xa0, 0x21, 0xc2, 0xc2, 0x06, 0x43, 0x8c, 0x65, + 0x0d, 0x96, 0x36, 0x68, 0x90, 0x21, 0xc6, 0xe2, 0x06, 0x8b, 0x1b, 0x34, + 0xc8, 0x08, 0x85, 0x1d, 0xd8, 0xc1, 0x1e, 0xda, 0xc1, 0x0d, 0xd2, 0x81, + 0x1c, 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0x10, 0x8c, 0x58, 0xc2, 0x21, + 0x1d, 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x61, 0x1e, 0xd2, 0xe1, + 0x1d, 0xdc, 0x61, 0x4a, 0x20, 0x8c, 0xa0, 0xc2, 0x21, 0x1d, 0xe4, 0xc1, + 0x0d, 0xd8, 0x21, 0x1c, 0xdc, 0xe1, 0x1c, 0xea, 0x21, 0x1c, 0xce, 0xa1, + 0x1c, 0x7e, 0xc1, 0x1e, 0xca, 0x41, 0x1e, 0xe6, 0x21, 0x1d, 0xde, 0xc1, + 0x1d, 0xa6, 0x04, 0xc4, 0x88, 0x29, 0x1c, 0xd2, 0x41, 0x1e, 0xdc, 0x60, + 0x1c, 0xde, 0xa1, 0x1d, 0xe0, 0x21, 0x1d, 0xd8, 0xa1, 0x1c, 0x7e, 0xe1, + 0x1d, 0xe0, 0x81, 0x1e, 0xd2, 0xe1, 0x1d, 0xdc, 0x61, 0x1e, 0xa6, 0x10, + 0x06, 0xa2, 0x30, 0x23, 0x94, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x7b, + 0x28, 0x07, 0x79, 0xa0, 0x87, 0x72, 0xc0, 0x87, 0x29, 0x81, 0x1a, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, + 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, + 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, + 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, + 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, + 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, + 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, + 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, + 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, + 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x06, 0x00, 0xb1, 0x5d, 0xf9, 0xb3, 0xce, 0x82, 0x0c, 0x7f, 0x45, 0x44, + 0x13, 0x71, 0x01, 0x00, 0x61, 0x20, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x47, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x14, 0x47, 0x00, 0xa8, 0x95, 0x41, 0x11, 0x94, 0x00, 0xa1, 0x42, 0x20, + 0x31, 0x03, 0x40, 0x61, 0x06, 0x80, 0xc0, 0x08, 0xc0, 0x18, 0x01, 0x08, + 0x82, 0x20, 0xfe, 0x01, 0x33, 0x11, 0x0c, 0x12, 0x14, 0x33, 0x11, 0x0c, + 0x12, 0x14, 0xe3, 0x11, 0x0e, 0x64, 0x41, 0x14, 0x94, 0x59, 0x82, 0x60, + 0xa0, 0x02, 0x81, 0x03, 0xe0, 0x0c, 0x86, 0x0b, 0x9a, 0x8c, 0x47, 0x44, + 0x94, 0x16, 0x50, 0x50, 0x06, 0x19, 0x82, 0x25, 0xb2, 0xc0, 0x90, 0xcf, + 0x2c, 0x81, 0x30, 0x50, 0x81, 0xf8, 0x41, 0x50, 0x09, 0x03, 0x15, 0x01, + 0x11, 0x44, 0xc2, 0x18, 0x42, 0x21, 0xcc, 0x31, 0x40, 0x41, 0x18, 0x0c, + 0x32, 0x04, 0xd1, 0x75, 0x45, 0x93, 0xf1, 0x08, 0xce, 0x23, 0x83, 0x80, + 0x82, 0x62, 0x01, 0x21, 0x1f, 0x0b, 0x10, 0xf8, 0x98, 0x92, 0x06, 0x30, + 0x18, 0x6e, 0x08, 0x34, 0x30, 0x98, 0x65, 0x18, 0x84, 0x60, 0x3c, 0xc2, + 0x22, 0x03, 0x35, 0x88, 0x06, 0x23, 0x02, 0xa2, 0x00, 0x6c, 0x62, 0x03, + 0x18, 0x0c, 0x37, 0x04, 0x1d, 0x18, 0xcc, 0x32, 0x10, 0x41, 0x30, 0x1e, + 0x91, 0x9d, 0x41, 0x1b, 0x9c, 0x01, 0x05, 0x65, 0x3c, 0x62, 0x4b, 0x83, + 0x37, 0x08, 0x03, 0x0a, 0xca, 0x78, 0x44, 0xb7, 0x06, 0x71, 0x40, 0x06, + 0x14, 0x94, 0xf1, 0x88, 0xaf, 0x0d, 0xe6, 0xe0, 0x0c, 0x28, 0x28, 0xe3, + 0x11, 0x60, 0xf0, 0x06, 0x75, 0xf0, 0x06, 0x83, 0x11, 0x01, 0x52, 0x00, + 0xe3, 0x11, 0x61, 0x00, 0x07, 0x76, 0x80, 0x06, 0x83, 0x11, 0xc1, 0x51, + 0x00, 0xe3, 0x11, 0x62, 0x10, 0x07, 0x77, 0xa0, 0x06, 0x83, 0x11, 0x81, + 0x51, 0x00, 0xe3, 0x11, 0x63, 0x20, 0x07, 0x78, 0xc0, 0x06, 0x83, 0x11, + 0x41, 0x51, 0x00, 0xf7, 0x06, 0x2d, 0xc6, 0x13, 0xe6, 0x20, 0xa0, 0x80, + 0x8c, 0x21, 0x04, 0x7c, 0x30, 0xc7, 0xc0, 0x06, 0x41, 0x1f, 0x8c, 0x21, + 0x0c, 0x7f, 0x30, 0xc7, 0x20, 0x04, 0xa0, 0x30, 0xc7, 0x10, 0xb8, 0x41, + 0x1f, 0xcc, 0x31, 0x04, 0x6e, 0xc0, 0x07, 0x83, 0x0c, 0x41, 0x1c, 0xdc, + 0x81, 0x05, 0x95, 0x7c, 0x66, 0x09, 0x8a, 0x81, 0x0a, 0x44, 0x25, 0x88, + 0xaa, 0x18, 0xa8, 0x08, 0x08, 0x22, 0x2a, 0xc6, 0x10, 0x0a, 0x61, 0x8e, + 0xc1, 0x0e, 0x82, 0x53, 0x18, 0x64, 0x08, 0xee, 0xa0, 0x0f, 0xae, 0x68, + 0x32, 0x1e, 0x51, 0x07, 0xa4, 0xa0, 0x0a, 0x01, 0x05, 0xc5, 0x02, 0x42, + 0x3e, 0x16, 0x20, 0xf0, 0x31, 0xe5, 0x15, 0x60, 0x30, 0xdc, 0x10, 0x80, + 0x02, 0x18, 0xcc, 0x32, 0x18, 0x45, 0x30, 0xdb, 0x00, 0x0a, 0x03, 0x30, + 0xdb, 0x10, 0xf8, 0x41, 0x90, 0x41, 0x40, 0x0c, 0x08, 0x00, 0x00, 0x00, + 0x5b, 0x86, 0x21, 0x78, 0x83, 0x2d, 0x03, 0x12, 0xbc, 0xc1, 0x96, 0x61, + 0x0a, 0xde, 0x60, 0xcb, 0xa0, 0x05, 0x6f, 0xb0, 0x65, 0x80, 0x83, 0xe0, + 0x0d, 0xb6, 0x0c, 0xa1, 0x10, 0xbc, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, + 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x90, 0x0b, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, + 0xe1, 0x02, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, + 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, + 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, + 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, + 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, + 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, + 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0x20, 0x00, 0x16, 0xa0, 0xda, 0x60, 0x08, 0x02, 0xb0, 0x00, + 0xd5, 0x06, 0x63, 0x18, 0x80, 0x05, 0xa8, 0x36, 0x18, 0x04, 0x01, 0x2c, + 0x40, 0xb5, 0x81, 0x5c, 0x8a, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x09, + 0xa8, 0x88, 0x71, 0x78, 0x07, 0x79, 0x90, 0x87, 0x72, 0x18, 0x07, 0x7a, + 0x60, 0x87, 0x7c, 0x68, 0x03, 0x79, 0x78, 0x87, 0x7a, 0x70, 0x07, 0x72, + 0x28, 0x07, 0x72, 0x68, 0x03, 0x72, 0x48, 0x07, 0x7b, 0x48, 0x07, 0x72, + 0x28, 0x87, 0x36, 0x98, 0x87, 0x78, 0x90, 0x07, 0x7a, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xcc, 0x21, + 0x1c, 0xd8, 0x61, 0x1e, 0xca, 0x01, 0x20, 0xc8, 0x21, 0x1d, 0xe6, 0x21, + 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0xa1, 0x0d, 0xe8, 0x21, 0x1c, 0xd2, 0x81, + 0x1d, 0xda, 0x60, 0x1c, 0xc2, 0x81, 0x1d, 0xd8, 0x61, 0x1e, 0x00, 0x73, + 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x76, 0x28, 0x87, 0x79, + 0x98, 0x87, 0x36, 0x80, 0x07, 0x79, 0x28, 0x87, 0x71, 0x48, 0x87, 0x79, + 0x28, 0x87, 0x36, 0x30, 0x07, 0x78, 0x68, 0x87, 0x70, 0x20, 0x07, 0x80, + 0x1e, 0xe4, 0xa1, 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0xc0, + 0x1c, 0xe4, 0x21, 0x1c, 0xda, 0xa1, 0x1c, 0xda, 0x00, 0x1e, 0xde, 0x21, + 0x1d, 0xdc, 0x81, 0x1e, 0xca, 0x41, 0x1e, 0xda, 0xa0, 0x1c, 0xd8, 0x21, + 0x1d, 0xda, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x06, 0x77, + 0x78, 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, + 0x80, 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, + 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x68, 0x03, 0x77, 0x78, 0x07, 0x77, + 0x68, 0x03, 0x76, 0x28, 0x87, 0x70, 0x30, 0x07, 0x80, 0x70, 0x87, 0x77, + 0x68, 0x83, 0x74, 0x70, 0x07, 0x73, 0x98, 0x87, 0x36, 0x30, 0x07, 0x78, + 0x68, 0x83, 0x76, 0x08, 0x07, 0x7a, 0x40, 0x07, 0x80, 0x1e, 0xe4, 0xa1, + 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x40, 0x1d, 0xea, 0xa1, + 0x1d, 0xe0, 0xa1, 0x0d, 0xe8, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, + 0x1e, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x77, + 0x78, 0x87, 0x36, 0x70, 0x87, 0x70, 0x70, 0x87, 0x79, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, + 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xe6, 0x21, + 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, 0xda, 0x40, 0x1f, 0xca, 0x41, + 0x1e, 0xde, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, + 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, + 0x00, 0x88, 0x79, 0xa0, 0x87, 0x70, 0x18, 0x87, 0x75, 0x68, 0x03, 0x78, + 0x90, 0x87, 0x77, 0xa0, 0x87, 0x72, 0x18, 0x07, 0x7a, 0x78, 0x07, 0x79, + 0x68, 0x03, 0x71, 0xa8, 0x07, 0x73, 0x30, 0x87, 0x72, 0x90, 0x87, 0x36, + 0x98, 0x87, 0x74, 0xd0, 0x87, 0x72, 0x00, 0xf0, 0x00, 0x20, 0xe8, 0x21, + 0x1c, 0xe4, 0xe1, 0x1c, 0xca, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xca, 0x21, + 0x1c, 0xe8, 0xa1, 0x1e, 0xe4, 0xa1, 0x1c, 0xe6, 0x01, 0x68, 0x03, 0x73, + 0x80, 0x87, 0x38, 0xb0, 0x03, 0x80, 0xa8, 0x07, 0x77, 0x98, 0x87, 0x70, + 0x30, 0x87, 0x72, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, + 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xa2, + 0x1e, 0xe6, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xde, 0xc1, 0x1c, 0xe8, 0xa1, + 0x0d, 0xcc, 0x81, 0x1d, 0xde, 0x21, 0x1c, 0xe8, 0x01, 0x30, 0x87, 0x70, + 0x60, 0x87, 0x79, 0x28, 0x07, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x8a, 0x40, 0x18, 0x88, 0x02, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x50, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0xe7, + 0x49, 0x53, 0x44, 0x09, 0x93, 0xcf, 0x39, 0x0f, 0xf6, 0x12, 0xd1, 0x44, + 0x5c, 0x28, 0x35, 0x3d, 0xd4, 0xe4, 0x3f, 0x80, 0xa0, 0x10, 0x03, 0x16, + 0x82, 0x18, 0x44, 0x10, 0x82, 0x24, 0x08, 0x33, 0x4d, 0xe3, 0xc0, 0x0e, + 0xe1, 0x30, 0x0f, 0xf3, 0xe0, 0x06, 0xed, 0x50, 0x0e, 0xf4, 0x10, 0x0e, + 0xec, 0xa0, 0x07, 0x7a, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xf2, 0x90, 0x0e, + 0xf8, 0x80, 0x82, 0x32, 0x88, 0x60, 0x08, 0x73, 0x04, 0x60, 0x50, 0x8c, + 0x41, 0xc8, 0x39, 0x88, 0xd2, 0x40, 0x00, 0x99, 0x39, 0x02, 0x50, 0x18, + 0x44, 0x08, 0x84, 0x29, 0x80, 0x11, 0x80, 0x61, 0x04, 0x02, 0x99, 0x23, + 0x08, 0x28, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, + 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, + 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, 0x87, 0x38, 0x80, 0x03, + 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, 0xf0, 0x1e, 0xe5, 0xd0, + 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x78, 0xa0, + 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, + 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, + 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, + 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, 0x10, + 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, + 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, 0x20, 0x07, 0x7a, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x74, 0x80, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, + 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, + 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x20, + 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, + 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, 0x20, 0x07, 0x7a, 0x20, + 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, + 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, + 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x50, 0x07, 0x71, 0x20, + 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, + 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, + 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, + 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, + 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, + 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0x30, 0x84, 0x51, 0x00, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x01, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x42, 0x25, 0x50, 0x10, 0x23, + 0x00, 0x05, 0x18, 0x50, 0x04, 0x05, 0x52, 0x06, 0x85, 0x40, 0x6d, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0xb0, 0x00, 0x43, 0x0c, 0x24, 0x40, 0x04, 0x64, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0x59, 0x06, 0x24, 0x40, 0x02, 0x64, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x84, 0xe5, 0x60, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x91, 0xa5, 0xcd, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x96, 0x84, 0x61, + 0x10, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, + 0xe2, 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, + 0x56, 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x58, + 0x16, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, + 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, + 0x85, 0xd1, 0xd1, 0x90, 0x09, 0x4b, 0x93, 0x73, 0x09, 0x93, 0x3b, 0xfb, + 0x72, 0x0b, 0x6b, 0x2b, 0x23, 0x02, 0xf7, 0x36, 0x97, 0x46, 0x97, 0xf6, + 0xe6, 0x36, 0x44, 0x59, 0x9a, 0xc5, 0x59, 0x9e, 0x05, 0x5a, 0x22, 0x46, + 0x61, 0x69, 0x72, 0x2e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x6f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0xcc, 0xce, 0xca, 0xdc, 0xca, 0xe4, 0xc2, + 0xe8, 0xca, 0xc8, 0x50, 0x70, 0xe8, 0xca, 0xf0, 0xc6, 0xde, 0xde, 0xe4, + 0xc8, 0x88, 0xec, 0x64, 0xbe, 0xcc, 0x52, 0x68, 0x98, 0xb1, 0xbd, 0x85, + 0xd1, 0xc9, 0x10, 0xa1, 0x2b, 0xc3, 0x1b, 0x7b, 0x7b, 0x93, 0x23, 0x1b, + 0xc2, 0x2c, 0xd3, 0x42, 0x2d, 0xce, 0x52, 0x2d, 0xd0, 0x62, 0x0d, 0x21, + 0x16, 0x69, 0xb9, 0xa8, 0x84, 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, + 0x95, 0xc9, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, + 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, + 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, + 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, + 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, + 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, + 0xd9, 0x10, 0x0e, 0x19, 0x96, 0x6c, 0xd1, 0x90, 0x01, 0x09, 0x96, 0x6d, + 0xe1, 0x10, 0x61, 0xe9, 0x10, 0x61, 0x71, 0x96, 0x6a, 0x81, 0x96, 0x88, + 0x09, 0x5d, 0x19, 0xde, 0xd8, 0xdb, 0x9b, 0x1c, 0xd9, 0xdc, 0x10, 0x0e, + 0x09, 0x96, 0x6c, 0xd1, 0x90, 0x00, 0x09, 0x96, 0x6d, 0xe1, 0x10, 0x61, + 0xe9, 0x10, 0x61, 0x71, 0x96, 0x6a, 0x81, 0x96, 0x8f, 0x4f, 0x58, 0x9a, + 0x9c, 0x8b, 0x58, 0x9d, 0x99, 0x59, 0x99, 0xdc, 0xd7, 0x5c, 0x9a, 0x5e, + 0x19, 0x11, 0x33, 0xb6, 0xb7, 0x30, 0x3a, 0x1a, 0x3c, 0x1a, 0x2a, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0xc0, 0x00, + 0x29, 0x96, 0x6c, 0x09, 0x03, 0x84, 0x58, 0x34, 0xa4, 0x40, 0x82, 0x65, + 0x5b, 0x38, 0x84, 0x58, 0x3a, 0xc4, 0x58, 0x9c, 0x45, 0x0c, 0x16, 0x68, + 0x19, 0x03, 0x26, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, + 0x43, 0xc0, 0x00, 0x39, 0x96, 0x6c, 0x09, 0x03, 0x84, 0x58, 0x34, 0xe4, + 0x40, 0x82, 0x65, 0x5b, 0x38, 0x84, 0x58, 0x3a, 0xc4, 0x58, 0x9c, 0x45, + 0x0c, 0x16, 0x68, 0x29, 0x03, 0x36, 0x61, 0x69, 0x72, 0x2e, 0x76, 0x65, + 0x72, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x64, 0x24, 0xea, 0xd2, 0xdc, 0xe8, + 0x38, 0xd8, 0xa5, 0x91, 0x0d, 0x61, 0x10, 0x64, 0x39, 0x83, 0xc5, 0x59, + 0xd0, 0x60, 0x81, 0x96, 0x34, 0x18, 0xa2, 0x2c, 0xde, 0x02, 0x06, 0x0b, + 0x19, 0x2c, 0x66, 0xb0, 0xa8, 0xc1, 0x10, 0x43, 0x01, 0x16, 0x6c, 0x59, + 0x03, 0x3e, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, + 0x20, 0x63, 0x68, 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, 0xe0, 0xd8, 0xca, + 0x40, 0x86, 0x56, 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, 0x86, 0x08, 0x8b, + 0x1b, 0x0c, 0x31, 0x96, 0x36, 0x58, 0xde, 0xa0, 0x49, 0x86, 0x18, 0x0b, + 0x1c, 0x2c, 0x70, 0xd0, 0x24, 0x23, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x48, 0x07, 0x72, 0x28, 0x07, 0x77, 0xa0, 0x87, 0x29, 0x41, + 0x30, 0x62, 0x09, 0x87, 0x74, 0x90, 0x07, 0x37, 0xb0, 0x87, 0x72, 0x90, + 0x87, 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x81, 0x30, 0x82, 0x0a, + 0x87, 0x74, 0x90, 0x07, 0x37, 0x60, 0x87, 0x70, 0x70, 0x87, 0x73, 0xa8, + 0x87, 0x70, 0x38, 0x87, 0x72, 0xf8, 0x05, 0x7b, 0x28, 0x07, 0x79, 0x98, + 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x10, 0x23, 0xa6, 0x70, 0x48, + 0x07, 0x79, 0x70, 0x83, 0x71, 0x78, 0x87, 0x76, 0x80, 0x87, 0x74, 0x60, + 0x87, 0x72, 0xf8, 0x85, 0x77, 0x80, 0x07, 0x7a, 0x48, 0x87, 0x77, 0x70, + 0x87, 0x79, 0x98, 0x42, 0x18, 0x88, 0xc2, 0x8c, 0x50, 0xc2, 0x21, 0x1d, + 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x81, 0x1e, 0xca, 0x01, 0x1f, + 0xa6, 0x04, 0x6c, 0x00, 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, + 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, + 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, + 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, + 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, + 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, + 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, + 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, + 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, + 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, + 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, + 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, + 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, + 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, + 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x06, 0xf0, 0xb0, 0x5d, 0xf9, 0x73, 0xce, 0x83, + 0xfd, 0x15, 0x11, 0x4d, 0xc4, 0x05, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x13, 0x04, 0x47, 0x2c, 0x10, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x14, 0x47, 0x00, 0xa8, 0x95, 0x41, 0x11, 0x94, + 0x00, 0x8d, 0x19, 0x00, 0x0a, 0x33, 0x00, 0x04, 0xc6, 0x08, 0x40, 0x10, + 0x04, 0xf1, 0x6f, 0x04, 0x00, 0x00, 0x00, 0x00, 0x33, 0x11, 0x0c, 0x12, + 0x14, 0x33, 0x11, 0x0c, 0x12, 0x14, 0xe3, 0x11, 0x0d, 0x64, 0x41, 0x14, + 0x94, 0x59, 0x82, 0x60, 0xa0, 0x02, 0x81, 0x03, 0xe0, 0x0c, 0x86, 0x0b, + 0x9a, 0x8c, 0x47, 0x40, 0x94, 0x16, 0x50, 0x50, 0x06, 0x19, 0x82, 0x05, + 0xb2, 0xc0, 0x90, 0xcf, 0x2c, 0x81, 0x30, 0x50, 0x81, 0x80, 0x42, 0x50, + 0x09, 0x03, 0x15, 0x01, 0x11, 0x44, 0xc2, 0x18, 0x42, 0x21, 0xcc, 0x31, + 0x40, 0x41, 0x18, 0x0c, 0x32, 0x04, 0x91, 0x75, 0x45, 0x93, 0xf1, 0x88, + 0xcd, 0x23, 0x83, 0x80, 0x82, 0x62, 0x01, 0x21, 0x1f, 0x0b, 0x10, 0xf8, + 0x98, 0xa2, 0x06, 0x30, 0x18, 0x6e, 0x08, 0xc8, 0x00, 0x0c, 0x66, 0x19, + 0x06, 0x21, 0x18, 0x8f, 0xb0, 0xc8, 0x40, 0x0d, 0xa2, 0xc1, 0x88, 0x80, + 0x28, 0x00, 0x9b, 0xda, 0x00, 0x06, 0xc3, 0x0d, 0xc1, 0x19, 0x80, 0xc1, + 0x2c, 0x03, 0x11, 0x04, 0xe3, 0x11, 0xd9, 0x19, 0xb4, 0xc1, 0x19, 0x50, + 0x50, 0xc6, 0x23, 0xb6, 0x34, 0x78, 0x03, 0x30, 0xa0, 0xa0, 0x8c, 0x47, + 0x74, 0x6b, 0x10, 0x07, 0x63, 0x40, 0x41, 0x19, 0x8f, 0xf8, 0xda, 0x60, + 0x0e, 0xcc, 0x80, 0x82, 0x32, 0x1e, 0x01, 0x06, 0x6f, 0x50, 0x07, 0x6f, + 0x30, 0x18, 0x11, 0x20, 0x05, 0x30, 0x1e, 0x11, 0x06, 0x70, 0x60, 0x07, + 0x67, 0x30, 0x18, 0x11, 0x1c, 0x05, 0x30, 0x1e, 0x21, 0x06, 0x71, 0x70, + 0x07, 0x69, 0x30, 0x18, 0x11, 0x18, 0x05, 0x30, 0x1e, 0x31, 0x06, 0x72, + 0x80, 0x07, 0x6b, 0x30, 0x18, 0x11, 0x14, 0x05, 0x70, 0x6e, 0xd0, 0x62, + 0x3c, 0x61, 0x0e, 0x02, 0x0a, 0xc8, 0x18, 0x42, 0xc0, 0x07, 0x73, 0x0c, + 0x6c, 0x10, 0xf4, 0xc1, 0x18, 0xc2, 0x00, 0x0a, 0x73, 0x0c, 0x42, 0x10, + 0x0a, 0x73, 0x0c, 0x41, 0x1b, 0xf8, 0xc1, 0x1c, 0x43, 0xf0, 0x06, 0x7d, + 0x30, 0xc8, 0x10, 0xc4, 0x81, 0x1d, 0x58, 0x50, 0xc9, 0x67, 0x96, 0xa0, + 0x18, 0xa8, 0x40, 0x58, 0x82, 0xa8, 0x8a, 0x81, 0x8a, 0x80, 0x20, 0xa2, + 0x62, 0x0c, 0xa1, 0x10, 0xe6, 0x18, 0xec, 0x20, 0x38, 0x85, 0x41, 0x86, + 0xe0, 0x0e, 0xf8, 0xe0, 0x8a, 0x26, 0xe3, 0x11, 0x75, 0x40, 0x0a, 0xaa, + 0x10, 0x50, 0x50, 0x2c, 0x20, 0xe4, 0x63, 0x01, 0x02, 0x1f, 0x53, 0x60, + 0x01, 0x06, 0xc3, 0x0d, 0x81, 0x2a, 0x80, 0xc1, 0x2c, 0x83, 0x51, 0x04, + 0xe3, 0x09, 0xa8, 0x70, 0x51, 0x40, 0x66, 0x1b, 0x44, 0xa1, 0x00, 0x66, + 0x1b, 0x02, 0x21, 0xc8, 0x20, 0x20, 0x06, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x5b, 0x86, 0x21, 0x88, 0x83, 0x2d, 0x03, 0x12, 0xc4, 0xc1, 0x96, 0x61, + 0x0a, 0xe2, 0x60, 0xcb, 0xa0, 0x05, 0x71, 0xb0, 0x65, 0x80, 0x83, 0x20, + 0x0e, 0xb6, 0x0c, 0xa1, 0x10, 0xc4, 0xc1, 0x96, 0x01, 0x15, 0x82, 0x38, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x98, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x23, 0x02, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, + 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, + 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, + 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x08, 0x11, 0x62, 0xa8, 0xa0, + 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0x20, 0x00, 0x16, 0xa0, 0xda, 0x40, + 0x2e, 0xc2, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x80, 0x04, 0x54, 0xc4, 0x38, + 0xbc, 0x83, 0x3c, 0xc8, 0x43, 0x39, 0x8c, 0x03, 0x3d, 0xb0, 0x43, 0x3e, + 0xb4, 0x81, 0x3c, 0xbc, 0x43, 0x3d, 0xb8, 0x03, 0x39, 0x94, 0x03, 0x39, + 0xb4, 0x01, 0x39, 0xa4, 0x83, 0x3d, 0xa4, 0x03, 0x39, 0x94, 0x43, 0x1b, + 0xcc, 0x43, 0x3c, 0xc8, 0x03, 0x3d, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, + 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, 0x00, 0xe6, 0x10, 0x0e, 0xec, 0x30, + 0x0f, 0xe5, 0x00, 0x10, 0xe4, 0x90, 0x0e, 0xf3, 0x10, 0x0e, 0xe2, 0xc0, + 0x0e, 0xe5, 0xd0, 0x06, 0xf4, 0x10, 0x0e, 0xe9, 0xc0, 0x0e, 0x6d, 0x30, + 0x0e, 0xe1, 0xc0, 0x0e, 0xec, 0x30, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, + 0xcc, 0x43, 0x39, 0x00, 0x04, 0x3b, 0x94, 0xc3, 0x3c, 0xcc, 0x43, 0x1b, + 0xc0, 0x83, 0x3c, 0x94, 0xc3, 0x38, 0xa4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, + 0x98, 0x03, 0x3c, 0xb4, 0x43, 0x38, 0x90, 0x03, 0x40, 0x0f, 0xf2, 0x50, + 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x60, 0x0e, 0xf2, 0x10, + 0x0e, 0xed, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0xef, 0x90, 0x0e, 0xee, 0x40, + 0x0f, 0xe5, 0x20, 0x0f, 0x6d, 0x50, 0x0e, 0xec, 0x90, 0x0e, 0xed, 0x00, + 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x83, 0x3b, 0xbc, 0x43, 0x1b, + 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, 0x3b, + 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, + 0xa4, 0x43, 0x3b, 0xb4, 0x81, 0x3b, 0xbc, 0x83, 0x3b, 0xb4, 0x01, 0x3b, + 0x94, 0x43, 0x38, 0x98, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0x41, 0x3a, + 0xb8, 0x83, 0x39, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, 0x3b, + 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, + 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0xa0, 0x0e, 0xf5, 0xd0, 0x0e, 0xf0, 0xd0, + 0x06, 0xf4, 0x10, 0x0e, 0xe2, 0xc0, 0x0e, 0xe5, 0x30, 0x0f, 0x80, 0x39, + 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, + 0xb8, 0x43, 0x38, 0xb8, 0xc3, 0x3c, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, + 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, + 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xe7, 0xe0, + 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0xa0, 0x0f, 0xe5, 0x20, 0x0f, 0xef, 0x30, + 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, + 0x0e, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0xc4, 0x3c, + 0xd0, 0x43, 0x38, 0x8c, 0xc3, 0x3a, 0xb4, 0x01, 0x3c, 0xc8, 0xc3, 0x3b, + 0xd0, 0x43, 0x39, 0x8c, 0x03, 0x3d, 0xbc, 0x83, 0x3c, 0xb4, 0x81, 0x38, + 0xd4, 0x83, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0xcc, 0x43, 0x3a, + 0xe8, 0x43, 0x39, 0x00, 0x78, 0x00, 0x10, 0xf4, 0x10, 0x0e, 0xf2, 0x70, + 0x0e, 0xe5, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xe5, 0x10, 0x0e, 0xf4, 0x50, + 0x0f, 0xf2, 0x50, 0x0e, 0xf3, 0x00, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1c, + 0xd8, 0x01, 0x40, 0xd4, 0x83, 0x3b, 0xcc, 0x43, 0x38, 0x98, 0x43, 0x39, + 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, + 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0x51, 0x0f, 0xf3, 0x50, + 0x0e, 0x6d, 0x30, 0x0f, 0xef, 0x60, 0x0e, 0xf4, 0xd0, 0x06, 0xe6, 0xc0, + 0x0e, 0xef, 0x10, 0x0e, 0xf4, 0x00, 0x98, 0x43, 0x38, 0xb0, 0xc3, 0x3c, + 0x94, 0x03, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x13, 0x84, 0x40, 0x00, 0x89, 0x20, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x32, 0x22, 0x08, 0x09, 0x20, 0x64, 0x85, 0x04, 0x13, 0x22, 0xa4, 0x84, + 0x04, 0x13, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, + 0x0b, 0x84, 0x84, 0x4c, 0x10, 0x24, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, + 0x88, 0x10, 0x08, 0x45, 0x08, 0xa1, 0x19, 0x08, 0x98, 0x23, 0x00, 0x83, + 0x39, 0x02, 0x50, 0x18, 0x01, 0x00, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, + 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, + 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, + 0x87, 0x38, 0x80, 0x03, 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, + 0xf0, 0x1e, 0xe5, 0xd0, 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, + 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, + 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, + 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0f, 0x74, 0x80, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0x60, 0x0f, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, + 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, + 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, + 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, + 0x00, 0x07, 0x72, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0x30, 0x84, 0x21, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, + 0x02, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x0c, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xb2, + 0x11, 0x80, 0x12, 0x28, 0x90, 0x82, 0xa0, 0x1b, 0x01, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, + 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, + 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, + 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, + 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x50, 0x00, + 0x43, 0x0c, 0x43, 0x30, 0x08, 0x23, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, + 0x36, 0x04, 0x29, 0x06, 0x43, 0x30, 0x04, 0x23, 0xe0, 0x16, 0x96, 0x26, + 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, + 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0x28, 0x0a, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, + 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x84, 0xe2, + 0x60, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, + 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, + 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, 0x91, 0xa5, 0xcd, 0x85, + 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x8a, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, + 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, + 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, + 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x28, 0x16, 0x46, 0x61, 0x69, + 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, + 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, + 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0x8a, 0xc6, 0x08, 0x0a, 0xa7, 0x78, + 0x86, 0x08, 0x05, 0x44, 0x25, 0x2c, 0x4d, 0xce, 0x45, 0xac, 0xce, 0xcc, + 0xac, 0x4c, 0x8e, 0x4f, 0x58, 0x9a, 0x9c, 0x8b, 0x58, 0x9d, 0x99, 0x59, + 0x99, 0xdc, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0xa5, 0xb0, 0x34, 0x39, 0x17, + 0xb6, 0xb7, 0xb1, 0x30, 0xba, 0xb4, 0x37, 0xb7, 0xaf, 0x34, 0x37, 0xb2, + 0x32, 0x3c, 0x22, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x8c, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, + 0xbe, 0xe6, 0xd2, 0xf4, 0xca, 0x78, 0x85, 0xa5, 0xc9, 0xb9, 0x84, 0xc9, + 0x9d, 0x7d, 0xd1, 0xe5, 0xc1, 0x95, 0x7d, 0x85, 0xb1, 0xa5, 0x9d, 0xb9, + 0x7d, 0xcd, 0xa5, 0xe9, 0x95, 0x91, 0x09, 0x4b, 0x93, 0x73, 0x09, 0x93, + 0x3b, 0xfb, 0x72, 0x0b, 0x6b, 0x2b, 0xe3, 0x30, 0xf6, 0xc6, 0x36, 0x04, + 0x0c, 0x8c, 0xa0, 0x90, 0x8a, 0xc9, 0x18, 0x0a, 0xca, 0x08, 0x0c, 0xa1, + 0xa8, 0x0a, 0xcb, 0x18, 0x8a, 0xcb, 0x18, 0x0a, 0xa7, 0x78, 0x0a, 0xac, + 0xc8, 0x86, 0x08, 0x85, 0x36, 0xc4, 0x20, 0x80, 0x22, 0x2a, 0x36, 0x3e, + 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, 0x20, 0x63, + 0x68, 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, 0xe0, 0xd8, 0xca, 0x40, 0x86, + 0x56, 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, 0x86, 0x08, 0x85, 0x37, 0xc4, + 0x28, 0xba, 0xe2, 0x3b, 0x8a, 0x21, 0x46, 0x01, 0x06, 0x05, 0x18, 0x1c, + 0xc5, 0x08, 0x85, 0x1d, 0xd8, 0xc1, 0x1e, 0xda, 0xc1, 0x0d, 0xd2, 0x81, + 0x1c, 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0x10, 0x8c, 0x58, 0xc2, 0x21, + 0x1d, 0xe4, 0xc1, 0x0d, 0xec, 0xa1, 0x1c, 0xe4, 0x61, 0x1e, 0xd2, 0xe1, + 0x1d, 0xdc, 0x61, 0x4a, 0x20, 0x8c, 0xa0, 0xc2, 0x21, 0x1d, 0xe4, 0xc1, + 0x0d, 0xd8, 0x21, 0x1c, 0xdc, 0xe1, 0x1c, 0xea, 0x21, 0x1c, 0xce, 0xa1, + 0x1c, 0x7e, 0xc1, 0x1e, 0xca, 0x41, 0x1e, 0xe6, 0x21, 0x1d, 0xde, 0xc1, + 0x1d, 0xa6, 0x04, 0xc4, 0x88, 0x29, 0x1c, 0xd2, 0x41, 0x1e, 0xdc, 0x60, + 0x1c, 0xde, 0xa1, 0x1d, 0xe0, 0x21, 0x1d, 0xd8, 0xa1, 0x1c, 0x7e, 0xe1, + 0x1d, 0xe0, 0x81, 0x1e, 0xd2, 0xe1, 0x1d, 0xdc, 0x61, 0x1e, 0xa6, 0x10, + 0x06, 0xa2, 0x30, 0x23, 0x98, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x73, + 0x90, 0x87, 0x70, 0x38, 0x87, 0x76, 0x28, 0x07, 0x77, 0xa0, 0x87, 0x29, + 0x01, 0x07, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, + 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, + 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, + 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, + 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, + 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, + 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, + 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, + 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, + 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, + 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, + 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, + 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, + 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, + 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x20, 0xb1, 0x5d, 0xf9, 0xb3, 0xce, 0x82, + 0x0c, 0x7f, 0x11, 0x01, 0x06, 0x43, 0x34, 0x13, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x04, 0x01, 0x05, + 0x25, 0x83, 0x80, 0x18, 0x02, 0x00, 0x00, 0x00, 0x5b, 0x06, 0x20, 0x08, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x68, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x97, 0x02, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x05, 0xb0, 0x00, 0xd5, 0x06, 0x73, 0x19, + 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x18, 0x40, 0x02, 0x2a, 0x62, 0x1c, + 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xd8, 0x21, 0x1f, + 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, 0xdc, 0x81, 0x1c, 0xca, 0x81, 0x1c, + 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, 0xd2, 0x81, 0x1c, 0xca, 0xa1, 0x0d, + 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, + 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, + 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, 0x87, 0x79, 0x08, 0x07, 0x71, 0x60, + 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, 0x87, 0x74, 0x60, 0x87, 0x36, 0x18, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, + 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, 0xca, 0x61, 0x1e, 0xe6, 0xa1, 0x0d, + 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xd2, 0x61, 0x1e, 0xca, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, 0xc8, 0x01, 0xa0, 0x07, 0x79, 0xa8, + 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, + 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, + 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, + 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, + 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, + 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, 0x81, 0x1d, + 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, + 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, + 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, + 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, + 0x08, 0x77, 0x78, 0x87, 0x36, 0x50, 0x87, 0x7a, 0x68, 0x07, 0x78, 0x68, + 0x03, 0x7a, 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x98, 0x07, 0xc0, 0x1c, + 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, + 0xdc, 0x21, 0x1c, 0xdc, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, + 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, + 0x07, 0x80, 0x70, 0x87, 0x77, 0x68, 0x83, 0x79, 0x48, 0x87, 0x73, 0x70, + 0x87, 0x72, 0x20, 0x87, 0x36, 0xd0, 0x87, 0x72, 0x90, 0x87, 0x77, 0x98, + 0x87, 0x36, 0x30, 0x07, 0x78, 0x68, 0x83, 0x76, 0x08, 0x07, 0x7a, 0x40, + 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x62, 0x1e, + 0xe8, 0x21, 0x1c, 0xc6, 0x61, 0x1d, 0xda, 0x00, 0x1e, 0xe4, 0xe1, 0x1d, + 0xe8, 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xde, 0x41, 0x1e, 0xda, 0x40, 0x1c, + 0xea, 0xc1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xe6, 0x21, 0x1d, + 0xf4, 0xa1, 0x1c, 0x00, 0x3c, 0x00, 0x08, 0x7a, 0x08, 0x07, 0x79, 0x38, + 0x87, 0x72, 0xa0, 0x87, 0x36, 0x30, 0x87, 0x72, 0x08, 0x07, 0x7a, 0xa8, + 0x07, 0x79, 0x28, 0x87, 0x79, 0x00, 0xda, 0xc0, 0x1c, 0xe0, 0x21, 0x0e, + 0xec, 0x00, 0x20, 0xea, 0xc1, 0x1d, 0xe6, 0x21, 0x1c, 0xcc, 0xa1, 0x1c, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, 0xa8, 0x87, 0x79, 0x28, + 0x87, 0x36, 0x98, 0x87, 0x77, 0x30, 0x07, 0x7a, 0x68, 0x03, 0x73, 0x60, + 0x87, 0x77, 0x08, 0x07, 0x7a, 0x00, 0xcc, 0x21, 0x1c, 0xd8, 0x61, 0x1e, + 0xca, 0x01, 0xd8, 0x40, 0x10, 0x01, 0xb0, 0x6c, 0x20, 0x0a, 0x01, 0x58, + 0x36, 0x20, 0xc6, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x03, 0x48, 0x40, + 0x05, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x13, 0x86, 0x40, 0x18, 0x26, 0x0c, 0x44, 0x61, 0x00, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x48, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, + 0x08, 0x81, 0x70, 0x94, 0x34, 0x45, 0x94, 0x30, 0xf9, 0xff, 0x44, 0x5c, + 0x13, 0x15, 0x11, 0xbf, 0x3d, 0xfc, 0xd3, 0x18, 0x01, 0x30, 0x88, 0x40, + 0x04, 0x17, 0x49, 0x53, 0x44, 0x09, 0x93, 0xff, 0x4b, 0x00, 0xf3, 0x2c, + 0x44, 0xf4, 0x4f, 0x63, 0x04, 0xc0, 0x20, 0x82, 0x21, 0x14, 0x23, 0x04, + 0x31, 0xca, 0x21, 0x34, 0x47, 0x10, 0xcc, 0x11, 0x80, 0xc1, 0x30, 0x82, + 0xb0, 0x14, 0x24, 0x94, 0x23, 0x14, 0x53, 0x80, 0xda, 0x40, 0xc0, 0x1c, + 0x01, 0x28, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, + 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, + 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, + 0x87, 0x38, 0x80, 0x03, 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, + 0xf0, 0x1e, 0xe5, 0xd0, 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, + 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, + 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, + 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0f, 0x74, 0x80, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0x60, 0x0f, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, + 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, + 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, + 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, + 0x00, 0x07, 0x72, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0x30, 0x84, 0x49, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0xc2, 0x38, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x81, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x5a, + 0x25, 0x30, 0x02, 0x50, 0x20, 0x05, 0x51, 0x04, 0x65, 0x50, 0x08, 0x04, + 0x47, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, + 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, + 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, + 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, + 0x65, 0x88, 0xf0, 0x00, 0x43, 0x8c, 0x45, 0x58, 0x8a, 0x65, 0x60, 0xd1, + 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0x79, 0x86, 0x45, 0x58, 0x84, 0x65, + 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, + 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, + 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x78, 0x0a, 0x72, 0x61, 0x69, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x43, 0x84, 0xe7, 0x60, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, + 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, + 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, + 0x91, 0xa5, 0xcd, 0x85, 0x89, 0xb1, 0x95, 0x0d, 0x11, 0x9e, 0x84, 0x61, + 0x10, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, + 0xe2, 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, + 0x56, 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0x78, + 0x16, 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, + 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, + 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0x9e, 0x66, + 0x19, 0x1e, 0xe7, 0x79, 0x86, 0x08, 0x0f, 0x44, 0x26, 0x2c, 0x4d, 0xce, + 0x05, 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, + 0x9c, 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, + 0x17, 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, + 0x34, 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, + 0xdc, 0x86, 0x40, 0xcb, 0xf0, 0x48, 0xcf, 0xf4, 0x50, 0x8f, 0xf3, 0x3c, + 0x4f, 0xf5, 0x58, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, + 0xda, 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, + 0x95, 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, + 0xe1, 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, + 0xf0, 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, + 0xa3, 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, + 0x84, 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0xb4, 0x08, + 0x0f, 0xf6, 0x64, 0xcf, 0xf4, 0x68, 0x8f, 0xf3, 0x6c, 0x4f, 0xf5, 0x70, + 0x54, 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, + 0x84, 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, + 0xa5, 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, + 0xa3, 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, + 0x96, 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, + 0x25, 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, + 0xaf, 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, + 0x1e, 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, + 0x5e, 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, 0xb0, 0x18, 0x8f, 0xf7, + 0x7c, 0x0b, 0xf1, 0x80, 0xc1, 0x32, 0x2c, 0xc2, 0x13, 0x06, 0x8f, 0x18, + 0x2c, 0xc4, 0x33, 0x06, 0x0b, 0xf1, 0x38, 0xcf, 0xf3, 0x54, 0x0f, 0x19, + 0x70, 0x09, 0x4b, 0x93, 0x73, 0xa1, 0x2b, 0xc3, 0xa3, 0xab, 0x93, 0x2b, + 0xa3, 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, 0x46, + 0x8c, 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, 0x4c, 0x86, 0x8c, 0xc7, 0x8c, + 0xed, 0x2d, 0x8c, 0x8e, 0x05, 0x64, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0xcc, + 0x87, 0x03, 0x5d, 0x19, 0xde, 0x10, 0x6a, 0x39, 0x1e, 0x33, 0x78, 0xc0, + 0x60, 0x19, 0x16, 0xe1, 0x39, 0x83, 0xc7, 0x79, 0xd0, 0xe0, 0xa9, 0x9e, + 0x34, 0xe0, 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, + 0x26, 0xc7, 0x63, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, + 0x10, 0x69, 0x41, 0x9e, 0x35, 0x78, 0xc0, 0x60, 0x19, 0x16, 0xe1, 0x71, + 0x1e, 0x36, 0x78, 0xaa, 0xa7, 0x0d, 0x86, 0x28, 0xcf, 0xf5, 0x74, 0x4f, + 0x19, 0x3c, 0x6a, 0xf0, 0xb8, 0xc1, 0x10, 0x23, 0x01, 0x9e, 0xe8, 0x79, + 0x03, 0x3e, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, + 0x20, 0x63, 0x68, 0x61, 0x72, 0x7c, 0xa6, 0xd2, 0xda, 0xe0, 0xd8, 0xca, + 0x40, 0x86, 0x56, 0x56, 0x40, 0xa8, 0x84, 0x82, 0x82, 0x86, 0x08, 0x8f, + 0x1c, 0x0c, 0x31, 0x9e, 0x38, 0x78, 0xe6, 0x00, 0x4a, 0x86, 0x18, 0x0f, + 0x1d, 0x3c, 0x74, 0x00, 0x25, 0x23, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x48, 0x07, 0x72, 0x28, 0x07, 0x77, 0xa0, 0x87, 0x29, 0x41, + 0x30, 0x62, 0x09, 0x87, 0x74, 0x90, 0x07, 0x37, 0xb0, 0x87, 0x72, 0x90, + 0x87, 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x81, 0x30, 0x82, 0x0a, + 0x87, 0x74, 0x90, 0x07, 0x37, 0x60, 0x87, 0x70, 0x70, 0x87, 0x73, 0xa8, + 0x87, 0x70, 0x38, 0x87, 0x72, 0xf8, 0x05, 0x7b, 0x28, 0x07, 0x79, 0x98, + 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x12, 0x10, 0x23, 0xa6, 0x70, 0x48, + 0x07, 0x79, 0x70, 0x83, 0x71, 0x78, 0x87, 0x76, 0x80, 0x87, 0x74, 0x60, + 0x87, 0x72, 0xf8, 0x85, 0x77, 0x80, 0x07, 0x7a, 0x48, 0x87, 0x77, 0x70, + 0x87, 0x79, 0x98, 0x42, 0x18, 0x88, 0xc2, 0x8c, 0x60, 0xc2, 0x21, 0x1d, + 0xe4, 0xc1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xe1, 0x1c, 0xda, 0xa1, 0x1c, + 0xdc, 0x81, 0x1e, 0xa6, 0x04, 0x70, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, + 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, + 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, 0xe4, 0x90, + 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, + 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, + 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, + 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, 0x50, 0x24, + 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, + 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x10, 0xb1, 0x5d, + 0xf9, 0x73, 0xce, 0x83, 0xfd, 0x45, 0x04, 0x18, 0x0c, 0xd1, 0x4c, 0x16, + 0xb0, 0x01, 0x48, 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, 0xd7, + 0x44, 0x45, 0xc4, 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x0d, 0x00, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc4, 0x46, 0x00, 0x48, + 0xd5, 0xc0, 0x08, 0x00, 0x81, 0x11, 0x00, 0x00, 0x23, 0x06, 0x8a, 0x10, + 0x48, 0x46, 0x81, 0x0c, 0x84, 0x10, 0x10, 0x52, 0x2c, 0x10, 0xe4, 0x93, + 0x41, 0x40, 0x0c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x20, 0xa8, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x74, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x9a, 0x03, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x49, 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, + 0x23, 0xc4, 0x52, 0x80, 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, + 0x11, 0x62, 0xa8, 0xa0, 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x18, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, + 0x16, 0xa0, 0xda, 0x60, 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, + 0x80, 0x05, 0xa8, 0x36, 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xc0, 0x00, 0x12, 0x31, 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, + 0x40, 0x0f, 0xec, 0x90, 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, + 0x40, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, + 0x40, 0x0e, 0xe5, 0xd0, 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, + 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, + 0x3c, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, + 0x3a, 0xb0, 0x43, 0x1b, 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, + 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, + 0x30, 0x0f, 0xf3, 0xd0, 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, + 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, + 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, + 0x3b, 0xa4, 0x43, 0x3b, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, + 0xe0, 0x0e, 0xef, 0xd0, 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, + 0xd0, 0x06, 0xf0, 0xf0, 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xe5, 0xc0, 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, + 0xe0, 0x0e, 0x6d, 0xc0, 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, + 0xf0, 0x0e, 0x6d, 0x90, 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, + 0x00, 0x0f, 0x6d, 0xd0, 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, + 0x3c, 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, + 0x3d, 0xb4, 0x03, 0x3c, 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, + 0x39, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, + 0xe1, 0x0e, 0xef, 0xd0, 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, + 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, + 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, + 0x3c, 0xa4, 0xc3, 0x39, 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, + 0x39, 0xc8, 0xc3, 0x3b, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, + 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, + 0x00, 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, + 0x20, 0x0f, 0x6d, 0x20, 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, + 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, + 0x3d, 0x84, 0x83, 0x3c, 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, + 0x39, 0x84, 0x03, 0x3d, 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, + 0x60, 0x0e, 0xf0, 0x10, 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, + 0x10, 0x0e, 0xe6, 0x50, 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, + 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, + 0x40, 0xd4, 0xc3, 0x3c, 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, + 0x3d, 0xb4, 0x81, 0x39, 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, + 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, + 0xff, 0xff, 0xff, 0x07, 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, + 0xc6, 0x81, 0x1e, 0xd8, 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, + 0xdc, 0x81, 0x1c, 0xca, 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, + 0xd2, 0x81, 0x1c, 0xca, 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, + 0x87, 0x79, 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, + 0x87, 0x74, 0x60, 0x87, 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, + 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, + 0xca, 0x61, 0x1e, 0xe6, 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, + 0xd2, 0x61, 0x1e, 0xca, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, + 0xc8, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, + 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, + 0x87, 0x77, 0x48, 0x07, 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, + 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, + 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, + 0xe4, 0xa1, 0x0d, 0xca, 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, + 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, + 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, + 0x07, 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, + 0x87, 0x70, 0x70, 0x87, 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, + 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, + 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, + 0xca, 0x81, 0x1c, 0xda, 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, + 0xda, 0xc0, 0x1c, 0xe0, 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, + 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, + 0x87, 0x70, 0x18, 0x87, 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, + 0x87, 0x72, 0x18, 0x07, 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, + 0x07, 0x73, 0x30, 0x87, 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, + 0x87, 0x72, 0x00, 0xf0, 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, + 0xca, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, + 0xe4, 0xa1, 0x1c, 0xe6, 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, + 0x03, 0x80, 0xa8, 0x07, 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, + 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, + 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, + 0xda, 0x60, 0x1e, 0xde, 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, + 0xde, 0x21, 0x1c, 0xe8, 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, + 0x07, 0x60, 0x03, 0x61, 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, + 0x80, 0x20, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, + 0x06, 0x22, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, + 0x88, 0x09, 0x41, 0x31, 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, + 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, + 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, + 0x10, 0x78, 0x33, 0x00, 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, + 0x08, 0x81, 0x30, 0x8c, 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, + 0x2f, 0xbb, 0x6f, 0x47, 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, + 0x11, 0x0a, 0xe1, 0x28, 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, + 0x26, 0x2a, 0x22, 0x7e, 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, + 0x08, 0x4e, 0x93, 0xa6, 0x88, 0x12, 0x26, 0xff, 0x9f, 0x88, 0x6b, 0xa2, + 0x22, 0xe2, 0xb7, 0x87, 0x1f, 0x88, 0x22, 0x00, 0xfb, 0xa7, 0x31, 0x02, + 0x60, 0x10, 0x21, 0x09, 0x2e, 0x92, 0xa6, 0x88, 0x12, 0x26, 0xff, 0x97, + 0x00, 0xe6, 0x59, 0x88, 0xe8, 0x9f, 0xc6, 0x08, 0x80, 0x41, 0x84, 0x45, + 0x28, 0x48, 0x08, 0x62, 0x18, 0xa4, 0x18, 0xb5, 0x32, 0x00, 0x42, 0xe8, + 0xcd, 0x11, 0x80, 0xc1, 0x1c, 0x41, 0x30, 0x8c, 0x20, 0x44, 0x25, 0x09, + 0x8a, 0x89, 0x28, 0xa7, 0x04, 0x44, 0x0b, 0x12, 0x10, 0x13, 0x72, 0x4a, + 0x40, 0x76, 0x20, 0x60, 0x18, 0x61, 0x88, 0x86, 0x11, 0x88, 0x68, 0x8e, + 0x00, 0x14, 0x06, 0x11, 0x08, 0x61, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x13, 0xb2, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, + 0x80, 0x07, 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, + 0x78, 0x87, 0x79, 0xc0, 0x87, 0x38, 0x80, 0x03, 0x37, 0x88, 0x83, 0x38, + 0x70, 0x03, 0x38, 0xd8, 0xf0, 0x1e, 0xe5, 0xd0, 0x06, 0xf0, 0xa0, 0x07, + 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, + 0xe9, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, + 0x6d, 0x90, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, + 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, + 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, + 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x60, 0x07, + 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, + 0x72, 0x40, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x6d, 0x60, 0x0f, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x74, 0x80, 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, + 0x79, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, + 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, + 0xf6, 0x10, 0x07, 0x79, 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, + 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, + 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, + 0x76, 0xd0, 0x06, 0xf6, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, + 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, + 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, + 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, 0x07, 0x6d, 0x60, 0x0e, + 0x78, 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, + 0x72, 0x80, 0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, + 0x7a, 0x30, 0x07, 0x72, 0x30, 0x84, 0x71, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0xc2, 0x40, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x61, 0x2a, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x86, 0x30, 0x17, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x59, 0x20, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x8a, + 0x23, 0x00, 0x25, 0x50, 0x20, 0x05, 0x18, 0x50, 0x10, 0x45, 0x50, 0x06, + 0x05, 0x54, 0x60, 0x85, 0x50, 0x0a, 0xc5, 0x40, 0x7b, 0x04, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x15, 0x01, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, + 0xd7, 0x20, 0x08, 0x0e, 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, + 0xc4, 0xae, 0x4c, 0x6e, 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, + 0x25, 0x06, 0x04, 0xa5, 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, + 0x07, 0x46, 0xc6, 0x25, 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x80, 0x01, + 0x43, 0x8c, 0xa8, 0x88, 0x90, 0x88, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, + 0x36, 0x04, 0xc1, 0x86, 0xa8, 0x88, 0x8a, 0x88, 0xe0, 0x16, 0x96, 0x26, + 0xe7, 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, + 0xf6, 0x26, 0xd7, 0x36, 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, + 0x36, 0x44, 0xc0, 0x0a, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, + 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x04, 0xec, + 0x60, 0x19, 0x84, 0xa5, 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, + 0x95, 0xb9, 0x98, 0xc9, 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, + 0xc9, 0x7d, 0x99, 0x95, 0xd1, 0x8d, 0xa1, 0x7d, 0x91, 0xa5, 0xcd, 0x85, + 0x89, 0xb1, 0x95, 0x0d, 0x11, 0xb0, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, + 0x32, 0xf6, 0xd6, 0x06, 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, + 0x66, 0x57, 0xf6, 0x45, 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, + 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xc0, 0x16, 0x46, 0x61, 0x69, + 0x72, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x8c, 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, + 0xe8, 0xf2, 0xe0, 0xca, 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, + 0xbd, 0x85, 0xd1, 0xd1, 0x0c, 0x41, 0xb0, 0x26, 0x22, 0x30, 0x07, 0x7b, + 0x86, 0x08, 0x18, 0x44, 0x26, 0x2c, 0x4d, 0xce, 0x05, 0xee, 0x6d, 0x2e, + 0x8d, 0x2e, 0xed, 0xcd, 0x8d, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x58, 0x99, + 0x1b, 0x5d, 0x99, 0x1c, 0xa5, 0xb0, 0x34, 0x39, 0x17, 0xb7, 0xb7, 0x2f, + 0xb8, 0x32, 0xb9, 0x39, 0xb8, 0xb2, 0x31, 0xba, 0x34, 0xbb, 0x32, 0x32, + 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x44, 0xe0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, 0x86, 0x40, 0x11, + 0x81, 0x49, 0xd8, 0x84, 0x51, 0x98, 0x83, 0x3d, 0x58, 0x85, 0x59, 0x94, + 0xc2, 0xd2, 0xe4, 0x5c, 0xcc, 0xe4, 0xc2, 0xce, 0xda, 0xca, 0xdc, 0xe8, + 0xbe, 0xd2, 0xdc, 0xe0, 0xea, 0xe8, 0x98, 0x9d, 0x95, 0xb9, 0x95, 0xc9, + 0x85, 0xd1, 0x95, 0x91, 0xa1, 0xe0, 0xd0, 0x95, 0xe1, 0x8d, 0xbd, 0xbd, + 0xc9, 0x91, 0x11, 0xd9, 0xc9, 0x7c, 0x99, 0xa5, 0xf0, 0x09, 0x4b, 0x93, + 0x73, 0x81, 0x2b, 0x93, 0x9b, 0x83, 0x2b, 0x1b, 0xa3, 0x4b, 0xb3, 0x2b, + 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x27, 0x43, 0x84, 0xae, 0x0c, 0x6f, + 0xec, 0xed, 0x4d, 0x8e, 0x6c, 0x88, 0x14, 0x15, 0x18, 0x86, 0x65, 0xd8, + 0x84, 0x69, 0x98, 0x83, 0x6d, 0x58, 0x85, 0x71, 0x54, 0xc2, 0xd2, 0xe4, + 0x5c, 0xc4, 0xea, 0xcc, 0xcc, 0xca, 0xe4, 0xf8, 0x84, 0xa5, 0xc9, 0xb9, + 0x88, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0xcd, 0xa5, 0xe9, 0x95, 0x51, + 0x0a, 0x4b, 0x93, 0x73, 0x61, 0x7b, 0x1b, 0x0b, 0xa3, 0x4b, 0x7b, 0x73, + 0xfb, 0x4a, 0x73, 0x23, 0x2b, 0xc3, 0x23, 0x12, 0x96, 0x26, 0xe7, 0x22, + 0x57, 0x16, 0x46, 0xc6, 0x28, 0x2c, 0x4d, 0xce, 0x25, 0x4c, 0xee, 0xec, + 0x8b, 0x2e, 0x0f, 0xae, 0xec, 0x6b, 0x2e, 0x4d, 0xaf, 0x8c, 0x57, 0x58, + 0x9a, 0x9c, 0x4b, 0x98, 0xdc, 0xd9, 0x17, 0x5d, 0x1e, 0x5c, 0xd9, 0x57, + 0x18, 0x5b, 0xda, 0x99, 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0x87, 0xb1, + 0x37, 0xb6, 0x21, 0x60, 0x10, 0x25, 0x98, 0x87, 0x7d, 0x91, 0x81, 0x81, + 0x41, 0x44, 0x44, 0x05, 0x16, 0x06, 0x98, 0x18, 0x44, 0x06, 0x36, 0x06, + 0x91, 0x81, 0x39, 0xd8, 0x83, 0x55, 0x18, 0x19, 0x90, 0x0a, 0x4b, 0x93, + 0x73, 0x99, 0xa3, 0x93, 0xab, 0x1b, 0xa3, 0xfb, 0xa2, 0xcb, 0x83, 0x2b, + 0xfb, 0x4a, 0x73, 0x33, 0x7b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x37, + 0x43, 0xe3, 0xcd, 0xcc, 0x6c, 0xae, 0x8c, 0x8e, 0x86, 0xd4, 0xd8, 0x5b, + 0x99, 0x99, 0x19, 0x8d, 0xa3, 0xb1, 0xb7, 0x32, 0x33, 0x33, 0x1a, 0x42, + 0x63, 0x6f, 0x65, 0x66, 0x66, 0x43, 0xd0, 0x20, 0x22, 0x22, 0x23, 0x22, + 0xb0, 0x33, 0xc0, 0xd0, 0x20, 0x32, 0x22, 0x23, 0x22, 0xb0, 0x33, 0xc0, + 0xd2, 0x20, 0x5a, 0x22, 0x23, 0x22, 0xb0, 0x33, 0xc0, 0xd4, 0x20, 0x62, + 0x22, 0x23, 0x22, 0xb0, 0x33, 0xc0, 0xd6, 0x80, 0x49, 0x56, 0x95, 0x15, + 0x51, 0xd9, 0xd8, 0x1b, 0x59, 0x19, 0x0d, 0xb2, 0xb2, 0xb1, 0x37, 0xb2, + 0xb2, 0x21, 0x64, 0x10, 0x29, 0x98, 0x87, 0x7d, 0xd1, 0x81, 0x81, 0x41, + 0x54, 0x44, 0x05, 0x16, 0x06, 0x98, 0x19, 0x60, 0x6c, 0x80, 0x89, 0x41, + 0x74, 0x60, 0x63, 0x10, 0x19, 0x98, 0x83, 0xb5, 0x01, 0x56, 0x61, 0x6e, + 0xc0, 0x25, 0x2c, 0x4d, 0xce, 0x85, 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, + 0x8c, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x19, + 0x31, 0xba, 0x32, 0x3c, 0xba, 0x3a, 0xb9, 0x32, 0x19, 0x32, 0x1e, 0x33, + 0xb6, 0xb7, 0x30, 0x3a, 0x16, 0x90, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, + 0x1f, 0x12, 0x74, 0x65, 0x78, 0x59, 0x43, 0xa8, 0xa8, 0xc1, 0xe0, 0x00, + 0x03, 0x83, 0x88, 0x88, 0x0a, 0x2c, 0x0e, 0x30, 0x07, 0x93, 0x03, 0xac, + 0xc2, 0xe6, 0x80, 0x1e, 0x5d, 0x19, 0x1e, 0x5d, 0x9d, 0x5c, 0x99, 0x0c, + 0xd9, 0x57, 0x98, 0x9c, 0x5c, 0x58, 0x1e, 0x8f, 0x19, 0xdb, 0x5b, 0x18, + 0x1d, 0x0b, 0xc8, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x99, 0x0f, 0x0b, 0xba, + 0x32, 0xbc, 0x2a, 0xab, 0x21, 0x54, 0xe4, 0x60, 0x70, 0x80, 0x81, 0x41, + 0x54, 0x44, 0x05, 0x16, 0x07, 0x98, 0x83, 0xd5, 0x01, 0x56, 0x61, 0x76, + 0xc0, 0x25, 0x2c, 0x4d, 0xce, 0x65, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, + 0x8e, 0xc7, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x99, 0x1c, 0x83, 0xb9, 0x21, + 0x52, 0xf4, 0x60, 0x78, 0x80, 0x81, 0x41, 0x44, 0x44, 0x05, 0xe6, 0x60, + 0x79, 0x80, 0x55, 0x98, 0x1e, 0x0c, 0x71, 0xb0, 0x0b, 0xeb, 0xb0, 0x32, + 0xc0, 0xde, 0x00, 0xa3, 0x03, 0xec, 0x0e, 0xb0, 0x3d, 0x18, 0x62, 0x38, + 0x00, 0x16, 0x61, 0x7c, 0xc0, 0xe7, 0xad, 0xcd, 0x2d, 0x0d, 0xee, 0x8d, + 0xae, 0xcc, 0x8d, 0x0e, 0x64, 0x0c, 0x2d, 0x4c, 0x8e, 0xcf, 0x54, 0x5a, + 0x1b, 0x1c, 0x5b, 0x19, 0xc8, 0xd0, 0xca, 0x0a, 0x08, 0x95, 0x50, 0x50, + 0xd0, 0x10, 0x01, 0xfb, 0x83, 0x21, 0x06, 0xe6, 0x07, 0x18, 0x28, 0x6c, + 0xd0, 0x10, 0x03, 0x0b, 0x05, 0x2c, 0x14, 0x36, 0x68, 0x84, 0xc2, 0x0e, + 0xec, 0x60, 0x0f, 0xed, 0xe0, 0x06, 0xe9, 0x40, 0x0e, 0xe5, 0xe0, 0x0e, + 0xf4, 0x30, 0x25, 0x08, 0x46, 0x2c, 0xe1, 0x90, 0x0e, 0xf2, 0xe0, 0x06, + 0xf6, 0x50, 0x0e, 0xf2, 0x30, 0x0f, 0xe9, 0xf0, 0x0e, 0xee, 0x30, 0x25, + 0x10, 0x46, 0x50, 0xe1, 0x90, 0x0e, 0xf2, 0xe0, 0x06, 0xec, 0x10, 0x0e, + 0xee, 0x70, 0x0e, 0xf5, 0x10, 0x0e, 0xe7, 0x50, 0x0e, 0xbf, 0x60, 0x0f, + 0xe5, 0x20, 0x0f, 0xf3, 0x90, 0x0e, 0xef, 0xe0, 0x0e, 0x53, 0x02, 0x62, + 0xc4, 0x14, 0x0e, 0xe9, 0x20, 0x0f, 0x6e, 0x30, 0x0e, 0xef, 0xd0, 0x0e, + 0xf0, 0x90, 0x0e, 0xec, 0x50, 0x0e, 0xbf, 0xf0, 0x0e, 0xf0, 0x40, 0x0f, + 0xe9, 0xf0, 0x0e, 0xee, 0x30, 0x0f, 0x53, 0x08, 0x03, 0x51, 0x98, 0x11, + 0x4c, 0x38, 0xa4, 0x83, 0x3c, 0xb8, 0x81, 0x39, 0xc8, 0x43, 0x38, 0x9c, + 0x43, 0x3b, 0x94, 0x83, 0x3b, 0xd0, 0xc3, 0x94, 0xa0, 0x0f, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, + 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, + 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, + 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, + 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, + 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, + 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, + 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, + 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, + 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x26, 0x10, 0x06, 0x00, 0x12, 0xf9, 0x12, 0xc0, 0x3c, 0x0b, 0xf1, 0x4f, + 0xc4, 0x35, 0x51, 0x11, 0xf1, 0xdb, 0xc3, 0x0f, 0x44, 0x11, 0x80, 0xf9, + 0x15, 0x5e, 0xdc, 0xb6, 0x05, 0x34, 0x00, 0x12, 0xf9, 0x83, 0x33, 0xf9, + 0xd5, 0x5d, 0xdc, 0xb6, 0x0d, 0x6c, 0x00, 0x12, 0xf9, 0x12, 0xc0, 0x3c, + 0x0b, 0xf1, 0x4f, 0xc4, 0x35, 0x51, 0x11, 0xf1, 0xdb, 0x83, 0x5f, 0xe1, + 0xc5, 0x6d, 0x1b, 0x00, 0xc4, 0x76, 0xe5, 0x2f, 0xbb, 0xef, 0x5f, 0x44, + 0x80, 0xc1, 0x10, 0xcd, 0x04, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa4, 0xe7, 0x20, 0x88, 0x22, 0xe1, 0x28, 0xcf, + 0x31, 0x10, 0x1c, 0x37, 0xd6, 0x00, 0x04, 0x02, 0xcd, 0x11, 0x00, 0x8a, + 0x33, 0x00, 0x24, 0x6b, 0x60, 0x04, 0x80, 0xc8, 0x0c, 0x00, 0x85, 0x19, + 0x00, 0x02, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf8, 0x37, 0x02, 0x00, 0x00, + 0x23, 0x06, 0xca, 0x10, 0x80, 0x81, 0xc3, 0x44, 0x06, 0x52, 0x04, 0x23, + 0x06, 0xcb, 0x10, 0x88, 0x81, 0xd3, 0x48, 0x60, 0x70, 0x24, 0x86, 0x30, + 0x86, 0x10, 0x84, 0xc1, 0x20, 0xc3, 0x60, 0x34, 0x73, 0x0c, 0x81, 0x20, + 0x06, 0x23, 0x06, 0xcb, 0x10, 0x98, 0x81, 0x14, 0x59, 0x63, 0xb0, 0x34, + 0x8a, 0x31, 0x86, 0x10, 0x94, 0xc1, 0x1c, 0xc3, 0x10, 0x84, 0xc1, 0x20, + 0x43, 0xc0, 0x4c, 0x87, 0x8d, 0xa5, 0xa0, 0xd8, 0x10, 0xc0, 0x87, 0xb8, + 0x32, 0xc8, 0x20, 0x40, 0xd6, 0x78, 0x43, 0x17, 0x06, 0x6c, 0x70, 0xc1, + 0x58, 0x0a, 0xca, 0x20, 0x43, 0x40, 0x69, 0x23, 0x06, 0x05, 0x11, 0xd0, + 0x41, 0x11, 0xcc, 0x31, 0x58, 0x81, 0x1c, 0x8c, 0x37, 0x8c, 0xc1, 0x19, + 0xb8, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, 0x81, 0x06, 0x06, 0x23, + 0x06, 0x05, 0x11, 0xe8, 0xc1, 0x12, 0xcc, 0x31, 0x18, 0xc1, 0x1d, 0x8c, + 0x37, 0xa4, 0x41, 0x1b, 0xcc, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, + 0x01, 0x18, 0x98, 0xc1, 0x88, 0x41, 0x41, 0x04, 0xa0, 0x10, 0x05, 0x73, + 0x0c, 0x46, 0x90, 0x07, 0x73, 0x0c, 0x81, 0x18, 0xe4, 0x81, 0x05, 0x95, + 0x7c, 0x32, 0x08, 0x88, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x5b, 0x06, 0x26, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0xf8, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x7b, 0x03, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, + 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, + 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, + 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, + 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, + 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, 0x16, 0xa0, 0xda, 0x60, + 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, 0x80, 0x05, 0xa8, 0x36, + 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0x00, 0x12, 0x31, + 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xec, 0x90, + 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, 0x40, 0x0e, 0xe5, 0x40, + 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, 0x40, 0x0e, 0xe5, 0xd0, + 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, 0x39, 0x84, 0x03, 0x3b, + 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, 0x3c, 0x84, 0x83, 0x38, + 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, 0x3a, 0xb0, 0x43, 0x1b, + 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, + 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, 0x30, 0x0f, 0xf3, 0xd0, + 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, 0x30, 0x0f, 0xe5, 0xd0, + 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, 0x00, 0xd0, 0x83, 0x3c, + 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, + 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, 0x3b, 0xa4, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, + 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, 0xe0, 0x0e, 0xef, 0xd0, + 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, 0xd0, 0x06, 0xf0, 0xf0, + 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xe5, 0xc0, + 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, 0xe0, 0x0e, 0x6d, 0xc0, + 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x90, + 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0x6d, 0xd0, + 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, + 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, 0x3d, 0xb4, 0x03, 0x3c, + 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xcc, 0x03, 0x60, + 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, + 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, + 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, 0x3c, 0xa4, 0xc3, 0x39, + 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, 0x39, 0xc8, 0xc3, 0x3b, + 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, + 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0x31, + 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, 0x00, 0x0f, 0xf2, 0xf0, + 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, 0x20, 0x0f, 0x6d, 0x20, + 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xf3, 0x90, + 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, 0x3d, 0x84, 0x83, 0x3c, + 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, 0x39, 0x84, 0x03, 0x3d, + 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, 0x60, 0x0e, 0xf0, 0x10, + 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, 0x10, 0x0e, 0xe6, 0x50, + 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, + 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xd4, 0xc3, 0x3c, + 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, 0x3d, 0xb4, 0x81, 0x39, + 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, 0x10, 0x0e, 0xec, 0x30, + 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xd8, + 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, 0xdc, 0x81, 0x1c, 0xca, + 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, 0xd2, 0x81, 0x1c, 0xca, + 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, 0x87, 0x79, 0x08, 0x07, + 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, 0x87, 0x74, 0x60, 0x87, + 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, 0x07, 0xc0, 0x1c, 0xc2, + 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, 0xca, 0x61, 0x1e, 0xe6, + 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xd2, 0x61, 0x1e, 0xca, + 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, 0xc8, 0x01, 0xa0, 0x07, + 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x30, 0x07, + 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, + 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, + 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, + 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, 0xca, 0xa1, 0x0d, 0xe0, + 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, + 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, + 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, + 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, + 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, + 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, 0x87, 0x70, 0x70, 0x87, + 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, + 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, + 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, 0xda, + 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, 0x87, 0x70, 0x18, 0x87, + 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, 0x87, 0x72, 0x18, 0x07, + 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, 0x07, 0x73, 0x30, 0x87, + 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, 0x87, 0x72, 0x00, 0xf0, + 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, 0xca, 0x81, 0x1e, 0xda, + 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, 0xe4, 0xa1, 0x1c, 0xe6, + 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, 0x03, 0x80, 0xa8, 0x07, + 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, 0x03, 0x73, 0x80, 0x87, + 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, + 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xde, + 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, 0xde, 0x21, 0x1c, 0xe8, + 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, 0x07, 0x60, 0x03, 0x61, + 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, 0x80, 0x20, 0xff, 0xff, + 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, 0x06, 0x22, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, 0x88, 0x09, 0x41, 0x31, + 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, + 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x68, 0x33, 0x00, + 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, 0x08, 0x81, 0x30, 0x8c, + 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, 0x2f, 0xbb, 0x6f, 0x47, + 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, 0x11, 0x0a, 0xe1, 0x28, + 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, 0x26, 0x2a, 0x22, 0x7e, + 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, 0x08, 0x2e, 0x92, 0xa6, + 0x88, 0x12, 0x26, 0xff, 0x97, 0x00, 0xe6, 0x59, 0x88, 0xe8, 0x9f, 0xc6, + 0x08, 0x80, 0x41, 0x84, 0x44, 0x28, 0x48, 0x08, 0x62, 0x18, 0x84, 0x14, + 0xad, 0x32, 0x00, 0x42, 0xa8, 0xcd, 0x11, 0x04, 0x73, 0x04, 0x60, 0x30, + 0x8c, 0x20, 0x40, 0x05, 0x09, 0x48, 0x89, 0x17, 0x1f, 0x20, 0x39, 0x10, + 0x30, 0x8c, 0x30, 0x40, 0xc3, 0x08, 0x04, 0x34, 0x47, 0x00, 0x0a, 0x83, + 0x08, 0x84, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, + 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, + 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, + 0x87, 0x38, 0x80, 0x03, 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, + 0xf0, 0x1e, 0xe5, 0xd0, 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, + 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, + 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, + 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0f, 0x74, 0x80, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0x60, 0x0f, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, + 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, + 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, + 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, + 0x00, 0x07, 0x72, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0x30, 0x84, 0x61, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0xc2, 0x38, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x61, + 0x26, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb2, 0x40, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x82, 0x23, 0x00, 0x25, 0x50, + 0x20, 0x05, 0x18, 0x50, 0x10, 0x45, 0x50, 0x06, 0x05, 0x54, 0x60, 0x85, + 0x50, 0x0a, 0xc5, 0x40, 0x77, 0x04, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x0d, 0x01, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, + 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, + 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, + 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, + 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x40, 0x01, 0x43, 0x0c, 0x88, 0x80, + 0x0e, 0x68, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0xa1, 0x06, + 0x88, 0x80, 0x08, 0x68, 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, + 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, + 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x0a, + 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x04, 0xea, 0x60, 0x19, 0x84, 0xa5, + 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, + 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, + 0xd1, 0x8d, 0xa1, 0x7d, 0x91, 0xa5, 0xcd, 0x85, 0x89, 0xb1, 0x95, 0x0d, + 0x11, 0xa8, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, + 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, + 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, + 0x56, 0x36, 0x44, 0xa0, 0x16, 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, + 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, + 0x0c, 0x41, 0xa8, 0x06, 0x1a, 0x28, 0x87, 0x7a, 0x86, 0x08, 0x14, 0x44, + 0x26, 0x2c, 0x4d, 0xce, 0x05, 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, + 0x8d, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, + 0xa5, 0xb0, 0x34, 0x39, 0x17, 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, + 0xb8, 0xb2, 0x31, 0xba, 0x34, 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, + 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, + 0xd2, 0xe8, 0xd2, 0xde, 0xdc, 0x86, 0x40, 0xd0, 0x40, 0x49, 0xd4, 0x44, + 0x51, 0x94, 0x43, 0x3d, 0x54, 0x45, 0x59, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, + 0xcc, 0xe4, 0xc2, 0xce, 0xda, 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, + 0xea, 0xe8, 0x98, 0x9d, 0x95, 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, + 0xa1, 0xe0, 0xd0, 0x95, 0xe1, 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, + 0xc9, 0x7c, 0x99, 0xa5, 0xf0, 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, + 0x9b, 0x83, 0x2b, 0x1b, 0xa3, 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, + 0x16, 0x46, 0x27, 0x43, 0x84, 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, + 0x6c, 0x88, 0x04, 0x11, 0x14, 0x46, 0x65, 0xd4, 0x44, 0x69, 0x94, 0x43, + 0x6d, 0x54, 0x45, 0x71, 0x54, 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, + 0xcc, 0xca, 0xe4, 0xf8, 0x84, 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, + 0x95, 0xc9, 0x7d, 0xcd, 0xa5, 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, + 0x61, 0x7b, 0x1b, 0x0b, 0xa3, 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, + 0x2b, 0xc3, 0x23, 0x12, 0x96, 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, + 0x28, 0x2c, 0x4d, 0xce, 0x25, 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, + 0xec, 0x6b, 0x2e, 0x4d, 0xaf, 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, + 0xdc, 0xd9, 0x17, 0x5d, 0x1e, 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, + 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, + 0x00, 0x21, 0x94, 0x47, 0x7d, 0x50, 0x41, 0x81, 0x01, 0x34, 0x40, 0x04, + 0x15, 0x06, 0x94, 0x18, 0x40, 0x05, 0x35, 0x06, 0x50, 0x41, 0x39, 0xd4, + 0x43, 0x55, 0x14, 0x19, 0x90, 0x0a, 0x4b, 0x93, 0x73, 0x99, 0xa3, 0x93, + 0xab, 0x1b, 0xa3, 0xfb, 0xa2, 0xcb, 0x83, 0x2b, 0xfb, 0x4a, 0x73, 0x33, + 0x7b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x37, 0x43, 0xe3, 0xcd, 0xcc, + 0x6c, 0xae, 0x8c, 0x8e, 0x86, 0xd4, 0xd8, 0x5b, 0x99, 0x99, 0x19, 0x8d, + 0xa3, 0xb1, 0xb7, 0x32, 0x33, 0x33, 0x1a, 0x42, 0x63, 0x6f, 0x65, 0x66, + 0x66, 0x43, 0xd0, 0x00, 0x1a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd0, + 0x00, 0x2a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd2, 0x00, 0x52, 0xa0, + 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd4, 0x00, 0x5a, 0xa0, 0x02, 0x1a, 0xa8, + 0x33, 0xa0, 0xd6, 0x80, 0x49, 0x56, 0x95, 0x15, 0x51, 0xd9, 0xd8, 0x1b, + 0x59, 0x19, 0x0d, 0xb2, 0xb2, 0xb1, 0x37, 0xb2, 0xb2, 0x21, 0x64, 0x00, + 0x25, 0x94, 0x47, 0x7d, 0x90, 0x41, 0x81, 0x01, 0x44, 0x40, 0x04, 0x15, + 0x06, 0x94, 0x19, 0x50, 0x6c, 0x40, 0x89, 0x01, 0x64, 0x50, 0x63, 0x00, + 0x15, 0x94, 0x43, 0xb5, 0x01, 0x55, 0x51, 0x6e, 0xc0, 0x25, 0x2c, 0x4d, + 0xce, 0x85, 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, 0x8c, 0x4a, 0x58, 0x9a, + 0x9c, 0xcb, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x19, 0x31, 0xba, 0x32, 0x3c, + 0xba, 0x3a, 0xb9, 0x32, 0x19, 0x32, 0x1e, 0x33, 0xb6, 0xb7, 0x30, 0x3a, + 0x16, 0x90, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, 0x1f, 0x12, 0x74, 0x65, + 0x78, 0x59, 0x43, 0x28, 0x88, 0xa1, 0xe0, 0x80, 0x02, 0x03, 0x68, 0x80, + 0x08, 0x2a, 0x0e, 0x28, 0x87, 0x92, 0x03, 0xaa, 0xa2, 0xe6, 0x80, 0x05, + 0x5d, 0x19, 0x5e, 0x95, 0xd5, 0x10, 0x0a, 0x6a, 0x28, 0x38, 0xa0, 0xc0, + 0x00, 0x22, 0x20, 0x82, 0x8a, 0x03, 0xca, 0xa1, 0xe4, 0x80, 0xaa, 0xa8, + 0x3a, 0xe0, 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, + 0x26, 0xc7, 0x63, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, + 0x10, 0x09, 0x72, 0xa8, 0x3b, 0xa0, 0xc0, 0x00, 0x1a, 0x20, 0x82, 0x72, + 0x28, 0x3c, 0xa0, 0x2a, 0x2a, 0x0f, 0x86, 0x38, 0xd4, 0x45, 0x75, 0x54, + 0x19, 0x50, 0x6f, 0x40, 0xd1, 0x01, 0x65, 0x07, 0x94, 0x1e, 0x0c, 0x31, + 0x18, 0x80, 0x8a, 0xa8, 0x3d, 0xe0, 0xf3, 0xd6, 0xe6, 0x96, 0x06, 0xf7, + 0x46, 0x57, 0xe6, 0x46, 0x07, 0x32, 0x86, 0x16, 0x26, 0xc7, 0x67, 0x2a, + 0xad, 0x0d, 0x8e, 0xad, 0x0c, 0x64, 0x68, 0x65, 0x05, 0x84, 0x4a, 0x28, + 0x28, 0x68, 0x88, 0x40, 0xf9, 0xc1, 0x10, 0x83, 0xea, 0x03, 0xea, 0x0f, + 0xae, 0x67, 0x88, 0x41, 0x81, 0x02, 0x05, 0x0a, 0xd7, 0x33, 0x42, 0x61, + 0x07, 0x76, 0xb0, 0x87, 0x76, 0x70, 0x83, 0x74, 0x20, 0x87, 0x72, 0x70, + 0x07, 0x7a, 0x98, 0x12, 0x04, 0x23, 0x96, 0x70, 0x48, 0x07, 0x79, 0x70, + 0x03, 0x7b, 0x28, 0x07, 0x79, 0x98, 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, + 0x12, 0x08, 0x23, 0xa8, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x76, 0x08, + 0x07, 0x77, 0x38, 0x87, 0x7a, 0x08, 0x87, 0x73, 0x28, 0x87, 0x5f, 0xb0, + 0x87, 0x72, 0x90, 0x87, 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x01, + 0x31, 0x62, 0x0a, 0x87, 0x74, 0x90, 0x07, 0x37, 0x18, 0x87, 0x77, 0x68, + 0x07, 0x78, 0x48, 0x07, 0x76, 0x28, 0x87, 0x5f, 0x78, 0x07, 0x78, 0xa0, + 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x87, 0x29, 0x84, 0x81, 0x28, 0xcc, + 0x08, 0x26, 0x1c, 0xd2, 0x41, 0x1e, 0xdc, 0xc0, 0x1c, 0xe4, 0x21, 0x1c, + 0xce, 0xa1, 0x1d, 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0xc0, 0x07, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, + 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, + 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, + 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, + 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, + 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, + 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, + 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, + 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, + 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x16, 0xd0, 0x00, 0x48, 0xe4, 0x0f, 0xce, 0xe4, 0x57, 0x77, 0x71, 0xdb, + 0x26, 0xb0, 0x01, 0x48, 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, + 0xd7, 0x44, 0x45, 0xc4, 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x6d, 0x00, + 0x11, 0xdb, 0x95, 0xff, 0xf9, 0xd6, 0xf6, 0x5f, 0x44, 0x80, 0xc1, 0x10, + 0xcd, 0x04, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x64, 0xe7, 0x20, 0x06, 0x02, 0xe9, 0xa8, 0x8e, 0x35, 0x00, 0x03, 0x31, + 0xc7, 0x30, 0x10, 0xdd, 0x1c, 0xc3, 0xd0, 0x75, 0xf4, 0x6a, 0x60, 0x04, + 0x80, 0xe0, 0x0c, 0x00, 0xc5, 0x11, 0x00, 0xaa, 0x63, 0x0d, 0x40, 0x20, + 0x10, 0x99, 0x01, 0xa0, 0x30, 0x03, 0x40, 0x60, 0x8c, 0x00, 0x04, 0x41, + 0x10, 0xff, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x06, 0xca, 0x10, + 0x88, 0x01, 0xe4, 0x4c, 0x89, 0x81, 0x04, 0x23, 0x06, 0xca, 0x10, 0x8c, + 0x01, 0xf4, 0x50, 0xca, 0x91, 0x08, 0x83, 0x0c, 0x42, 0xc1, 0x0c, 0x32, + 0x08, 0x86, 0x33, 0xc8, 0x20, 0x04, 0xd0, 0x20, 0x43, 0x90, 0x48, 0x77, + 0x8d, 0xa5, 0xa0, 0xd8, 0x10, 0xc0, 0x87, 0xb6, 0x32, 0xc8, 0x20, 0x34, + 0xcf, 0x78, 0x03, 0x07, 0x06, 0x6b, 0x70, 0xc1, 0x58, 0x0a, 0xca, 0x20, + 0x43, 0x10, 0x4d, 0x23, 0x06, 0x05, 0x11, 0xc8, 0x41, 0x11, 0xcc, 0x31, + 0x4c, 0x41, 0x1c, 0x8c, 0x37, 0x88, 0x81, 0x19, 0xb4, 0xc1, 0x05, 0x63, + 0x29, 0x28, 0x83, 0x0c, 0xc1, 0x95, 0x8d, 0x18, 0x14, 0x44, 0x80, 0x07, + 0x4b, 0x30, 0xc7, 0x60, 0x04, 0x76, 0x30, 0xde, 0x80, 0x06, 0x6c, 0x20, + 0x07, 0x17, 0x8c, 0xa5, 0xa0, 0x0c, 0x32, 0x04, 0xdd, 0x37, 0x62, 0x50, + 0x10, 0x81, 0x1f, 0x44, 0xc1, 0x1c, 0x83, 0x11, 0xe0, 0xc1, 0x1c, 0x43, + 0xf0, 0xe1, 0x81, 0x05, 0x95, 0x7c, 0x32, 0x08, 0x88, 0x01, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x24, 0x08, 0x05, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x7d, 0x03, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, + 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x49, + 0x0a, 0x32, 0x44, 0x24, 0x48, 0x0a, 0x90, 0x21, 0x23, 0xc4, 0x52, 0x80, + 0x0c, 0x19, 0x21, 0x72, 0x24, 0x07, 0xc8, 0x48, 0x11, 0x62, 0xa8, 0xa0, + 0xa8, 0x40, 0xc6, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x51, 0x18, 0x00, 0x00, + 0x03, 0x01, 0x00, 0x00, 0x1b, 0x8c, 0x60, 0x00, 0x16, 0xa0, 0xda, 0x60, + 0x08, 0x04, 0xb0, 0x00, 0xd5, 0x06, 0x63, 0x38, 0x80, 0x05, 0xa8, 0x36, + 0x90, 0x0b, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0x00, 0x12, 0x31, + 0x0e, 0xef, 0x20, 0x0f, 0xf2, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xec, 0x90, + 0x0f, 0x6d, 0x20, 0x0f, 0xef, 0x50, 0x0f, 0xee, 0x40, 0x0e, 0xe5, 0x40, + 0x0e, 0x6d, 0x40, 0x0e, 0xe9, 0x60, 0x0f, 0xe9, 0x40, 0x0e, 0xe5, 0xd0, + 0x06, 0xf3, 0x10, 0x0f, 0xf2, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x80, 0x39, 0x84, 0x03, 0x3b, + 0xcc, 0x43, 0x39, 0x00, 0x04, 0x39, 0xa4, 0xc3, 0x3c, 0x84, 0x83, 0x38, + 0xb0, 0x43, 0x39, 0xb4, 0x01, 0x3d, 0x84, 0x43, 0x3a, 0xb0, 0x43, 0x1b, + 0x8c, 0x43, 0x38, 0xb0, 0x03, 0x3b, 0xcc, 0x03, 0x60, 0x0e, 0xe1, 0xc0, + 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xc1, 0x0e, 0xe5, 0x30, 0x0f, 0xf3, 0xd0, + 0x06, 0xf0, 0x20, 0x0f, 0xe5, 0x30, 0x0e, 0xe9, 0x30, 0x0f, 0xe5, 0xd0, + 0x06, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xe4, 0x00, 0xd0, 0x83, 0x3c, + 0xd4, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, + 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, 0x3b, 0xa4, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, + 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0xc0, 0xe0, 0x0e, 0xef, 0xd0, + 0x06, 0xe6, 0x20, 0x0f, 0xe1, 0xd0, 0x0e, 0xe5, 0xd0, 0x06, 0xf0, 0xf0, + 0x0e, 0xe9, 0xe0, 0x0e, 0xf4, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xe5, 0xc0, + 0x0e, 0xe9, 0xd0, 0x0e, 0x6d, 0xe0, 0x0e, 0xef, 0xe0, 0x0e, 0x6d, 0xc0, + 0x0e, 0xe5, 0x10, 0x0e, 0xe6, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x90, + 0x0e, 0xee, 0x60, 0x0e, 0xf3, 0xd0, 0x06, 0xe6, 0x00, 0x0f, 0x6d, 0xd0, + 0x0e, 0xe1, 0x40, 0x0f, 0xe8, 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, + 0x00, 0x84, 0x3b, 0xbc, 0x43, 0x1b, 0xa8, 0x43, 0x3d, 0xb4, 0x03, 0x3c, + 0xb4, 0x01, 0x3d, 0x84, 0x83, 0x38, 0xb0, 0x43, 0x39, 0xcc, 0x03, 0x60, + 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, + 0x06, 0xee, 0x10, 0x0e, 0xee, 0x30, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, + 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, + 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0xc1, 0x3c, 0xa4, 0xc3, 0x39, + 0xb8, 0x43, 0x39, 0x90, 0x43, 0x1b, 0xe8, 0x43, 0x39, 0xc8, 0xc3, 0x3b, + 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, + 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0x31, + 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, 0x00, 0x0f, 0xf2, 0xf0, + 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, 0x20, 0x0f, 0x6d, 0x20, + 0x0e, 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xf3, 0x90, + 0x0e, 0xfa, 0x50, 0x0e, 0x00, 0x1e, 0x00, 0x04, 0x3d, 0x84, 0x83, 0x3c, + 0x9c, 0x43, 0x39, 0xd0, 0x43, 0x1b, 0x98, 0x43, 0x39, 0x84, 0x03, 0x3d, + 0xd4, 0x83, 0x3c, 0x94, 0xc3, 0x3c, 0x00, 0x6d, 0x60, 0x0e, 0xf0, 0x10, + 0x07, 0x76, 0x00, 0x10, 0xf5, 0xe0, 0x0e, 0xf3, 0x10, 0x0e, 0xe6, 0x50, + 0x0e, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, + 0x0e, 0x00, 0x3d, 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xd4, 0xc3, 0x3c, + 0x94, 0x43, 0x1b, 0xcc, 0xc3, 0x3b, 0x98, 0x03, 0x3d, 0xb4, 0x81, 0x39, + 0xb0, 0xc3, 0x3b, 0x84, 0x03, 0x3d, 0x00, 0xe6, 0x10, 0x0e, 0xec, 0x30, + 0x0f, 0xe5, 0x00, 0x6c, 0x50, 0x95, 0xe2, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x62, 0x1c, 0xde, 0x41, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x81, 0x1e, 0xd8, + 0x21, 0x1f, 0xda, 0x40, 0x1e, 0xde, 0xa1, 0x1e, 0xdc, 0x81, 0x1c, 0xca, + 0x81, 0x1c, 0xda, 0x80, 0x1c, 0xd2, 0xc1, 0x1e, 0xd2, 0x81, 0x1c, 0xca, + 0xa1, 0x0d, 0xe6, 0x21, 0x1e, 0xe4, 0x81, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x72, 0x48, 0x87, 0x79, 0x08, 0x07, + 0x71, 0x60, 0x87, 0x72, 0x68, 0x03, 0x7a, 0x08, 0x87, 0x74, 0x60, 0x87, + 0x36, 0x18, 0x87, 0x70, 0x60, 0x07, 0x76, 0x98, 0x07, 0xc0, 0x1c, 0xc2, + 0x81, 0x1d, 0xe6, 0xa1, 0x1c, 0x00, 0x82, 0x1d, 0xca, 0x61, 0x1e, 0xe6, + 0xa1, 0x0d, 0xe0, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xd2, 0x61, 0x1e, 0xca, + 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0x21, 0x1c, 0xc8, 0x01, 0xa0, 0x07, + 0x79, 0xa8, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x30, 0x07, + 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, + 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, + 0x76, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, + 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, 0xca, 0xa1, 0x0d, 0xe0, + 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, + 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, + 0x80, 0x1d, 0xca, 0x21, 0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, + 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, + 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, + 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x70, 0x87, 0x70, 0x70, 0x87, + 0x79, 0x68, 0x03, 0x73, 0x80, 0x87, 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, + 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, 0xa1, 0x1c, 0x00, 0xc2, 0x1d, 0xde, + 0xa1, 0x0d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, 0xda, + 0x40, 0x1f, 0xca, 0x41, 0x1e, 0xde, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x73, 0x08, 0x07, + 0x76, 0x98, 0x87, 0x72, 0x00, 0x88, 0x79, 0xa0, 0x87, 0x70, 0x18, 0x87, + 0x75, 0x68, 0x03, 0x78, 0x90, 0x87, 0x77, 0xa0, 0x87, 0x72, 0x18, 0x07, + 0x7a, 0x78, 0x07, 0x79, 0x68, 0x03, 0x71, 0xa8, 0x07, 0x73, 0x30, 0x87, + 0x72, 0x90, 0x87, 0x36, 0x98, 0x87, 0x74, 0xd0, 0x87, 0x72, 0x00, 0xf0, + 0x00, 0x20, 0xe8, 0x21, 0x1c, 0xe4, 0xe1, 0x1c, 0xca, 0x81, 0x1e, 0xda, + 0xc0, 0x1c, 0xca, 0x21, 0x1c, 0xe8, 0xa1, 0x1e, 0xe4, 0xa1, 0x1c, 0xe6, + 0x01, 0x68, 0x03, 0x73, 0x80, 0x87, 0x38, 0xb0, 0x03, 0x80, 0xa8, 0x07, + 0x77, 0x98, 0x87, 0x70, 0x30, 0x87, 0x72, 0x68, 0x03, 0x73, 0x80, 0x87, + 0x36, 0x68, 0x87, 0x70, 0xa0, 0x07, 0x74, 0x00, 0xe8, 0x41, 0x1e, 0xea, + 0xa1, 0x1c, 0x00, 0xa2, 0x1e, 0xe6, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xde, + 0xc1, 0x1c, 0xe8, 0xa1, 0x0d, 0xcc, 0x81, 0x1d, 0xde, 0x21, 0x1c, 0xe8, + 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, 0x79, 0x28, 0x07, 0x60, 0x03, 0x61, + 0x04, 0xc0, 0xb2, 0x81, 0x38, 0x04, 0x60, 0xd9, 0x80, 0x20, 0xff, 0xff, + 0xff, 0xff, 0x3f, 0x00, 0x0c, 0x20, 0x01, 0xd5, 0x06, 0x22, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0x01, 0x90, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x13, 0x88, 0x40, 0x18, 0x88, 0x09, 0x41, 0x31, + 0x61, 0x30, 0x0e, 0x64, 0x42, 0x90, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, + 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x68, 0x33, 0x00, + 0xc3, 0x08, 0x04, 0x30, 0x8c, 0x20, 0x00, 0x83, 0x08, 0x81, 0x30, 0x8c, + 0x30, 0x00, 0x07, 0x49, 0x53, 0x44, 0x09, 0x93, 0x2f, 0xbb, 0x6f, 0x47, + 0x08, 0xce, 0x40, 0x20, 0x82, 0x10, 0x42, 0x06, 0x11, 0x0a, 0xe1, 0x28, + 0x69, 0x8a, 0x28, 0x61, 0xf2, 0xff, 0x89, 0xb8, 0x26, 0x2a, 0x22, 0x7e, + 0x7b, 0xf8, 0xa7, 0x31, 0x02, 0x60, 0x10, 0xe1, 0x08, 0x2e, 0x92, 0xa6, + 0x88, 0x12, 0x26, 0xff, 0x97, 0x00, 0xe6, 0x59, 0x88, 0xe8, 0x9f, 0xc6, + 0x08, 0x80, 0x41, 0x84, 0x44, 0x28, 0x48, 0x08, 0x62, 0x18, 0x84, 0x14, + 0xad, 0x32, 0x00, 0x42, 0xa8, 0xcd, 0x11, 0x04, 0x73, 0x04, 0x60, 0x30, + 0x8c, 0x20, 0x40, 0x05, 0x09, 0x48, 0x89, 0x17, 0x1f, 0x20, 0x39, 0x10, + 0x30, 0x8c, 0x30, 0x40, 0xc3, 0x08, 0x04, 0x34, 0x47, 0x00, 0x0a, 0x83, + 0x08, 0x84, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x13, 0xb2, 0x70, 0x48, + 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, 0x78, 0x60, + 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, + 0x87, 0x38, 0x80, 0x03, 0x37, 0x88, 0x83, 0x38, 0x70, 0x03, 0x38, 0xd8, + 0xf0, 0x1e, 0xe5, 0xd0, 0x06, 0xf0, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, 0x0e, 0x71, + 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, + 0x80, 0x07, 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, + 0x00, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x40, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0f, 0x74, 0x80, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0x60, 0x0f, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, + 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, 0xf6, 0x10, 0x07, 0x79, + 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, + 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, + 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, + 0x00, 0x07, 0x72, 0x40, 0x07, 0x6d, 0x60, 0x0e, 0x78, 0x00, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, + 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, + 0x30, 0x84, 0x61, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0xc2, 0x38, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x61, + 0x26, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb2, 0x40, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x82, 0x23, 0x00, 0x25, 0x50, + 0x20, 0x05, 0x18, 0x50, 0x10, 0x45, 0x50, 0x06, 0x05, 0x54, 0x60, 0x85, + 0x50, 0x0a, 0xc5, 0x40, 0x77, 0x04, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x0d, 0x01, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x10, 0xd7, 0x20, 0x08, 0x0e, + 0x8e, 0xad, 0x0c, 0x84, 0x89, 0xc9, 0xaa, 0x09, 0xc4, 0xae, 0x4c, 0x6e, + 0x2e, 0xed, 0xcd, 0x0d, 0x04, 0x07, 0x46, 0xc6, 0x25, 0x06, 0x04, 0xa5, + 0xad, 0x8c, 0x2e, 0x8c, 0xcd, 0xac, 0xac, 0x05, 0x07, 0x46, 0xc6, 0x25, + 0xc6, 0x65, 0x86, 0x26, 0x65, 0x88, 0x40, 0x01, 0x43, 0x0c, 0x88, 0x80, + 0x0e, 0x68, 0x60, 0xd1, 0x54, 0x46, 0x17, 0xc6, 0x36, 0x04, 0xa1, 0x06, + 0x88, 0x80, 0x08, 0x68, 0xe0, 0x16, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, + 0x06, 0x97, 0xc6, 0x56, 0xe6, 0x42, 0x56, 0xe6, 0xf6, 0x26, 0xd7, 0x36, + 0xf7, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, 0x56, 0x36, 0x44, 0xa0, 0x0a, + 0x72, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x04, 0xea, 0x60, 0x19, 0x84, 0xa5, + 0xc9, 0xb9, 0x8c, 0xbd, 0xb5, 0xc1, 0xa5, 0xb1, 0x95, 0xb9, 0x98, 0xc9, + 0x85, 0xb5, 0x95, 0x89, 0xd5, 0x99, 0x99, 0x95, 0xc9, 0x7d, 0x99, 0x95, + 0xd1, 0x8d, 0xa1, 0x7d, 0x91, 0xa5, 0xcd, 0x85, 0x89, 0xb1, 0x95, 0x0d, + 0x11, 0xa8, 0x84, 0x61, 0x10, 0x96, 0x26, 0xe7, 0x32, 0xf6, 0xd6, 0x06, + 0x97, 0xc6, 0x56, 0xe6, 0xe2, 0x16, 0x46, 0x97, 0x66, 0x57, 0xf6, 0x45, + 0xf6, 0x56, 0x27, 0xc6, 0x56, 0xf6, 0x45, 0x96, 0x36, 0x17, 0x26, 0xc6, + 0x56, 0x36, 0x44, 0xa0, 0x16, 0x46, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x8c, + 0xc2, 0xd2, 0xe4, 0x5c, 0xc2, 0xe4, 0xce, 0xbe, 0xe8, 0xf2, 0xe0, 0xca, + 0xbe, 0xdc, 0xc2, 0xda, 0xca, 0x68, 0x98, 0xb1, 0xbd, 0x85, 0xd1, 0xd1, + 0x0c, 0x41, 0xa8, 0x06, 0x1a, 0x28, 0x87, 0x7a, 0x86, 0x08, 0x14, 0x44, + 0x26, 0x2c, 0x4d, 0xce, 0x05, 0xee, 0x6d, 0x2e, 0x8d, 0x2e, 0xed, 0xcd, + 0x8d, 0x4a, 0x58, 0x9a, 0x9c, 0xcb, 0x58, 0x99, 0x1b, 0x5d, 0x99, 0x1c, + 0xa5, 0xb0, 0x34, 0x39, 0x17, 0xb7, 0xb7, 0x2f, 0xb8, 0x32, 0xb9, 0x39, + 0xb8, 0xb2, 0x31, 0xba, 0x34, 0xbb, 0x32, 0x32, 0x61, 0x69, 0x72, 0x2e, + 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0xe0, 0xde, 0xe6, + 0xd2, 0xe8, 0xd2, 0xde, 0xdc, 0x86, 0x40, 0xd0, 0x40, 0x49, 0xd4, 0x44, + 0x51, 0x94, 0x43, 0x3d, 0x54, 0x45, 0x59, 0x94, 0xc2, 0xd2, 0xe4, 0x5c, + 0xcc, 0xe4, 0xc2, 0xce, 0xda, 0xca, 0xdc, 0xe8, 0xbe, 0xd2, 0xdc, 0xe0, + 0xea, 0xe8, 0x98, 0x9d, 0x95, 0xb9, 0x95, 0xc9, 0x85, 0xd1, 0x95, 0x91, + 0xa1, 0xe0, 0xd0, 0x95, 0xe1, 0x8d, 0xbd, 0xbd, 0xc9, 0x91, 0x11, 0xd9, + 0xc9, 0x7c, 0x99, 0xa5, 0xf0, 0x09, 0x4b, 0x93, 0x73, 0x81, 0x2b, 0x93, + 0x9b, 0x83, 0x2b, 0x1b, 0xa3, 0x4b, 0xb3, 0x2b, 0xa3, 0x61, 0xc6, 0xf6, + 0x16, 0x46, 0x27, 0x43, 0x84, 0xae, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x8e, + 0x6c, 0x88, 0x04, 0x11, 0x14, 0x46, 0x65, 0xd4, 0x44, 0x69, 0x94, 0x43, + 0x6d, 0x54, 0x45, 0x71, 0x54, 0xc2, 0xd2, 0xe4, 0x5c, 0xc4, 0xea, 0xcc, + 0xcc, 0xca, 0xe4, 0xf8, 0x84, 0xa5, 0xc9, 0xb9, 0x88, 0xd5, 0x99, 0x99, + 0x95, 0xc9, 0x7d, 0xcd, 0xa5, 0xe9, 0x95, 0x51, 0x0a, 0x4b, 0x93, 0x73, + 0x61, 0x7b, 0x1b, 0x0b, 0xa3, 0x4b, 0x7b, 0x73, 0xfb, 0x4a, 0x73, 0x23, + 0x2b, 0xc3, 0x23, 0x12, 0x96, 0x26, 0xe7, 0x22, 0x57, 0x16, 0x46, 0xc6, + 0x28, 0x2c, 0x4d, 0xce, 0x25, 0x4c, 0xee, 0xec, 0x8b, 0x2e, 0x0f, 0xae, + 0xec, 0x6b, 0x2e, 0x4d, 0xaf, 0x8c, 0x57, 0x58, 0x9a, 0x9c, 0x4b, 0x98, + 0xdc, 0xd9, 0x17, 0x5d, 0x1e, 0x5c, 0xd9, 0x57, 0x18, 0x5b, 0xda, 0x99, + 0xdb, 0xd7, 0x5c, 0x9a, 0x5e, 0x19, 0x87, 0xb1, 0x37, 0xb6, 0x21, 0x60, + 0x00, 0x21, 0x94, 0x47, 0x7d, 0x50, 0x41, 0x81, 0x01, 0x34, 0x40, 0x04, + 0x15, 0x06, 0x94, 0x18, 0x40, 0x05, 0x35, 0x06, 0x50, 0x41, 0x39, 0xd4, + 0x43, 0x55, 0x14, 0x19, 0x90, 0x0a, 0x4b, 0x93, 0x73, 0x99, 0xa3, 0x93, + 0xab, 0x1b, 0xa3, 0xfb, 0xa2, 0xcb, 0x83, 0x2b, 0xfb, 0x4a, 0x73, 0x33, + 0x7b, 0xa3, 0x61, 0xc6, 0xf6, 0x16, 0x46, 0x37, 0x43, 0xe3, 0xcd, 0xcc, + 0x6c, 0xae, 0x8c, 0x8e, 0x86, 0xd4, 0xd8, 0x5b, 0x99, 0x99, 0x19, 0x8d, + 0xa3, 0xb1, 0xb7, 0x32, 0x33, 0x33, 0x1a, 0x42, 0x63, 0x6f, 0x65, 0x66, + 0x66, 0x43, 0xd0, 0x00, 0x1a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd0, + 0x00, 0x2a, 0xa0, 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd2, 0x00, 0x52, 0xa0, + 0x02, 0x1a, 0xa8, 0x33, 0xa0, 0xd4, 0x00, 0x5a, 0xa0, 0x02, 0x1a, 0xa8, + 0x33, 0xa0, 0xd6, 0x80, 0x49, 0x56, 0x95, 0x15, 0x51, 0xd9, 0xd8, 0x1b, + 0x59, 0x19, 0x0d, 0xb2, 0xb2, 0xb1, 0x37, 0xb2, 0xb2, 0x21, 0x64, 0x00, + 0x25, 0x94, 0x47, 0x7d, 0x90, 0x41, 0x81, 0x01, 0x44, 0x40, 0x04, 0x15, + 0x06, 0x94, 0x19, 0x50, 0x6c, 0x40, 0x89, 0x01, 0x64, 0x50, 0x63, 0x00, + 0x15, 0x94, 0x43, 0xb5, 0x01, 0x55, 0x51, 0x6e, 0xc0, 0x25, 0x2c, 0x4d, + 0xce, 0x85, 0xae, 0x0c, 0x8f, 0xae, 0x4e, 0xae, 0x8c, 0x4a, 0x58, 0x9a, + 0x9c, 0xcb, 0x5c, 0x58, 0x1b, 0x1c, 0x5b, 0x19, 0x31, 0xba, 0x32, 0x3c, + 0xba, 0x3a, 0xb9, 0x32, 0x19, 0x32, 0x1e, 0x33, 0xb6, 0xb7, 0x30, 0x3a, + 0x16, 0x90, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, 0x1f, 0x12, 0x74, 0x65, + 0x78, 0x59, 0x43, 0x28, 0x88, 0xa1, 0xe0, 0x80, 0x02, 0x03, 0x68, 0x80, + 0x08, 0x2a, 0x0e, 0x28, 0x87, 0x92, 0x03, 0xaa, 0xa2, 0xe6, 0x80, 0x05, + 0x5d, 0x19, 0x5e, 0x95, 0xd5, 0x10, 0x0a, 0x6a, 0x28, 0x38, 0xa0, 0xc0, + 0x00, 0x22, 0x20, 0x82, 0x8a, 0x03, 0xca, 0xa1, 0xe4, 0x80, 0xaa, 0xa8, + 0x3a, 0xe0, 0x12, 0x96, 0x26, 0xe7, 0x32, 0x17, 0xd6, 0x06, 0xc7, 0x56, + 0x26, 0xc7, 0x63, 0x2e, 0xac, 0x0d, 0x8e, 0xad, 0x4c, 0x8e, 0xc1, 0xdc, + 0x10, 0x09, 0x72, 0xa8, 0x3b, 0xa0, 0xc0, 0x00, 0x1a, 0x20, 0x82, 0x72, + 0x28, 0x3c, 0xa0, 0x2a, 0x2a, 0x0f, 0x86, 0x38, 0xd4, 0x45, 0x75, 0x54, + 0x19, 0x50, 0x6f, 0x40, 0xd1, 0x01, 0x65, 0x07, 0x94, 0x1e, 0x0c, 0x31, + 0x18, 0x80, 0x8a, 0xa8, 0x3d, 0xe0, 0xf3, 0xd6, 0xe6, 0x96, 0x06, 0xf7, + 0x46, 0x57, 0xe6, 0x46, 0x07, 0x32, 0x86, 0x16, 0x26, 0xc7, 0x67, 0x2a, + 0xad, 0x0d, 0x8e, 0xad, 0x0c, 0x64, 0x68, 0x65, 0x05, 0x84, 0x4a, 0x28, + 0x28, 0x68, 0x88, 0x40, 0xf9, 0xc1, 0x10, 0x83, 0xea, 0x03, 0xea, 0x0f, + 0xae, 0x67, 0x88, 0x41, 0x81, 0x02, 0x05, 0x0a, 0xd7, 0x33, 0x42, 0x61, + 0x07, 0x76, 0xb0, 0x87, 0x76, 0x70, 0x83, 0x74, 0x20, 0x87, 0x72, 0x70, + 0x07, 0x7a, 0x98, 0x12, 0x04, 0x23, 0x96, 0x70, 0x48, 0x07, 0x79, 0x70, + 0x03, 0x7b, 0x28, 0x07, 0x79, 0x98, 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, + 0x12, 0x08, 0x23, 0xa8, 0x70, 0x48, 0x07, 0x79, 0x70, 0x03, 0x76, 0x08, + 0x07, 0x77, 0x38, 0x87, 0x7a, 0x08, 0x87, 0x73, 0x28, 0x87, 0x5f, 0xb0, + 0x87, 0x72, 0x90, 0x87, 0x79, 0x48, 0x87, 0x77, 0x70, 0x87, 0x29, 0x01, + 0x31, 0x62, 0x0a, 0x87, 0x74, 0x90, 0x07, 0x37, 0x18, 0x87, 0x77, 0x68, + 0x07, 0x78, 0x48, 0x07, 0x76, 0x28, 0x87, 0x5f, 0x78, 0x07, 0x78, 0xa0, + 0x87, 0x74, 0x78, 0x07, 0x77, 0x98, 0x87, 0x29, 0x84, 0x81, 0x28, 0xcc, + 0x08, 0x26, 0x1c, 0xd2, 0x41, 0x1e, 0xdc, 0xc0, 0x1c, 0xe4, 0x21, 0x1c, + 0xce, 0xa1, 0x1d, 0xca, 0xc1, 0x1d, 0xe8, 0x61, 0x4a, 0xc0, 0x07, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, + 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, 0x74, 0x18, + 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, + 0x50, 0x0e, 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, + 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, + 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, 0xe1, 0x1d, + 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, + 0x3b, 0xcc, 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, + 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, + 0x50, 0x0e, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x16, 0xd0, 0x00, 0x48, 0xe4, 0x0f, 0xce, 0xe4, 0x57, 0x77, 0x71, 0xdb, + 0x26, 0xb0, 0x01, 0x48, 0xe4, 0x4b, 0x00, 0xf3, 0x2c, 0xc4, 0x3f, 0x11, + 0xd7, 0x44, 0x45, 0xc4, 0x6f, 0x0f, 0x7e, 0x85, 0x17, 0xb7, 0x6d, 0x00, + 0x11, 0xdb, 0x95, 0xff, 0xf9, 0xda, 0xf5, 0x5f, 0x44, 0x80, 0xc1, 0x10, + 0xcd, 0x04, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x64, 0xe7, 0x20, 0x06, 0x02, 0xf1, 0xa8, 0x8e, 0x35, 0x00, 0x03, 0x31, + 0xc7, 0x30, 0x10, 0xde, 0x1c, 0xc3, 0xe0, 0x79, 0x63, 0x0d, 0x40, 0x20, + 0xd0, 0xab, 0x81, 0x11, 0x00, 0x82, 0x33, 0x00, 0x14, 0x47, 0x00, 0xc6, + 0x12, 0x02, 0x80, 0xc8, 0x0c, 0x00, 0x89, 0x19, 0x00, 0x0a, 0x33, 0x00, + 0x04, 0xc6, 0x08, 0x40, 0x10, 0x04, 0xf1, 0x6f, 0x04, 0x00, 0x00, 0x00, + 0x23, 0x06, 0xca, 0x10, 0x90, 0x81, 0x04, 0x55, 0xca, 0x91, 0x04, 0x23, + 0x06, 0xca, 0x10, 0x94, 0x81, 0x14, 0x59, 0x0b, 0xa2, 0x08, 0x83, 0x0c, + 0x41, 0x81, 0x0c, 0x32, 0x0c, 0xc6, 0x33, 0xc8, 0x20, 0x20, 0xd1, 0x20, + 0x83, 0x10, 0x4c, 0x83, 0x0c, 0xc1, 0x52, 0x9d, 0x36, 0x96, 0x82, 0x62, + 0x43, 0x00, 0x1f, 0xf2, 0xca, 0x20, 0x83, 0xe0, 0x58, 0xe3, 0x0d, 0xdf, + 0x18, 0xb8, 0xc1, 0x05, 0x63, 0x29, 0x28, 0x83, 0x0c, 0x81, 0xa4, 0x8d, + 0x18, 0x14, 0x44, 0x50, 0x07, 0x45, 0x30, 0xc7, 0x40, 0x05, 0x74, 0x30, + 0xde, 0x50, 0x06, 0x69, 0x00, 0x07, 0x17, 0x8c, 0xa5, 0xa0, 0x0c, 0x32, + 0x04, 0x18, 0x18, 0x8c, 0x18, 0x14, 0x44, 0xb0, 0x07, 0x4b, 0x30, 0xc7, + 0x60, 0x04, 0x79, 0x30, 0xde, 0xb0, 0x06, 0x6f, 0x50, 0x07, 0x17, 0x8c, + 0xa5, 0xa0, 0x0c, 0x32, 0x04, 0x9e, 0x19, 0x8c, 0x18, 0x14, 0x44, 0x10, + 0x0a, 0x51, 0x30, 0xc7, 0x60, 0x04, 0x7b, 0x30, 0xc7, 0x10, 0x80, 0xc1, + 0x1e, 0x58, 0x50, 0xc9, 0x27, 0x83, 0x80, 0x18, 0x02, 0x00, 0x00, 0x00, + 0x5b, 0x06, 0x25, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; +const unsigned int sdl_metallib_len = 22792; diff --git a/source/3rd-party/SDL2/src/render/metal/build-metal-shaders.sh b/source/3rd-party/SDL2/src/render/metal/build-metal-shaders.sh new file mode 100644 index 0000000..8ebf63e --- /dev/null +++ b/source/3rd-party/SDL2/src/render/metal/build-metal-shaders.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -x +set -e +cd `dirname "$0"` + +generate_shaders() +{ + platform=$1 + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/metal -std=$platform-metal1.1 -Wall -O3 -o ./sdl.air ./SDL_shaders_metal.metal || exit $? + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/metal-ar rc sdl.metalar sdl.air || exit $? + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/metallib -o sdl.metallib sdl.metalar || exit $? + xxd -i sdl.metallib | perl -w -p -e 's/\Aunsigned /const unsigned /;' >./SDL_shaders_metal_$platform.h + rm -f sdl.air sdl.metalar sdl.metallib +} + +generate_shaders osx +generate_shaders ios diff --git a/source/3rd-party/SDL2/src/render/opengl/SDL_glfuncs.h b/source/3rd-party/SDL2/src/render/opengl/SDL_glfuncs.h new file mode 100644 index 0000000..02be0e1 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengl/SDL_glfuncs.h @@ -0,0 +1,478 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* list of OpenGL functions sorted alphabetically + If you need to use a GL function from the SDL video subsystem, + change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. +*/ +#define SDL_PROC_UNUSED(ret,func,params) + +SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat)) +SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf)) +SDL_PROC_UNUSED(GLboolean, glAreTexturesResident, + (GLsizei, const GLuint *, GLboolean *)) +SDL_PROC_UNUSED(void, glArrayElement, (GLint)) +SDL_PROC(void, glBegin, (GLenum)) +SDL_PROC(void, glBindTexture, (GLenum, GLuint)) +SDL_PROC_UNUSED(void, glBitmap, + (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, + const GLubyte *)) +SDL_PROC(void, glBlendEquation, (GLenum)) +SDL_PROC_UNUSED(void, glBlendFunc, (GLenum, GLenum)) +SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum)) +SDL_PROC_UNUSED(void, glCallList, (GLuint)) +SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *)) +SDL_PROC(void, glClear, (GLbitfield)) +SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) +SDL_PROC_UNUSED(void, glClearDepth, (GLclampd)) +SDL_PROC_UNUSED(void, glClearIndex, (GLfloat)) +SDL_PROC_UNUSED(void, glClearStencil, (GLint)) +SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *)) +SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte)) +SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *)) +SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble)) +SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *)) +SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glColor3fv, (const GLfloat *)) +SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint)) +SDL_PROC_UNUSED(void, glColor3iv, (const GLint *)) +SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort)) +SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *)) +SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte)) +SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *)) +SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint)) +SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *)) +SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort)) +SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *)) +SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte)) +SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *)) +SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble)) +SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *)) +SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *)) +SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint)) +SDL_PROC_UNUSED(void, glColor4iv, (const GLint *)) +SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort)) +SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *)) +SDL_PROC_UNUSED(void, glColor4ub, + (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) +SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v)) +SDL_PROC_UNUSED(void, glColor4ui, + (GLuint red, GLuint green, GLuint blue, GLuint alpha)) +SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v)) +SDL_PROC_UNUSED(void, glColor4us, + (GLushort red, GLushort green, GLushort blue, GLushort alpha)) +SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v)) +SDL_PROC_UNUSED(void, glColorMask, + (GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha)) +SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode)) +SDL_PROC_UNUSED(void, glColorPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glCopyPixels, + (GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type)) +SDL_PROC_UNUSED(void, glCopyTexImage1D, + (GLenum target, GLint level, GLenum internalFormat, GLint x, + GLint y, GLsizei width, GLint border)) +SDL_PROC_UNUSED(void, glCopyTexImage2D, + (GLenum target, GLint level, GLenum internalFormat, GLint x, + GLint y, GLsizei width, GLsizei height, GLint border)) +SDL_PROC_UNUSED(void, glCopyTexSubImage1D, + (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, + GLsizei width)) +SDL_PROC_UNUSED(void, glCopyTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range)) +SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) +SDL_PROC(void, glDepthFunc, (GLenum func)) +SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) +SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar)) +SDL_PROC(void, glDisable, (GLenum cap)) +SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array)) +SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) +SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode)) +SDL_PROC_UNUSED(void, glDrawElements, + (GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices)) +SDL_PROC(void, glDrawPixels, + (GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag)) +SDL_PROC_UNUSED(void, glEdgeFlagPointer, + (GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag)) +SDL_PROC(void, glEnable, (GLenum cap)) +SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array)) +SDL_PROC(void, glEnd, (void)) +SDL_PROC_UNUSED(void, glEndList, (void)) +SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u)) +SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u)) +SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v)) +SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v)) +SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2)) +SDL_PROC_UNUSED(void, glEvalMesh2, + (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)) +SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i)) +SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j)) +SDL_PROC_UNUSED(void, glFeedbackBuffer, + (GLsizei size, GLenum type, GLfloat * buffer)) +SDL_PROC_UNUSED(void, glFinish, (void)) +SDL_PROC_UNUSED(void, glFlush, (void)) +SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glFrustum, + (GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble zNear, GLdouble zFar)) +SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range)) +SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) +SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) +SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation)) +SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params)) +SDL_PROC(GLenum, glGetError, (void)) +SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params)) +SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetLightfv, + (GLenum light, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetLightiv, + (GLenum light, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v)) +SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v)) +SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v)) +SDL_PROC_UNUSED(void, glGetMaterialfv, + (GLenum face, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetMaterialiv, + (GLenum face, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values)) +SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values)) +SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values)) +SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid * *params)) +SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask)) +SDL_PROC(const GLubyte *, glGetString, (GLenum name)) +SDL_PROC_UNUSED(void, glGetTexEnvfv, + (GLenum target, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexEnviv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexGendv, + (GLenum coord, GLenum pname, GLdouble * params)) +SDL_PROC_UNUSED(void, glGetTexGenfv, + (GLenum coord, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexGeniv, + (GLenum coord, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexImage, + (GLenum target, GLint level, GLenum format, GLenum type, + GLvoid * pixels)) +SDL_PROC_UNUSED(void, glGetTexLevelParameterfv, + (GLenum target, GLint level, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexLevelParameteriv, + (GLenum target, GLint level, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexParameterfv, + (GLenum target, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexParameteriv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) +SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask)) +SDL_PROC_UNUSED(void, glIndexPointer, + (GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glIndexd, (GLdouble c)) +SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c)) +SDL_PROC_UNUSED(void, glIndexf, (GLfloat c)) +SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c)) +SDL_PROC_UNUSED(void, glIndexi, (GLint c)) +SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c)) +SDL_PROC_UNUSED(void, glIndexs, (GLshort c)) +SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c)) +SDL_PROC_UNUSED(void, glIndexub, (GLubyte c)) +SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c)) +SDL_PROC_UNUSED(void, glInitNames, (void)) +SDL_PROC_UNUSED(void, glInterleavedArrays, + (GLenum format, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) +SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list)) +SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) +SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightfv, + (GLenum light, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glLightiv, + (GLenum light, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern)) +SDL_PROC(void, glLineWidth, (GLfloat width)) +SDL_PROC_UNUSED(void, glListBase, (GLuint base)) +SDL_PROC(void, glLoadIdentity, (void)) +SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m)) +SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glLoadName, (GLuint name)) +SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) +SDL_PROC_UNUSED(void, glMap1d, + (GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points)) +SDL_PROC_UNUSED(void, glMap1f, + (GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * points)) +SDL_PROC_UNUSED(void, glMap2d, + (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, + GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, + GLint vorder, const GLdouble * points)) +SDL_PROC_UNUSED(void, glMap2f, + (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, + GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, + GLint vorder, const GLfloat * points)) +SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2)) +SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2)) +SDL_PROC_UNUSED(void, glMapGrid2d, + (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, + GLdouble v2)) +SDL_PROC_UNUSED(void, glMapGrid2f, + (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, + GLfloat v2)) +SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glMaterialfv, + (GLenum face, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glMaterialiv, + (GLenum face, GLenum pname, const GLint * params)) +SDL_PROC(void, glMatrixMode, (GLenum mode)) +SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m)) +SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode)) +SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz)) +SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v)) +SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz)) +SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) +SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz)) +SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz)) +SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glNormalPointer, + (GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC(void, glOrtho, + (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar)) +SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token)) +SDL_PROC_UNUSED(void, glPixelMapfv, + (GLenum map, GLsizei mapsize, const GLfloat * values)) +SDL_PROC_UNUSED(void, glPixelMapuiv, + (GLenum map, GLsizei mapsize, const GLuint * values)) +SDL_PROC_UNUSED(void, glPixelMapusv, + (GLenum map, GLsizei mapsize, const GLushort * values)) +SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param)) +SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor)) +SDL_PROC(void, glPointSize, (GLfloat size)) +SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode)) +SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) +SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask)) +SDL_PROC_UNUSED(void, glPopAttrib, (void)) +SDL_PROC_UNUSED(void, glPopClientAttrib, (void)) +SDL_PROC(void, glPopMatrix, (void)) +SDL_PROC_UNUSED(void, glPopName, (void)) +SDL_PROC_UNUSED(void, glPrioritizeTextures, + (GLsizei n, const GLuint * textures, + const GLclampf * priorities)) +SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask)) +SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask)) +SDL_PROC(void, glPushMatrix, (void)) +SDL_PROC_UNUSED(void, glPushName, (GLuint name)) +SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y)) +SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y)) +SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v)) +SDL_PROC(void, glRasterPos2i, (GLint x, GLint y)) +SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y)) +SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z)) +SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z)) +SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos4d, + (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) +SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos4f, + (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) +SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w)) +SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos4s, + (GLshort x, GLshort y, GLshort z, GLshort w)) +SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v)) +SDL_PROC(void, glReadBuffer, (GLenum mode)) +SDL_PROC(void, glReadPixels, + (GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels)) +SDL_PROC_UNUSED(void, glRectd, + (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)) +SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2)) +SDL_PROC(void, glRectf, + (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)) +SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2)) +SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2)) +SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2)) +SDL_PROC_UNUSED(void, glRects, + (GLshort x1, GLshort y1, GLshort x2, GLshort y2)) +SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2)) +SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode)) +SDL_PROC(void, glRotated, + (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC(void, glRotatef, + (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer)) +SDL_PROC(void, glShadeModel, (GLenum mode)) +SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) +SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) +SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) +SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s)) +SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s)) +SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s)) +SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s)) +SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t)) +SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v)) +SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t)) +SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t)) +SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t)) +SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r)) +SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r)) +SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r)) +SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r)) +SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord4d, + (GLdouble s, GLdouble t, GLdouble r, GLdouble q)) +SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord4f, + (GLfloat s, GLfloat t, GLfloat r, GLfloat q)) +SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q)) +SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord4s, + (GLshort s, GLshort t, GLshort r, GLshort q)) +SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoordPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexEnvfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexEnviv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param)) +SDL_PROC_UNUSED(void, glTexGendv, + (GLenum coord, GLenum pname, const GLdouble * params)) +SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexGenfv, + (GLenum coord, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexGeniv, + (GLenum coord, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexImage1D, + (GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC(void, glTexImage2D, + (GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glTexParameterf, + (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexParameterfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexParameteriv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexSubImage1D, + (GLenum target, GLint level, GLint xoffset, GLsizei width, + GLenum format, GLenum type, const GLvoid * pixels)) +SDL_PROC(void, glTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y)) +SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v)) +SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y)) +SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y)) +SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y)) +SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC(void, glVertex3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z)) +SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z)) +SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex4d, + (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) +SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex4f, + (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) +SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w)) +SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex4s, + (GLshort x, GLshort y, GLshort z, GLshort w)) +SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertexPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengl/SDL_render_gl.c b/source/3rd-party/SDL2/src/render/opengl/SDL_render_gl.c new file mode 100644 index 0000000..f3e8326 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengl/SDL_render_gl.c @@ -0,0 +1,1678 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_assert.h" +#include "SDL_opengl.h" +#include "../SDL_sysrender.h" +#include "SDL_shaders_gl.h" + +#ifdef __MACOSX__ +#include <OpenGL/OpenGL.h> +#endif + +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ + +#define RENDERER_CONTEXT_MAJOR 2 +#define RENDERER_CONTEXT_MINOR 1 + +/* OpenGL renderer implementation */ + +/* Details on optimizing the texture path on Mac OS X: + http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html +*/ + +/* Used to re-create the window with OpenGL capability */ +extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); + +static const float inv255f = 1.0f / 255.0f; + +static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); +static void GL_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); +static SDL_bool GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int GL_UpdateViewport(SDL_Renderer * renderer); +static int GL_UpdateClipRect(SDL_Renderer * renderer); +static int GL_RenderClear(SDL_Renderer * renderer); +static int GL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int GL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int GL_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); +static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GL_RenderPresent(SDL_Renderer * renderer); +static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void GL_DestroyRenderer(SDL_Renderer * renderer); +static int GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); +static int GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); + +SDL_RenderDriver GL_RenderDriver = { + GL_CreateRenderer, + { + "opengl", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 1, + {SDL_PIXELFORMAT_ARGB8888}, + 0, + 0} +}; + +typedef struct GL_FBOList GL_FBOList; + +struct GL_FBOList +{ + Uint32 w, h; + GLuint FBO; + GL_FBOList *next; +}; + +typedef struct +{ + SDL_GLContext context; + + SDL_bool debug_enabled; + SDL_bool GL_ARB_debug_output_supported; + int errors; + char **error_messages; + GLDEBUGPROCARB next_error_callback; + GLvoid *next_error_userparam; + + SDL_bool GL_ARB_texture_non_power_of_two_supported; + SDL_bool GL_ARB_texture_rectangle_supported; + struct { + GL_Shader shader; + Uint32 color; + SDL_BlendMode blendMode; + } current; + + SDL_bool GL_EXT_framebuffer_object_supported; + GL_FBOList *framebuffers; + + /* OpenGL functions */ +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#include "SDL_glfuncs.h" +#undef SDL_PROC + + /* Multitexture support */ + SDL_bool GL_ARB_multitexture_supported; + PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; + GLint num_texture_units; + + PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; + PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; + PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; + PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; + PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; + + /* Shader support */ + GL_ShaderContext *shaders; + +} GL_RenderData; + +typedef struct +{ + GLuint texture; + GLenum type; + GLfloat texw; + GLfloat texh; + GLenum format; + GLenum formattype; + void *pixels; + int pitch; + SDL_Rect locked_rect; + + /* YUV texture support */ + SDL_bool yuv; + SDL_bool nv12; + GLuint utexture; + GLuint vtexture; + + GL_FBOList *fbo; +} GL_TextureData; + +SDL_FORCE_INLINE const char* +GL_TranslateError (GLenum error) +{ +#define GL_ERROR_TRANSLATE(e) case e: return #e; + switch (error) { + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) + GL_ERROR_TRANSLATE(GL_STACK_OVERFLOW) + GL_ERROR_TRANSLATE(GL_STACK_UNDERFLOW) + GL_ERROR_TRANSLATE(GL_TABLE_TOO_LARGE) + default: + return "UNKNOWN"; +} +#undef GL_ERROR_TRANSLATE +} + +SDL_FORCE_INLINE void +GL_ClearErrors(SDL_Renderer *renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (!data->debug_enabled) + { + return; + } + if (data->GL_ARB_debug_output_supported) { + if (data->errors) { + int i; + for (i = 0; i < data->errors; ++i) { + SDL_free(data->error_messages[i]); + } + SDL_free(data->error_messages); + + data->errors = 0; + data->error_messages = NULL; + } + } else { + while (data->glGetError() != GL_NO_ERROR) { + continue; + } + } +} + +SDL_FORCE_INLINE int +GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int ret = 0; + + if (!data->debug_enabled) + { + return 0; + } + if (data->GL_ARB_debug_output_supported) { + if (data->errors) { + int i; + for (i = 0; i < data->errors; ++i) { + SDL_SetError("%s: %s (%d): %s %s", prefix, file, line, function, data->error_messages[i]); + ret = -1; + } + GL_ClearErrors(renderer); + } + } else { + /* check gl errors (can return multiple errors) */ + for (;;) { + GLenum error = data->glGetError(); + if (error != GL_NO_ERROR) { + if (prefix == NULL || prefix[0] == '\0') { + prefix = "generic"; + } + SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); + ret = -1; + } else { + break; + } + } + } + return ret; +} + +#if 0 +#define GL_CheckError(prefix, renderer) +#else +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION) +#endif + +static int +GL_LoadFunctions(GL_RenderData * data) +{ +#ifdef __SDL_NOGETPROCADDR__ +#define SDL_PROC(ret,func,params) data->func=func; +#else +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if ( ! data->func ) { \ + return SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \ + } \ + } while ( 0 ); +#endif /* __SDL_NOGETPROCADDR__ */ + +#include "SDL_glfuncs.h" +#undef SDL_PROC + return 0; +} + +static SDL_GLContext SDL_CurrentContext = NULL; + +static int +GL_ActivateRenderer(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context || + SDL_GL_GetCurrentContext() != data->context) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { + return -1; + } + SDL_CurrentContext = data->context; + + GL_UpdateViewport(renderer); + } + + GL_ClearErrors(renderer); + + return 0; +} + +/* This is called if we need to invalidate all of the SDL OpenGL state */ +static void +GL_ResetState(SDL_Renderer *renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_GL_GetCurrentContext() == data->context) { + GL_UpdateViewport(renderer); + } else { + GL_ActivateRenderer(renderer); + } + + data->current.shader = SHADER_NONE; + data->current.color = 0xffffffff; + data->current.blendMode = SDL_BLENDMODE_INVALID; + + data->glDisable(GL_DEPTH_TEST); + data->glDisable(GL_CULL_FACE); + /* This ended up causing video discrepancies between OpenGL and Direct3D */ + /* data->glEnable(GL_LINE_SMOOTH); */ + + data->glMatrixMode(GL_MODELVIEW); + data->glLoadIdentity(); + + GL_CheckError("", renderer); +} + +static void APIENTRY +GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam) +{ + SDL_Renderer *renderer = (SDL_Renderer *) userParam; + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (type == GL_DEBUG_TYPE_ERROR_ARB) { + /* Record this error */ + int errors = data->errors + 1; + char **error_messages = SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages)); + if (error_messages) { + data->errors = errors; + data->error_messages = error_messages; + data->error_messages[data->errors-1] = SDL_strdup(message); + } + } + + /* If there's another error callback, pass it along, otherwise log it */ + if (data->next_error_callback) { + data->next_error_callback(source, type, id, severity, length, message, data->next_error_userparam); + } else { + if (type == GL_DEBUG_TYPE_ERROR_ARB) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "%s", message); + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_RENDER, "%s", message); + } + } +} + +static GL_FBOList * +GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) +{ + GL_FBOList *result = data->framebuffers; + + while (result && ((result->w != w) || (result->h != h))) { + result = result->next; + } + + if (!result) { + result = SDL_malloc(sizeof(GL_FBOList)); + if (result) { + result->w = w; + result->h = h; + data->glGenFramebuffersEXT(1, &result->FBO); + result->next = data->framebuffers; + data->framebuffers = result; + } + } + return result; +} + +SDL_Renderer * +GL_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + GL_RenderData *data; + GLint value; + Uint32 window_flags; + int profile_mask = 0, major = 0, minor = 0; + SDL_bool changed_window = SDL_FALSE; + + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); + + window_flags = SDL_GetWindowFlags(window); + if (!(window_flags & SDL_WINDOW_OPENGL) || + profile_mask == SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { + + changed_window = SDL_TRUE; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + + if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { + goto error; + } + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + goto error; + } + + data = (GL_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + GL_DestroyRenderer(renderer); + SDL_OutOfMemory(); + goto error; + } + + renderer->WindowEvent = GL_WindowEvent; + renderer->GetOutputSize = GL_GetOutputSize; + renderer->SupportsBlendMode = GL_SupportsBlendMode; + renderer->CreateTexture = GL_CreateTexture; + renderer->UpdateTexture = GL_UpdateTexture; + renderer->UpdateTextureYUV = GL_UpdateTextureYUV; + renderer->LockTexture = GL_LockTexture; + renderer->UnlockTexture = GL_UnlockTexture; + renderer->SetRenderTarget = GL_SetRenderTarget; + renderer->UpdateViewport = GL_UpdateViewport; + renderer->UpdateClipRect = GL_UpdateClipRect; + renderer->RenderClear = GL_RenderClear; + renderer->RenderDrawPoints = GL_RenderDrawPoints; + renderer->RenderDrawLines = GL_RenderDrawLines; + renderer->RenderFillRects = GL_RenderFillRects; + renderer->RenderCopy = GL_RenderCopy; + renderer->RenderCopyEx = GL_RenderCopyEx; + renderer->RenderReadPixels = GL_RenderReadPixels; + renderer->RenderPresent = GL_RenderPresent; + renderer->DestroyTexture = GL_DestroyTexture; + renderer->DestroyRenderer = GL_DestroyRenderer; + renderer->GL_BindTexture = GL_BindTexture; + renderer->GL_UnbindTexture = GL_UnbindTexture; + renderer->info = GL_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->driverdata = data; + renderer->window = window; + + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GL_DestroyRenderer(renderer); + goto error; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GL_DestroyRenderer(renderer); + goto error; + } + + if (GL_LoadFunctions(data) < 0) { + GL_DestroyRenderer(renderer); + goto error; + } + +#ifdef __MACOSX__ + /* Enable multi-threaded rendering */ + /* Disabled until Ryan finishes his VBO/PBO code... + CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine); + */ +#endif + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + /* Check for debug output support */ + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && + (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { + data->debug_enabled = SDL_TRUE; + } + if (data->debug_enabled && SDL_GL_ExtensionSupported("GL_ARB_debug_output")) { + PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC) SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); + + data->GL_ARB_debug_output_supported = SDL_TRUE; + data->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION_ARB, (GLvoid **)(char *)&data->next_error_callback); + data->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM_ARB, &data->next_error_userparam); + glDebugMessageCallbackARBFunc(GL_HandleDebugMessage, renderer); + + /* Make sure our callback is called when errors actually happen */ + data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + } + + if (SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two")) { + data->GL_ARB_texture_non_power_of_two_supported = SDL_TRUE; + } else if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || + SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { + data->GL_ARB_texture_rectangle_supported = SDL_TRUE; + } + if (data->GL_ARB_texture_rectangle_supported) { + data->glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &value); + renderer->info.max_texture_width = value; + renderer->info.max_texture_height = value; + } else { + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + renderer->info.max_texture_height = value; + } + + /* Check for multitexture support */ + if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { + data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB"); + if (data->glActiveTextureARB) { + data->GL_ARB_multitexture_supported = SDL_TRUE; + data->glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &data->num_texture_units); + } + } + + /* Check for shader support */ + if (SDL_GetHintBoolean(SDL_HINT_RENDER_OPENGL_SHADERS, SDL_TRUE)) { + data->shaders = GL_CreateShaderContext(); + } + SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s", + data->shaders ? "ENABLED" : "DISABLED"); + + /* We support YV12 textures using 3 textures and a shader */ + if (data->shaders && data->num_texture_units >= 3) { + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; + } + +#ifdef __MACOSX__ + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_UYVY; +#endif + + if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) { + data->GL_EXT_framebuffer_object_supported = SDL_TRUE; + data->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) + SDL_GL_GetProcAddress("glGenFramebuffersEXT"); + data->glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) + SDL_GL_GetProcAddress("glDeleteFramebuffersEXT"); + data->glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) + SDL_GL_GetProcAddress("glFramebufferTexture2DEXT"); + data->glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) + SDL_GL_GetProcAddress("glBindFramebufferEXT"); + data->glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) + SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT"); + renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; + } + data->framebuffers = NULL; + + /* Set up parameters for rendering */ + GL_ResetState(renderer); + + return renderer; + +error: + if (changed_window) { + /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); + SDL_RecreateWindow(window, window_flags); + } + return NULL; +} + +static void +GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || + event->event == SDL_WINDOWEVENT_SHOWN || + event->event == SDL_WINDOWEVENT_HIDDEN) { + /* Rebind the context to the window area and update matrices */ + SDL_CurrentContext = NULL; + } +} + +static int +GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + return 0; +} + +static GLenum GetBlendFunc(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: + return GL_ZERO; + case SDL_BLENDFACTOR_ONE: + return GL_ONE; + case SDL_BLENDFACTOR_SRC_COLOR: + return GL_SRC_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return GL_ONE_MINUS_SRC_COLOR; + case SDL_BLENDFACTOR_SRC_ALPHA: + return GL_SRC_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return GL_ONE_MINUS_SRC_ALPHA; + case SDL_BLENDFACTOR_DST_COLOR: + return GL_DST_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return GL_ONE_MINUS_DST_COLOR; + case SDL_BLENDFACTOR_DST_ALPHA: + return GL_DST_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return GL_ONE_MINUS_DST_ALPHA; + default: + return GL_INVALID_ENUM; + } +} + +static GLenum GetBlendEquation(SDL_BlendOperation operation) +{ + switch (operation) { + case SDL_BLENDOPERATION_ADD: + return GL_FUNC_ADD; + case SDL_BLENDOPERATION_SUBTRACT: + return GL_FUNC_SUBTRACT; + case SDL_BLENDOPERATION_REV_SUBTRACT: + return GL_FUNC_REVERSE_SUBTRACT; + default: + return GL_INVALID_ENUM; + } +} + +static SDL_bool +GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(colorOperation) == GL_INVALID_ENUM || + GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) { + return SDL_FALSE; + } + if (colorOperation != alphaOperation) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +SDL_FORCE_INLINE int +power_of_2(int input) +{ + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + +SDL_FORCE_INLINE SDL_bool +convert_format(GL_RenderData *renderdata, Uint32 pixel_format, + GLint* internalFormat, GLenum* format, GLenum* type) +{ + switch (pixel_format) { + case SDL_PIXELFORMAT_ARGB8888: + *internalFormat = GL_RGBA8; + *format = GL_BGRA; + *type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + *internalFormat = GL_LUMINANCE; + *format = GL_LUMINANCE; + *type = GL_UNSIGNED_BYTE; + break; +#ifdef __MACOSX__ + case SDL_PIXELFORMAT_UYVY: + *internalFormat = GL_RGB8; + *format = GL_YCBCR_422_APPLE; + *type = GL_UNSIGNED_SHORT_8_8_APPLE; + break; +#endif + default: + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int +GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data; + GLint internalFormat; + GLenum format, type; + int texture_w, texture_h; + GLenum scaleMode; + + GL_ActivateRenderer(renderer); + + if (texture->access == SDL_TEXTUREACCESS_TARGET && + !renderdata->GL_EXT_framebuffer_object_supported) { + return SDL_SetError("Render targets not supported by OpenGL"); + } + + if (!convert_format(renderdata, texture->format, &internalFormat, + &format, &type)) { + return SDL_SetError("Texture format %s not supported by OpenGL", + SDL_GetPixelFormatName(texture->format)); + } + + data = (GL_TextureData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + return SDL_OutOfMemory(); + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + size_t size; + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + size = texture->h * data->pitch; + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + /* Need to add size for the U and V planes */ + size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); + } + if (texture->format == SDL_PIXELFORMAT_NV12 || + texture->format == SDL_PIXELFORMAT_NV21) { + /* Need to add size for the U/V plane */ + size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); + } + data->pixels = SDL_calloc(1, size); + if (!data->pixels) { + SDL_free(data); + return SDL_OutOfMemory(); + } + } + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + data->fbo = GL_GetFBO(renderdata, texture->w, texture->h); + } else { + data->fbo = NULL; + } + + GL_CheckError("", renderer); + renderdata->glGenTextures(1, &data->texture); + if (GL_CheckError("glGenTextures()", renderer) < 0) { + if (data->pixels) { + SDL_free(data->pixels); + } + SDL_free(data); + return -1; + } + texture->driverdata = data; + + if (renderdata->GL_ARB_texture_non_power_of_two_supported) { + data->type = GL_TEXTURE_2D; + texture_w = texture->w; + texture_h = texture->h; + data->texw = 1.0f; + data->texh = 1.0f; + } else if (renderdata->GL_ARB_texture_rectangle_supported) { + data->type = GL_TEXTURE_RECTANGLE_ARB; + texture_w = texture->w; + texture_h = texture->h; + data->texw = (GLfloat) texture_w; + data->texh = (GLfloat) texture_h; + } else { + data->type = GL_TEXTURE_2D; + texture_w = power_of_2(texture->w); + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) (texture->w) / texture_w; + data->texh = (GLfloat) texture->h / texture_h; + } + + data->format = format; + data->formattype = type; + scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode); + /* According to the spec, CLAMP_TO_EDGE is the default for TEXTURE_RECTANGLE + and setting it causes an INVALID_ENUM error in the latest NVidia drivers. + */ + if (data->type != GL_TEXTURE_RECTANGLE_ARB) { + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + } +#ifdef __MACOSX__ +#ifndef GL_TEXTURE_STORAGE_HINT_APPLE +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#endif +#ifndef STORAGE_CACHED_APPLE +#define STORAGE_CACHED_APPLE 0x85BE +#endif +#ifndef STORAGE_SHARED_APPLE +#define STORAGE_SHARED_APPLE 0x85BF +#endif + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_SHARED_APPLE); + } else { + renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_CACHED_APPLE); + } + if (texture->access == SDL_TEXTUREACCESS_STREAMING + && texture->format == SDL_PIXELFORMAT_ARGB8888 + && (texture->w % 8) == 0) { + renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, + (data->pitch / SDL_BYTESPERPIXEL(texture->format))); + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, data->pixels); + renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); + } + else +#endif + { + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, NULL); + } + renderdata->glDisable(data->type); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; + } + + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + data->yuv = SDL_TRUE; + + renderdata->glGenTextures(1, &data->utexture); + renderdata->glGenTextures(1, &data->vtexture); + renderdata->glEnable(data->type); + + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, internalFormat, (texture_w+1)/2, + (texture_h+1)/2, 0, format, type, NULL); + + renderdata->glBindTexture(data->type, data->vtexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, internalFormat, (texture_w+1)/2, + (texture_h+1)/2, 0, format, type, NULL); + + renderdata->glDisable(data->type); + } + + if (texture->format == SDL_PIXELFORMAT_NV12 || + texture->format == SDL_PIXELFORMAT_NV21) { + data->nv12 = SDL_TRUE; + + renderdata->glGenTextures(1, &data->utexture); + renderdata->glEnable(data->type); + + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2, + (texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); + renderdata->glDisable(data->type); + } + + return GL_CheckError("", renderer); +} + +static int +GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + const int texturebpp = SDL_BYTESPERPIXEL(texture->format); + + SDL_assert(texturebpp != 0); /* otherwise, division by zero later. */ + + GL_ActivateRenderer(renderer); + + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / texturebpp)); + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + pixels); + if (data->yuv) { + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + if (texture->format == SDL_PIXELFORMAT_YV12) { + renderdata->glBindTexture(data->type, data->vtexture); + } else { + renderdata->glBindTexture(data->type, data->utexture); + } + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + (rect->w+1)/2, (rect->h+1)/2, + data->format, data->formattype, pixels); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); + if (texture->format == SDL_PIXELFORMAT_YV12) { + renderdata->glBindTexture(data->type, data->utexture); + } else { + renderdata->glBindTexture(data->type, data->vtexture); + } + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + (rect->w+1)/2, (rect->h+1)/2, + data->format, data->formattype, pixels); + } + + if (data->nv12) { + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + (rect->w + 1)/2, (rect->h + 1)/2, + GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels); + } + renderdata->glDisable(data->type); + + return GL_CheckError("glTexSubImage2D()", renderer); +} + +static int +GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Ypitch); + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + Yplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Upitch); + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + (rect->w + 1)/2, (rect->h + 1)/2, + data->format, data->formattype, Uplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Vpitch); + renderdata->glBindTexture(data->type, data->vtexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + (rect->w + 1)/2, (rect->h + 1)/2, + data->format, data->formattype, Vplane); + renderdata->glDisable(data->type); + + return GL_CheckError("glTexSubImage2D()", renderer); +} + +static int +GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + data->locked_rect = *rect; + *pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = data->pitch; + return 0; +} + +static void +GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + const SDL_Rect *rect; + void *pixels; + + rect = &data->locked_rect; + pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + GL_UpdateTexture(renderer, texture, rect, pixels, data->pitch); +} + +static int +GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata; + GLenum status; + + GL_ActivateRenderer(renderer); + + if (!data->GL_EXT_framebuffer_object_supported) { + return SDL_SetError("Render targets not supported by OpenGL"); + } + + if (texture == NULL) { + data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + return 0; + } + + texturedata = (GL_TextureData *) texture->driverdata; + data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, texturedata->fbo->FBO); + /* TODO: check if texture pixel format allows this operation */ + data->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, texturedata->type, texturedata->texture, 0); + /* Check FBO status */ + status = data->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return SDL_SetError("glFramebufferTexture2DEXT() failed"); + } + return 0; +} + +static int +GL_UpdateViewport(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + if (renderer->target) { + data->glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h), + renderer->viewport.w, renderer->viewport.h); + } + + data->glMatrixMode(GL_PROJECTION); + data->glLoadIdentity(); + if (renderer->viewport.w && renderer->viewport.h) { + if (renderer->target) { + data->glOrtho((GLdouble) 0, + (GLdouble) renderer->viewport.w, + (GLdouble) 0, + (GLdouble) renderer->viewport.h, + 0.0, 1.0); + } else { + data->glOrtho((GLdouble) 0, + (GLdouble) renderer->viewport.w, + (GLdouble) renderer->viewport.h, + (GLdouble) 0, + 0.0, 1.0); + } + } + data->glMatrixMode(GL_MODELVIEW); + + return GL_CheckError("", renderer); +} + +static int +GL_UpdateClipRect(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (renderer->clipping_enabled) { + const SDL_Rect *rect = &renderer->clip_rect; + data->glEnable(GL_SCISSOR_TEST); + if (renderer->target) { + data->glScissor(renderer->viewport.x + rect->x, renderer->viewport.y + rect->y, rect->w, rect->h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h); + } + } else { + data->glDisable(GL_SCISSOR_TEST); + } + return 0; +} + +static void +GL_SetShader(GL_RenderData * data, GL_Shader shader) +{ + if (data->shaders && shader != data->current.shader) { + GL_SelectShader(data->shaders, shader); + data->current.shader = shader; + } +} + +static void +GL_SetColor(GL_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b); + + if (color != data->current.color) { + data->glColor4f((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); + data->current.color = color; + } +} + +static void +GL_SetBlendMode(GL_RenderData * data, SDL_BlendMode blendMode) +{ + if (blendMode != data->current.blendMode) { + if (blendMode == SDL_BLENDMODE_NONE) { + data->glDisable(GL_BLEND); + } else { + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode))); + data->glBlendEquation(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode))); + } + data->current.blendMode = blendMode; + } +} + +static void +GL_SetDrawingState(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + GL_ActivateRenderer(renderer); + + GL_SetColor(data, renderer->r, + renderer->g, + renderer->b, + renderer->a); + + GL_SetBlendMode(data, renderer->blendMode); + + GL_SetShader(data, SHADER_SOLID); +} + +static int +GL_RenderClear(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + GL_ActivateRenderer(renderer); + + data->glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } + + data->glClear(GL_COLOR_BUFFER_BIT); + + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + + return 0; +} + +static int +GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + data->glBegin(GL_POINTS); + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + + return 0; +} + +static int +GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + if (count > 2 && + points[0].x == points[count-1].x && points[0].y == points[count-1].y) { + data->glBegin(GL_LINE_LOOP); + /* GL_LINE_LOOP takes care of the final segment */ + --count; + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + } else { +#if defined(__MACOSX__) || defined(__WIN32__) +#else + int x1, y1, x2, y2; +#endif + + data->glBegin(GL_LINE_STRIP); + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + + /* The line is half open, so we need one more point to complete it. + * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html + * If we have to, we can use vertical line and horizontal line textures + * for vertical and horizontal lines, and then create custom textures + * for diagonal lines and software render those. It's terrible, but at + * least it would be pixel perfect. + */ + data->glBegin(GL_POINTS); +#if defined(__MACOSX__) || defined(__WIN32__) + /* Mac OS X and Windows seem to always leave the last point open */ + data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y); +#else + /* Linux seems to leave the right-most or bottom-most point open */ + x1 = points[0].x; + y1 = points[0].y; + x2 = points[count-1].x; + y2 = points[count-1].y; + + if (x1 > x2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (x2 > x1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } + if (y1 > y2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (y2 > y1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } +#endif + data->glEnd(); + } + return GL_CheckError("", renderer); +} + +static int +GL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + for (i = 0; i < count; ++i) { + const SDL_FRect *rect = &rects[i]; + + data->glRectf(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); + } + return GL_CheckError("", renderer); +} + +static int +GL_SetupCopy(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + + data->glEnable(texturedata->type); + if (texturedata->yuv) { + data->glActiveTextureARB(GL_TEXTURE2_ARB); + data->glBindTexture(texturedata->type, texturedata->vtexture); + + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glBindTexture(texturedata->type, texturedata->utexture); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } + if (texturedata->nv12) { + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glBindTexture(texturedata->type, texturedata->utexture); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + GL_SetColor(data, texture->r, texture->g, texture->b, texture->a); + } else { + GL_SetColor(data, 255, 255, 255, 255); + } + + GL_SetBlendMode(data, texture->blendMode); + + if (texturedata->yuv || texturedata->nv12) { + switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { + case SDL_YUV_CONVERSION_JPEG: + if (texturedata->yuv) { + GL_SetShader(data, SHADER_YUV_JPEG); + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + GL_SetShader(data, SHADER_NV12_JPEG); + } else { + GL_SetShader(data, SHADER_NV21_JPEG); + } + break; + case SDL_YUV_CONVERSION_BT601: + if (texturedata->yuv) { + GL_SetShader(data, SHADER_YUV_BT601); + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + GL_SetShader(data, SHADER_NV12_BT601); + } else { + GL_SetShader(data, SHADER_NV21_BT601); + } + break; + case SDL_YUV_CONVERSION_BT709: + if (texturedata->yuv) { + GL_SetShader(data, SHADER_YUV_BT709); + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + GL_SetShader(data, SHADER_NV12_BT709); + } else { + GL_SetShader(data, SHADER_NV21_BT709); + } + break; + default: + return SDL_SetError("Unsupported YUV conversion mode"); + } + } else { + GL_SetShader(data, SHADER_RGB); + } + return 0; +} + +static int +GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GLfloat minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + + GL_ActivateRenderer(renderer); + + if (GL_SetupCopy(renderer, texture) < 0) { + return -1; + } + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + data->glBegin(GL_TRIANGLE_STRIP); + data->glTexCoord2f(minu, minv); + data->glVertex2f(minx, miny); + data->glTexCoord2f(maxu, minv); + data->glVertex2f(maxx, miny); + data->glTexCoord2f(minu, maxv); + data->glVertex2f(minx, maxy); + data->glTexCoord2f(maxu, maxv); + data->glVertex2f(maxx, maxy); + data->glEnd(); + + data->glDisable(texturedata->type); + + return GL_CheckError("", renderer); +} + +static int +GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GLfloat minx, miny, maxx, maxy; + GLfloat centerx, centery; + GLfloat minu, maxu, minv, maxv; + + GL_ActivateRenderer(renderer); + + if (GL_SetupCopy(renderer, texture) < 0) { + return -1; + } + + centerx = center->x; + centery = center->y; + + if (flip & SDL_FLIP_HORIZONTAL) { + minx = dstrect->w - centerx; + maxx = -centerx; + } + else { + minx = -centerx; + maxx = dstrect->w - centerx; + } + + if (flip & SDL_FLIP_VERTICAL) { + miny = dstrect->h - centery; + maxy = -centery; + } + else { + miny = -centery; + maxy = dstrect->h - centery; + } + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + /* Translate to flip, rotate, translate to position */ + data->glPushMatrix(); + data->glTranslatef((GLfloat)dstrect->x + centerx, (GLfloat)dstrect->y + centery, (GLfloat)0.0); + data->glRotated(angle, (GLdouble)0.0, (GLdouble)0.0, (GLdouble)1.0); + + data->glBegin(GL_TRIANGLE_STRIP); + data->glTexCoord2f(minu, minv); + data->glVertex2f(minx, miny); + data->glTexCoord2f(maxu, minv); + data->glVertex2f(maxx, miny); + data->glTexCoord2f(minu, maxv); + data->glVertex2f(minx, maxy); + data->glTexCoord2f(maxu, maxv); + data->glVertex2f(maxx, maxy); + data->glEnd(); + data->glPopMatrix(); + + data->glDisable(texturedata->type); + + return GL_CheckError("", renderer); +} + +static int +GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888; + void *temp_pixels; + int temp_pitch; + GLint internalFormat; + GLenum format, type; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GL_ActivateRenderer(renderer); + + if (!convert_format(data, temp_format, &internalFormat, &format, &type)) { + return SDL_SetError("Texture format %s not supported by OpenGL", + SDL_GetPixelFormatName(temp_format)); + } + + if (!rect->w || !rect->h) { + return 0; /* nothing to do. */ + } + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + + SDL_GetRendererOutputSize(renderer, &w, &h); + + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_PACK_ROW_LENGTH, + (temp_pitch / SDL_BYTESPERPIXEL(temp_format))); + + data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + rect->w, rect->h, format, type, temp_pixels); + + if (GL_CheckError("glReadPixels()", renderer) < 0) { + SDL_free(temp_pixels); + return -1; + } + + /* Flip the rows to be top-down if necessary */ + if (!renderer->target) { + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + } + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GL_RenderPresent(SDL_Renderer * renderer) +{ + GL_ActivateRenderer(renderer); + + SDL_GL_SwapWindow(renderer->window); +} + +static void +GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + if (!data) { + return; + } + if (data->texture) { + renderdata->glDeleteTextures(1, &data->texture); + } + if (data->yuv) { + renderdata->glDeleteTextures(1, &data->utexture); + renderdata->glDeleteTextures(1, &data->vtexture); + } + SDL_free(data->pixels); + SDL_free(data); + texture->driverdata = NULL; +} + +static void +GL_DestroyRenderer(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (data) { + if (data->context != NULL) { + /* make sure we delete the right resources! */ + GL_ActivateRenderer(renderer); + } + + GL_ClearErrors(renderer); + if (data->GL_ARB_debug_output_supported) { + PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC) SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); + + /* Uh oh, we don't have a safe way of removing ourselves from the callback chain, if it changed after we set our callback. */ + /* For now, just always replace the callback with the original one */ + glDebugMessageCallbackARBFunc(data->next_error_callback, data->next_error_userparam); + } + if (data->shaders) { + GL_DestroyShaderContext(data->shaders); + } + if (data->context) { + while (data->framebuffers) { + GL_FBOList *nextnode = data->framebuffers->next; + /* delete the framebuffer object */ + data->glDeleteFramebuffersEXT(1, &data->framebuffers->FBO); + GL_CheckError("", renderer); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; + } + SDL_GL_DeleteContext(data->context); + } + SDL_free(data); + } + SDL_free(renderer); +} + +static int +GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GL_ActivateRenderer(renderer); + + data->glEnable(texturedata->type); + if (texturedata->yuv) { + data->glActiveTextureARB(GL_TEXTURE2_ARB); + data->glBindTexture(texturedata->type, texturedata->vtexture); + + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glBindTexture(texturedata->type, texturedata->utexture); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } + data->glBindTexture(texturedata->type, texturedata->texture); + + if(texw) *texw = (float)texturedata->texw; + if(texh) *texh = (float)texturedata->texh; + + return 0; +} + +static int +GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GL_ActivateRenderer(renderer); + + if (texturedata->yuv) { + data->glActiveTextureARB(GL_TEXTURE2_ARB); + data->glDisable(texturedata->type); + + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glDisable(texturedata->type); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } + + data->glDisable(texturedata->type); + + return 0; +} + +#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.c b/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.c new file mode 100644 index 0000000..251b54d --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.c @@ -0,0 +1,524 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED + +#include "SDL_stdinc.h" +#include "SDL_log.h" +#include "SDL_opengl.h" +#include "SDL_video.h" +#include "SDL_shaders_gl.h" + +/* OpenGL shader implementation */ + +/* #define DEBUG_SHADERS */ + +typedef struct +{ + GLhandleARB program; + GLhandleARB vert_shader; + GLhandleARB frag_shader; +} GL_ShaderData; + +struct GL_ShaderContext +{ + GLenum (*glGetError)(void); + + PFNGLATTACHOBJECTARBPROC glAttachObjectARB; + PFNGLCOMPILESHADERARBPROC glCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; + PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; + PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; + PFNGLGETINFOLOGARBPROC glGetInfoLogARB; + PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; + PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; + PFNGLLINKPROGRAMARBPROC glLinkProgramARB; + PFNGLSHADERSOURCEARBPROC glShaderSourceARB; + PFNGLUNIFORM1IARBPROC glUniform1iARB; + PFNGLUNIFORM1FARBPROC glUniform1fARB; + PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; + + SDL_bool GL_ARB_texture_rectangle_supported; + + GL_ShaderData shaders[NUM_SHADERS]; +}; + +#define COLOR_VERTEX_SHADER \ +"varying vec4 v_color;\n" \ +"\n" \ +"void main()\n" \ +"{\n" \ +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \ +" v_color = gl_Color;\n" \ +"}" \ + +#define TEXTURE_VERTEX_SHADER \ +"varying vec4 v_color;\n" \ +"varying vec2 v_texCoord;\n" \ +"\n" \ +"void main()\n" \ +"{\n" \ +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \ +" v_color = gl_Color;\n" \ +" v_texCoord = vec2(gl_MultiTexCoord0);\n" \ +"}" \ + +#define JPEG_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const vec3 Rcoeff = vec3(1, 0.000, 1.402);\n" \ +"const vec3 Gcoeff = vec3(1, -0.3441, -0.7141);\n" \ +"const vec3 Bcoeff = vec3(1, 1.772, 0.000);\n" \ + +#define BT601_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.596);\n" \ +"const vec3 Gcoeff = vec3(1.1644, -0.3918, -0.813);\n" \ +"const vec3 Bcoeff = vec3(1.1644, 2.0172, 0.000);\n" \ + +#define BT709_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.7927);\n" \ +"const vec3 Gcoeff = vec3(1.1644, -0.2132, -0.5329);\n" \ +"const vec3 Bcoeff = vec3(1.1644, 2.1124, 0.000);\n" \ + +#define YUV_SHADER_PROLOGUE \ +"varying vec4 v_color;\n" \ +"varying vec2 v_texCoord;\n" \ +"uniform sampler2D tex0; // Y \n" \ +"uniform sampler2D tex1; // U \n" \ +"uniform sampler2D tex2; // V \n" \ +"\n" \ + +#define YUV_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" vec2 tcoord;\n" \ +" vec3 yuv, rgb;\n" \ +"\n" \ +" // Get the Y value \n" \ +" tcoord = v_texCoord;\n" \ +" yuv.x = texture2D(tex0, tcoord).r;\n" \ +"\n" \ +" // Get the U and V values \n" \ +" tcoord *= UVCoordScale;\n" \ +" yuv.y = texture2D(tex1, tcoord).r;\n" \ +" yuv.z = texture2D(tex2, tcoord).r;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb.r = dot(yuv, Rcoeff);\n" \ +" rgb.g = dot(yuv, Gcoeff);\n" \ +" rgb.b = dot(yuv, Bcoeff);\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \ +"}" \ + +#define NV12_SHADER_PROLOGUE \ +"varying vec4 v_color;\n" \ +"varying vec2 v_texCoord;\n" \ +"uniform sampler2D tex0; // Y \n" \ +"uniform sampler2D tex1; // U/V \n" \ +"\n" \ + +#define NV12_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" vec2 tcoord;\n" \ +" vec3 yuv, rgb;\n" \ +"\n" \ +" // Get the Y value \n" \ +" tcoord = v_texCoord;\n" \ +" yuv.x = texture2D(tex0, tcoord).r;\n" \ +"\n" \ +" // Get the U and V values \n" \ +" tcoord *= UVCoordScale;\n" \ +" yuv.yz = texture2D(tex1, tcoord).ra;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb.r = dot(yuv, Rcoeff);\n" \ +" rgb.g = dot(yuv, Gcoeff);\n" \ +" rgb.b = dot(yuv, Bcoeff);\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \ +"}" \ + +#define NV21_SHADER_PROLOGUE \ +"varying vec4 v_color;\n" \ +"varying vec2 v_texCoord;\n" \ +"uniform sampler2D tex0; // Y \n" \ +"uniform sampler2D tex1; // U/V \n" \ +"\n" \ + +#define NV21_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" vec2 tcoord;\n" \ +" vec3 yuv, rgb;\n" \ +"\n" \ +" // Get the Y value \n" \ +" tcoord = v_texCoord;\n" \ +" yuv.x = texture2D(tex0, tcoord).r;\n" \ +"\n" \ +" // Get the U and V values \n" \ +" tcoord *= UVCoordScale;\n" \ +" yuv.yz = texture2D(tex1, tcoord).ar;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb.r = dot(yuv, Rcoeff);\n" \ +" rgb.g = dot(yuv, Gcoeff);\n" \ +" rgb.b = dot(yuv, Bcoeff);\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \ +"}" \ + +/* + * NOTE: Always use sampler2D, etc here. We'll #define them to the + * texture_rectangle versions if we choose to use that extension. + */ +static const char *shader_source[NUM_SHADERS][2] = +{ + /* SHADER_NONE */ + { NULL, NULL }, + + /* SHADER_SOLID */ + { + /* vertex shader */ + COLOR_VERTEX_SHADER, + /* fragment shader */ +"varying vec4 v_color;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = v_color;\n" +"}" + }, + + /* SHADER_RGB */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" +"}" + }, + + /* SHADER_YUV_JPEG */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + YUV_SHADER_PROLOGUE + JPEG_SHADER_CONSTANTS + YUV_SHADER_BODY + }, + /* SHADER_YUV_BT601 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + YUV_SHADER_PROLOGUE + BT601_SHADER_CONSTANTS + YUV_SHADER_BODY + }, + /* SHADER_YUV_BT709 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + YUV_SHADER_PROLOGUE + BT709_SHADER_CONSTANTS + YUV_SHADER_BODY + }, + /* SHADER_NV12_JPEG */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV12_SHADER_PROLOGUE + JPEG_SHADER_CONSTANTS + NV12_SHADER_BODY + }, + /* SHADER_NV12_BT601 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV12_SHADER_PROLOGUE + BT601_SHADER_CONSTANTS + NV12_SHADER_BODY + }, + /* SHADER_NV12_BT709 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV12_SHADER_PROLOGUE + BT709_SHADER_CONSTANTS + NV12_SHADER_BODY + }, + /* SHADER_NV21_JPEG */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV21_SHADER_PROLOGUE + JPEG_SHADER_CONSTANTS + NV21_SHADER_BODY + }, + /* SHADER_NV21_BT601 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV21_SHADER_PROLOGUE + BT601_SHADER_CONSTANTS + NV21_SHADER_BODY + }, + /* SHADER_NV21_BT709 */ + { + /* vertex shader */ + TEXTURE_VERTEX_SHADER, + /* fragment shader */ + NV21_SHADER_PROLOGUE + BT709_SHADER_CONSTANTS + NV21_SHADER_BODY + }, +}; + +static SDL_bool +CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) +{ + GLint status; + const char *sources[2]; + + sources[0] = defines; + sources[1] = source; + + ctx->glShaderSourceARB(shader, SDL_arraysize(sources), sources, NULL); + ctx->glCompileShaderARB(shader); + ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); + if (status == 0) { + GLint length; + char *info; + + ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + info = SDL_stack_alloc(char, length+1); + ctx->glGetInfoLogARB(shader, length, NULL, info); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#ifdef DEBUG_SHADERS + fprintf(stderr, + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#endif + SDL_stack_free(info); + + return SDL_FALSE; + } else { + return SDL_TRUE; + } +} + +static SDL_bool +CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) +{ + const int num_tmus_bound = 4; + const char *vert_defines = ""; + const char *frag_defines = ""; + int i; + GLint location; + + if (index == SHADER_NONE) { + return SDL_TRUE; + } + + ctx->glGetError(); + + /* Make sure we use the correct sampler type for our texture type */ + if (ctx->GL_ARB_texture_rectangle_supported) { + frag_defines = +"#define sampler2D sampler2DRect\n" +"#define texture2D texture2DRect\n" +"#define UVCoordScale 0.5\n"; + } else { + frag_defines = +"#define UVCoordScale 1.0\n"; + } + + /* Create one program object to rule them all */ + data->program = ctx->glCreateProgramObjectARB(); + + /* Create the vertex shader */ + data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) { + return SDL_FALSE; + } + + /* Create the fragment shader */ + data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) { + return SDL_FALSE; + } + + /* ... and in the darkness bind them */ + ctx->glAttachObjectARB(data->program, data->vert_shader); + ctx->glAttachObjectARB(data->program, data->frag_shader); + ctx->glLinkProgramARB(data->program); + + /* Set up some uniform variables */ + ctx->glUseProgramObjectARB(data->program); + for (i = 0; i < num_tmus_bound; ++i) { + char tex_name[10]; + SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i); + location = ctx->glGetUniformLocationARB(data->program, tex_name); + if (location >= 0) { + ctx->glUniform1iARB(location, i); + } + } + ctx->glUseProgramObjectARB(0); + + return (ctx->glGetError() == GL_NO_ERROR); +} + +static void +DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data) +{ + ctx->glDeleteObjectARB(data->vert_shader); + ctx->glDeleteObjectARB(data->frag_shader); + ctx->glDeleteObjectARB(data->program); +} + +GL_ShaderContext * +GL_CreateShaderContext(void) +{ + GL_ShaderContext *ctx; + SDL_bool shaders_supported; + int i; + + ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); + if (!ctx) { + return NULL; + } + + if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") && + (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || + SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) { + ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE; + } + + /* Check for shader support */ + shaders_supported = SDL_FALSE; + if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") && + SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && + SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && + SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { + ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError"); + ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); + ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); + ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); + ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); + ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); + ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); + ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); + ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); + ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); + ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + if (ctx->glGetError && + ctx->glAttachObjectARB && + ctx->glCompileShaderARB && + ctx->glCreateProgramObjectARB && + ctx->glCreateShaderObjectARB && + ctx->glDeleteObjectARB && + ctx->glGetInfoLogARB && + ctx->glGetObjectParameterivARB && + ctx->glGetUniformLocationARB && + ctx->glLinkProgramARB && + ctx->glShaderSourceARB && + ctx->glUniform1iARB && + ctx->glUniform1fARB && + ctx->glUseProgramObjectARB) { + shaders_supported = SDL_TRUE; + } + } + + if (!shaders_supported) { + SDL_free(ctx); + return NULL; + } + + /* Compile all the shaders */ + for (i = 0; i < NUM_SHADERS; ++i) { + if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) { + GL_DestroyShaderContext(ctx); + return NULL; + } + } + + /* We're done! */ + return ctx; +} + +void +GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader) +{ + ctx->glUseProgramObjectARB(ctx->shaders[shader].program); +} + +void +GL_DestroyShaderContext(GL_ShaderContext *ctx) +{ + int i; + + for (i = 0; i < NUM_SHADERS; ++i) { + DestroyShaderProgram(ctx, &ctx->shaders[i]); + } + SDL_free(ctx); +} + +#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.h b/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.h new file mode 100644 index 0000000..3697521 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengl/SDL_shaders_gl.h @@ -0,0 +1,53 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_shaders_gl_h_ +#define SDL_shaders_gl_h_ + +#include "../../SDL_internal.h" + +/* OpenGL shader implementation */ + +typedef enum { + SHADER_NONE, + SHADER_SOLID, + SHADER_RGB, + SHADER_YUV_JPEG, + SHADER_YUV_BT601, + SHADER_YUV_BT709, + SHADER_NV12_JPEG, + SHADER_NV12_BT601, + SHADER_NV12_BT709, + SHADER_NV21_JPEG, + SHADER_NV21_BT601, + SHADER_NV21_BT709, + NUM_SHADERS +} GL_Shader; + +typedef struct GL_ShaderContext GL_ShaderContext; + +extern GL_ShaderContext * GL_CreateShaderContext(void); +extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader); +extern void GL_DestroyShaderContext(GL_ShaderContext *ctx); + +#endif /* SDL_shaders_gl_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengles/SDL_glesfuncs.h b/source/3rd-party/SDL2/src/render/opengles/SDL_glesfuncs.h new file mode 100644 index 0000000..e00982b --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles/SDL_glesfuncs.h @@ -0,0 +1,65 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +SDL_PROC(void, glBindTexture, (GLenum, GLuint)) +SDL_PROC(void, glBlendFunc, (GLenum, GLenum)) +SDL_PROC_OES(void, glBlendEquationOES, (GLenum)) +SDL_PROC_OES(void, glBlendEquationSeparateOES, (GLenum, GLenum)) +SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) +SDL_PROC(void, glClear, (GLbitfield)) +SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) +SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *)) +SDL_PROC(void, glDisable, (GLenum)) +SDL_PROC(void, glDisableClientState, (GLenum array)) +SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei)) +SDL_PROC_OES(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glEnable, (GLenum)) +SDL_PROC(void, glEnableClientState, (GLenum)) +SDL_PROC(void, glFinish, (void)) +SDL_PROC_OES(void, glGenFramebuffersOES, (GLsizei, GLuint *)) +SDL_PROC(void, glGenTextures, (GLsizei, GLuint *)) +SDL_PROC(GLenum, glGetError, (void)) +SDL_PROC(void, glGetIntegerv, (GLenum, GLint *)) +SDL_PROC(void, glLoadIdentity, (void)) +SDL_PROC(void, glMatrixMode, (GLenum)) +SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glPixelStorei, (GLenum, GLint)) +SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*)) +SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) +SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *)) +SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat)) +SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) +SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint)) +SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *)) +SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) +SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *)) +SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei)) +SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint)) +SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) +SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum)) +SDL_PROC(void, glPushMatrix, (void)) +SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glPopMatrix, (void)) +SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengles/SDL_render_gles.c b/source/3rd-party/SDL2/src/render/opengles/SDL_render_gles.c new file mode 100644 index 0000000..4007dff --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles/SDL_render_gles.c @@ -0,0 +1,1278 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_opengles.h" +#include "../SDL_sysrender.h" + +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ + +#define RENDERER_CONTEXT_MAJOR 1 +#define RENDERER_CONTEXT_MINOR 1 + +#if defined(SDL_VIDEO_DRIVER_PANDORA) + +/* Empty function stub to get OpenGL ES 1.x support without */ +/* OpenGL ES extension GL_OES_draw_texture supported */ +GL_API void GL_APIENTRY +glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + return; +} + +#endif /* SDL_VIDEO_DRIVER_PANDORA */ + +/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */ + +/* Used to re-create the window with OpenGL ES capability */ +extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); + +static const float inv255f = 1.0f / 255.0f; + +static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); +static void GLES_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); +static SDL_bool GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void GLES_UnlockTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_SetRenderTarget(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_UpdateViewport(SDL_Renderer * renderer); +static int GLES_UpdateClipRect(SDL_Renderer * renderer); +static int GLES_RenderClear(SDL_Renderer * renderer); +static int GLES_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int GLES_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int GLES_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); +static int GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); +static int GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GLES_RenderPresent(SDL_Renderer * renderer); +static void GLES_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void GLES_DestroyRenderer(SDL_Renderer * renderer); +static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); +static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); + +typedef struct GLES_FBOList GLES_FBOList; + +struct GLES_FBOList +{ + Uint32 w, h; + GLuint FBO; + GLES_FBOList *next; +}; + + +SDL_RenderDriver GLES_RenderDriver = { + GLES_CreateRenderer, + { + "opengles", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 1, + {SDL_PIXELFORMAT_ABGR8888}, + 0, + 0} +}; + +typedef struct +{ + SDL_GLContext context; + struct { + Uint32 color; + SDL_BlendMode blendMode; + SDL_bool tex_coords; + } current; + +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC_OES SDL_PROC +#include "SDL_glesfuncs.h" +#undef SDL_PROC +#undef SDL_PROC_OES + SDL_bool GL_OES_framebuffer_object_supported; + GLES_FBOList *framebuffers; + GLuint window_framebuffer; + + SDL_bool GL_OES_blend_func_separate_supported; + SDL_bool GL_OES_blend_equation_separate_supported; + SDL_bool GL_OES_blend_subtract_supported; +} GLES_RenderData; + +typedef struct +{ + GLuint texture; + GLenum type; + GLfloat texw; + GLfloat texh; + GLenum format; + GLenum formattype; + void *pixels; + int pitch; + GLES_FBOList *fbo; +} GLES_TextureData; + +static int +GLES_SetError(const char *prefix, GLenum result) +{ + const char *error; + + switch (result) { + case GL_NO_ERROR: + error = "GL_NO_ERROR"; + break; + case GL_INVALID_ENUM: + error = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + error = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + error = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + error = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + error = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + error = "GL_OUT_OF_MEMORY"; + break; + default: + error = "UNKNOWN"; + break; + } + return SDL_SetError("%s: %s", prefix, error); +} + +static int GLES_LoadFunctions(GLES_RenderData * data) +{ +#if SDL_VIDEO_DRIVER_UIKIT +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_ANDROID +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_PANDORA +#define __SDL_NOGETPROCADDR__ +#endif + +#ifdef __SDL_NOGETPROCADDR__ +#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC_OES(ret,func,params) data->func=func; +#else +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if ( ! data->func ) { \ + return SDL_SetError("Couldn't load GLES function %s: %s", #func, SDL_GetError()); \ + } \ + } while ( 0 ); +#define SDL_PROC_OES(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + } while ( 0 ); +#endif /* __SDL_NOGETPROCADDR__ */ + +#include "SDL_glesfuncs.h" +#undef SDL_PROC +#undef SDL_PROC_OES + return 0; +} + +static SDL_GLContext SDL_CurrentContext = NULL; + +static GLES_FBOList * +GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h) +{ + GLES_FBOList *result = data->framebuffers; + while ((result) && ((result->w != w) || (result->h != h)) ) { + result = result->next; + } + if (result == NULL) { + result = SDL_malloc(sizeof(GLES_FBOList)); + result->w = w; + result->h = h; + data->glGenFramebuffersOES(1, &result->FBO); + result->next = data->framebuffers; + data->framebuffers = result; + } + return result; +} + + +static int +GLES_ActivateRenderer(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { + return -1; + } + SDL_CurrentContext = data->context; + + GLES_UpdateViewport(renderer); + } + return 0; +} + +/* This is called if we need to invalidate all of the SDL OpenGL state */ +static void +GLES_ResetState(SDL_Renderer *renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext == data->context) { + GLES_UpdateViewport(renderer); + } else { + GLES_ActivateRenderer(renderer); + } + + data->current.color = 0xffffffff; + data->current.blendMode = SDL_BLENDMODE_INVALID; + data->current.tex_coords = SDL_FALSE; + + data->glDisable(GL_DEPTH_TEST); + data->glDisable(GL_CULL_FACE); + + data->glMatrixMode(GL_MODELVIEW); + data->glLoadIdentity(); + + data->glEnableClientState(GL_VERTEX_ARRAY); + data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + +SDL_Renderer * +GLES_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + + SDL_Renderer *renderer; + GLES_RenderData *data; + GLint value; + Uint32 window_flags; + int profile_mask = 0, major = 0, minor = 0; + SDL_bool changed_window = SDL_FALSE; + + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); + + window_flags = SDL_GetWindowFlags(window); + if (!(window_flags & SDL_WINDOW_OPENGL) || + profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { + + changed_window = SDL_TRUE; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + + if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { + goto error; + } + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + goto error; + } + + data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + GLES_DestroyRenderer(renderer); + SDL_OutOfMemory(); + goto error; + } + + renderer->WindowEvent = GLES_WindowEvent; + renderer->GetOutputSize = GLES_GetOutputSize; + renderer->SupportsBlendMode = GLES_SupportsBlendMode; + renderer->CreateTexture = GLES_CreateTexture; + renderer->UpdateTexture = GLES_UpdateTexture; + renderer->LockTexture = GLES_LockTexture; + renderer->UnlockTexture = GLES_UnlockTexture; + renderer->SetRenderTarget = GLES_SetRenderTarget; + renderer->UpdateViewport = GLES_UpdateViewport; + renderer->UpdateClipRect = GLES_UpdateClipRect; + renderer->RenderClear = GLES_RenderClear; + renderer->RenderDrawPoints = GLES_RenderDrawPoints; + renderer->RenderDrawLines = GLES_RenderDrawLines; + renderer->RenderFillRects = GLES_RenderFillRects; + renderer->RenderCopy = GLES_RenderCopy; + renderer->RenderCopyEx = GLES_RenderCopyEx; + renderer->RenderReadPixels = GLES_RenderReadPixels; + renderer->RenderPresent = GLES_RenderPresent; + renderer->DestroyTexture = GLES_DestroyTexture; + renderer->DestroyRenderer = GLES_DestroyRenderer; + renderer->GL_BindTexture = GLES_BindTexture; + renderer->GL_UnbindTexture = GLES_UnbindTexture; + renderer->info = GLES_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->driverdata = data; + renderer->window = window; + + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GLES_DestroyRenderer(renderer); + goto error; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GLES_DestroyRenderer(renderer); + goto error; + } + + if (GLES_LoadFunctions(data) < 0) { + GLES_DestroyRenderer(renderer); + goto error; + } + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + + /* Android does not report GL_OES_framebuffer_object but the functionality seems to be there anyway */ + if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object") || data->glGenFramebuffersOES) { + data->GL_OES_framebuffer_object_supported = SDL_TRUE; + renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; + + value = 0; + data->glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &value); + data->window_framebuffer = (GLuint)value; + } + data->framebuffers = NULL; + + if (SDL_GL_ExtensionSupported("GL_OES_blend_func_separate")) { + data->GL_OES_blend_func_separate_supported = SDL_TRUE; + } + if (SDL_GL_ExtensionSupported("GL_OES_blend_equation_separate")) { + data->GL_OES_blend_equation_separate_supported = SDL_TRUE; + } + if (SDL_GL_ExtensionSupported("GL_OES_blend_subtract")) { + data->GL_OES_blend_subtract_supported = SDL_TRUE; + } + + /* Set up parameters for rendering */ + GLES_ResetState(renderer); + + return renderer; + +error: + if (changed_window) { + /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); + SDL_RecreateWindow(window, window_flags); + } + return NULL; +} + +static void +GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || + event->event == SDL_WINDOWEVENT_SHOWN || + event->event == SDL_WINDOWEVENT_HIDDEN) { + /* Rebind the context to the window area and update matrices */ + SDL_CurrentContext = NULL; + } + + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + data->glFinish(); + } +} + +static int +GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + return 0; +} + +static GLenum GetBlendFunc(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: + return GL_ZERO; + case SDL_BLENDFACTOR_ONE: + return GL_ONE; + case SDL_BLENDFACTOR_SRC_COLOR: + return GL_SRC_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return GL_ONE_MINUS_SRC_COLOR; + case SDL_BLENDFACTOR_SRC_ALPHA: + return GL_SRC_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return GL_ONE_MINUS_SRC_ALPHA; + case SDL_BLENDFACTOR_DST_COLOR: + return GL_DST_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return GL_ONE_MINUS_DST_COLOR; + case SDL_BLENDFACTOR_DST_ALPHA: + return GL_DST_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return GL_ONE_MINUS_DST_ALPHA; + default: + return GL_INVALID_ENUM; + } +} + +static GLenum GetBlendEquation(SDL_BlendOperation operation) +{ + switch (operation) { + case SDL_BLENDOPERATION_ADD: + return GL_FUNC_ADD_OES; + case SDL_BLENDOPERATION_SUBTRACT: + return GL_FUNC_SUBTRACT_OES; + case SDL_BLENDOPERATION_REV_SUBTRACT: + return GL_FUNC_REVERSE_SUBTRACT_OES; + default: + return GL_INVALID_ENUM; + } +} + +static SDL_bool +GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(colorOperation) == GL_INVALID_ENUM || + GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) { + return SDL_FALSE; + } + if ((srcColorFactor != srcAlphaFactor || dstColorFactor != dstAlphaFactor) && !data->GL_OES_blend_func_separate_supported) { + return SDL_FALSE; + } + if (colorOperation != alphaOperation && !data->GL_OES_blend_equation_separate_supported) { + return SDL_FALSE; + } + if (colorOperation != SDL_BLENDOPERATION_ADD && !data->GL_OES_blend_subtract_supported) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static SDL_INLINE int +power_of_2(int input) +{ + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + +static int +GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *data; + GLint internalFormat; + GLenum format, type; + int texture_w, texture_h; + GLenum scaleMode; + GLenum result; + + GLES_ActivateRenderer(renderer); + + switch (texture->format) { + case SDL_PIXELFORMAT_ABGR8888: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + break; + default: + return SDL_SetError("Texture format not supported"); + } + + data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + return SDL_OutOfMemory(); + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixels = SDL_calloc(1, texture->h * data->pitch); + if (!data->pixels) { + SDL_free(data); + return SDL_OutOfMemory(); + } + } + + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + if (!renderdata->GL_OES_framebuffer_object_supported) { + SDL_free(data); + return SDL_SetError("GL_OES_framebuffer_object not supported"); + } + data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h); + } else { + data->fbo = NULL; + } + + + renderdata->glGetError(); + renderdata->glEnable(GL_TEXTURE_2D); + renderdata->glGenTextures(1, &data->texture); + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + SDL_free(data); + return GLES_SetError("glGenTextures()", result); + } + + data->type = GL_TEXTURE_2D; + /* no NPOV textures allowed in OpenGL ES (yet) */ + texture_w = power_of_2(texture->w); + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) texture->w / texture_w; + data->texh = (GLfloat) texture->h / texture_h; + + data->format = format; + data->formattype = type; + scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; + renderdata->glBindTexture(data->type, data->texture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, NULL); + renderdata->glDisable(GL_TEXTURE_2D); + + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + SDL_free(data); + return GLES_SetError("glTexImage2D()", result); + } + + texture->driverdata = data; + return 0; +} + +static int +GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + Uint8 *blob = NULL; + Uint8 *src; + int srcPitch; + int y; + + GLES_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + /* Reformat the texture data into a tightly packed array */ + srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + src = (Uint8 *)pixels; + if (pitch != srcPitch) { + blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); + if (!blob) { + return SDL_OutOfMemory(); + } + src = blob; + for (y = 0; y < rect->h; ++y) { + SDL_memcpy(src, pixels, srcPitch); + src += srcPitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; + } + + /* Create a texture subimage with the supplied data */ + renderdata->glGetError(); + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glTexSubImage2D(data->type, + 0, + rect->x, + rect->y, + rect->w, + rect->h, + data->format, + data->formattype, + src); + renderdata->glDisable(data->type); + SDL_free(blob); + + if (renderdata->glGetError() != GL_NO_ERROR) { + return SDL_SetError("Failed to update texture"); + } + return 0; +} + +static int +GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = data->pitch; + return 0; +} + +static void +GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + SDL_Rect rect; + + /* We do whole texture updates, at least for now */ + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + GLES_UpdateTexture(renderer, texture, &rect, data->pixels, data->pitch); +} + +static int +GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = NULL; + GLenum status; + + if (!data->GL_OES_framebuffer_object_supported) { + return SDL_SetError("Can't enable render target support in this renderer"); + } + + if (texture == NULL) { + data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); + return 0; + } + + texturedata = (GLES_TextureData *) texture->driverdata; + data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, texturedata->fbo->FBO); + /* TODO: check if texture pixel format allows this operation */ + data->glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, texturedata->type, texturedata->texture, 0); + /* Check FBO status */ + status = data->glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); + if (status != GL_FRAMEBUFFER_COMPLETE_OES) { + return SDL_SetError("glFramebufferTexture2DOES() failed"); + } + return 0; +} + +static int +GLES_UpdateViewport(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + if (renderer->target) { + data->glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h), + renderer->viewport.w, renderer->viewport.h); + } + + data->glMatrixMode(GL_PROJECTION); + data->glLoadIdentity(); + if (renderer->viewport.w && renderer->viewport.h) { + if (renderer->target) { + data->glOrthof((GLfloat) 0, + (GLfloat) renderer->viewport.w, + (GLfloat) 0, + (GLfloat) renderer->viewport.h, + 0.0, 1.0); + } else { + data->glOrthof((GLfloat) 0, + (GLfloat) renderer->viewport.w, + (GLfloat) renderer->viewport.h, + (GLfloat) 0, + 0.0, 1.0); + } + } + data->glMatrixMode(GL_MODELVIEW); + + return 0; +} + +static int +GLES_UpdateClipRect(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the clip rect after we rebind the context */ + return 0; + } + + if (renderer->clipping_enabled) { + const SDL_Rect *rect = &renderer->clip_rect; + data->glEnable(GL_SCISSOR_TEST); + if (renderer->target) { + data->glScissor(renderer->viewport.x + rect->x, renderer->viewport.y + rect->y, rect->w, rect->h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h); + } + } else { + data->glDisable(GL_SCISSOR_TEST); + } + return 0; +} + +static void +GLES_SetColor(GLES_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b); + + if (color != data->current.color) { + data->glColor4f((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); + data->current.color = color; + } +} + +static void +GLES_SetBlendMode(GLES_RenderData * data, SDL_BlendMode blendMode) +{ + if (blendMode != data->current.blendMode) { + if (blendMode == SDL_BLENDMODE_NONE) { + data->glDisable(GL_BLEND); + } else { + data->glEnable(GL_BLEND); + if (data->GL_OES_blend_func_separate_supported) { + data->glBlendFuncSeparateOES(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode))); + } else { + data->glBlendFunc(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode))); + } + if (data->GL_OES_blend_equation_separate_supported) { + data->glBlendEquationSeparateOES(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)), + GetBlendEquation(SDL_GetBlendModeAlphaOperation(blendMode))); + } else if (data->GL_OES_blend_subtract_supported) { + data->glBlendEquationOES(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode))); + } + } + data->current.blendMode = blendMode; + } +} + +static void +GLES_SetTexCoords(GLES_RenderData * data, SDL_bool enabled) +{ + if (enabled != data->current.tex_coords) { + if (enabled) { + data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); + } else { + data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + data->current.tex_coords = enabled; + } +} + +static void +GLES_SetDrawingState(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + GLES_ActivateRenderer(renderer); + + GLES_SetColor(data, (GLfloat) renderer->r, + (GLfloat) renderer->g, + (GLfloat) renderer->b, + (GLfloat) renderer->a); + + GLES_SetBlendMode(data, renderer->blendMode); + + GLES_SetTexCoords(data, SDL_FALSE); +} + +static int +GLES_RenderClear(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + GLES_ActivateRenderer(renderer); + + data->glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } + + data->glClear(GL_COLOR_BUFFER_BIT); + + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + + return 0; +} + +static int +GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLfloat *vertices; + int idx; + + GLES_SetDrawingState(renderer); + + /* Emit the specified vertices as points */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) { + GLfloat x = points[idx].x + 0.5f; + GLfloat y = points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + + data->glVertexPointer(2, GL_FLOAT, 0, vertices); + data->glDrawArrays(GL_POINTS, 0, count); + SDL_stack_free(vertices); + return 0; +} + +static int +GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLfloat *vertices; + int idx; + + GLES_SetDrawingState(renderer); + + /* Emit a line strip including the specified vertices */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) { + GLfloat x = points[idx].x + 0.5f; + GLfloat y = points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + + data->glVertexPointer(2, GL_FLOAT, 0, vertices); + if (count > 2 && + points[0].x == points[count-1].x && points[0].y == points[count-1].y) { + /* GL_LINE_LOOP takes care of the final segment */ + --count; + data->glDrawArrays(GL_LINE_LOOP, 0, count); + } else { + data->glDrawArrays(GL_LINE_STRIP, 0, count); + /* We need to close the endpoint of the line */ + data->glDrawArrays(GL_POINTS, count-1, 1); + } + SDL_stack_free(vertices); + + return 0; +} + +static int +GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + int i; + + GLES_SetDrawingState(renderer); + + for (i = 0; i < count; ++i) { + const SDL_FRect *rect = &rects[i]; + GLfloat minx = rect->x; + GLfloat maxx = rect->x + rect->w; + GLfloat miny = rect->y; + GLfloat maxy = rect->y + rect->h; + GLfloat vertices[8]; + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + data->glVertexPointer(2, GL_FLOAT, 0, vertices); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + + return 0; +} + +static int +GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLfloat minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + GLfloat vertices[8]; + GLfloat texCoords[8]; + + GLES_ActivateRenderer(renderer); + + data->glEnable(GL_TEXTURE_2D); + + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a); + } else { + GLES_SetColor(data, 255, 255, 255, 255); + } + + GLES_SetBlendMode(data, texture->blendMode); + + GLES_SetTexCoords(data, SDL_TRUE); + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + texCoords[0] = minu; + texCoords[1] = minv; + texCoords[2] = maxu; + texCoords[3] = minv; + texCoords[4] = minu; + texCoords[5] = maxv; + texCoords[6] = maxu; + texCoords[7] = maxv; + + data->glVertexPointer(2, GL_FLOAT, 0, vertices); + data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + data->glDisable(GL_TEXTURE_2D); + + return 0; +} + +static int +GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLfloat minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + GLfloat centerx, centery; + GLfloat vertices[8]; + GLfloat texCoords[8]; + + + GLES_ActivateRenderer(renderer); + + data->glEnable(GL_TEXTURE_2D); + + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a); + } else { + GLES_SetColor(data, 255, 255, 255, 255); + } + + GLES_SetBlendMode(data, texture->blendMode); + + GLES_SetTexCoords(data, SDL_TRUE); + + centerx = center->x; + centery = center->y; + + /* Rotate and translate */ + data->glPushMatrix(); + data->glTranslatef(dstrect->x + centerx, dstrect->y + centery, 0.0f); + data->glRotatef((GLfloat)angle, 0.0f, 0.0f, 1.0f); + + if (flip & SDL_FLIP_HORIZONTAL) { + minx = dstrect->w - centerx; + maxx = -centerx; + } else { + minx = -centerx; + maxx = dstrect->w - centerx; + } + + if (flip & SDL_FLIP_VERTICAL) { + miny = dstrect->h - centery; + maxy = -centery; + } else { + miny = -centery; + maxy = dstrect->h - centery; + } + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + texCoords[0] = minu; + texCoords[1] = minv; + texCoords[2] = maxu; + texCoords[3] = minv; + texCoords[4] = minu; + texCoords[5] = maxv; + texCoords[6] = maxu; + texCoords[7] = maxv; + data->glVertexPointer(2, GL_FLOAT, 0, vertices); + data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glPopMatrix(); + data->glDisable(GL_TEXTURE_2D); + + return 0; +} + +static int +GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + + SDL_GetRendererOutputSize(renderer, &w, &h); + + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + + data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + + /* Flip the rows to be top-down if necessary */ + if (!renderer->target) { + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + } + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GLES_RenderPresent(SDL_Renderer * renderer) +{ + GLES_ActivateRenderer(renderer); + + SDL_GL_SwapWindow(renderer->window); +} + +static void +GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + GLES_ActivateRenderer(renderer); + + if (!data) { + return; + } + if (data->texture) { + renderdata->glDeleteTextures(1, &data->texture); + } + SDL_free(data->pixels); + SDL_free(data); + texture->driverdata = NULL; +} + +static void +GLES_DestroyRenderer(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (data) { + if (data->context) { + while (data->framebuffers) { + GLES_FBOList *nextnode = data->framebuffers->next; + data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; + } + SDL_GL_DeleteContext(data->context); + } + SDL_free(data); + } + SDL_free(renderer); +} + +static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLES_ActivateRenderer(renderer); + + data->glEnable(GL_TEXTURE_2D); + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texw) { + *texw = (float)texturedata->texw; + } + if (texh) { + *texh = (float)texturedata->texh; + } + + return 0; +} + +static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLES_ActivateRenderer(renderer); + data->glDisable(texturedata->type); + + return 0; +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengles2/SDL_gles2funcs.h b/source/3rd-party/SDL2/src/render/opengles2/SDL_gles2funcs.h new file mode 100644 index 0000000..b6a1436 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles2/SDL_gles2funcs.h @@ -0,0 +1,80 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +SDL_PROC(void, glActiveTexture, (GLenum)) +SDL_PROC(void, glAttachShader, (GLuint, GLuint)) +SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *)) +SDL_PROC(void, glBindTexture, (GLenum, GLuint)) +SDL_PROC(void, glBlendEquationSeparate, (GLenum, GLenum)) +SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum)) +SDL_PROC(void, glClear, (GLbitfield)) +SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) +SDL_PROC(void, glCompileShader, (GLuint)) +SDL_PROC(GLuint, glCreateProgram, (void)) +SDL_PROC(GLuint, glCreateShader, (GLenum)) +SDL_PROC(void, glDeleteProgram, (GLuint)) +SDL_PROC(void, glDeleteShader, (GLuint)) +SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *)) +SDL_PROC(void, glDisable, (GLenum)) +SDL_PROC(void, glDisableVertexAttribArray, (GLuint)) +SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei)) +SDL_PROC(void, glEnable, (GLenum)) +SDL_PROC(void, glEnableVertexAttribArray, (GLuint)) +SDL_PROC(void, glFinish, (void)) +SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *)) +SDL_PROC(void, glGenTextures, (GLsizei, GLuint *)) +SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *)) +SDL_PROC(const GLubyte *, glGetString, (GLenum)) +SDL_PROC(GLenum, glGetError, (void)) +SDL_PROC(void, glGetIntegerv, (GLenum, GLint *)) +SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *)) +SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *)) +SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *)) +SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *)) +SDL_PROC(void, glLinkProgram, (GLuint)) +SDL_PROC(void, glPixelStorei, (GLenum, GLint)) +SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*)) +SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) +SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei)) +#if __NACL__ || __ANDROID__ +SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *)) +#else +SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *)) +#endif +SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *)) +SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint)) +SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) +SDL_PROC(void, glUniform1i, (GLint, GLint)) +SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *)) +SDL_PROC(void, glUseProgram, (GLuint)) +SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *)) +SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei)) +SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint)) +SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint)) +SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum)) +SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *)) +SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *)) +SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*)) +SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *)) +SDL_PROC(void, glBindBuffer, (GLenum, GLuint)) +SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum)) +SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *)) diff --git a/source/3rd-party/SDL2/src/render/opengles2/SDL_render_gles2.c b/source/3rd-party/SDL2/src/render/opengles2/SDL_render_gles2.c new file mode 100644 index 0000000..fe51b9a --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles2/SDL_render_gles2.c @@ -0,0 +1,2261 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED + +#include "SDL_assert.h" +#include "SDL_hints.h" +#include "SDL_opengles2.h" +#include "../SDL_sysrender.h" +#include "../../video/SDL_blit.h" +#include "SDL_shaders_gles2.h" + +/* !!! FIXME: Emscripten makes these into WebGL calls, and WebGL doesn't offer + !!! FIXME: client-side arrays (without an Emscripten compatibility hack, + !!! FIXME: at least), but the current VBO code here is dramatically + !!! FIXME: slower on actual iOS devices, even though the iOS Simulator + !!! FIXME: is okay. Some time after 2.0.4 ships, we should revisit this, + !!! FIXME: fix the performance bottleneck, and make everything use VBOs. +*/ +#ifdef __EMSCRIPTEN__ +#define SDL_GLES2_USE_VBOS 1 +#else +#define SDL_GLES2_USE_VBOS 0 +#endif + +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ +#define RENDERER_CONTEXT_MAJOR 2 +#define RENDERER_CONTEXT_MINOR 0 + +/* Used to re-create the window with OpenGL ES capability */ +extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); + +/************************************************************************************************* + * Bootstrap data * + *************************************************************************************************/ + +static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags); + +SDL_RenderDriver GLES2_RenderDriver = { + GLES2_CreateRenderer, + { + "opengles2", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 4, + { + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_BGR888 + }, + 0, + 0 + } +}; + +/************************************************************************************************* + * Context structures * + *************************************************************************************************/ + +typedef struct GLES2_FBOList GLES2_FBOList; + +struct GLES2_FBOList +{ + Uint32 w, h; + GLuint FBO; + GLES2_FBOList *next; +}; + +typedef struct GLES2_TextureData +{ + GLenum texture; + GLenum texture_type; + GLenum pixel_format; + GLenum pixel_type; + void *pixel_data; + int pitch; + /* YUV texture support */ + SDL_bool yuv; + SDL_bool nv12; + GLenum texture_v; + GLenum texture_u; + GLES2_FBOList *fbo; +} GLES2_TextureData; + +typedef struct GLES2_ShaderCacheEntry +{ + GLuint id; + GLES2_ShaderType type; + const GLES2_ShaderInstance *instance; + int references; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; + struct GLES2_ShaderCacheEntry *prev; + struct GLES2_ShaderCacheEntry *next; +} GLES2_ShaderCacheEntry; + +typedef struct GLES2_ShaderCache +{ + int count; + GLES2_ShaderCacheEntry *head; +} GLES2_ShaderCache; + +typedef struct GLES2_ProgramCacheEntry +{ + GLuint id; + GLES2_ShaderCacheEntry *vertex_shader; + GLES2_ShaderCacheEntry *fragment_shader; + GLuint uniform_locations[16]; + Uint8 color_r, color_g, color_b, color_a; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; + GLfloat projection[4][4]; + struct GLES2_ProgramCacheEntry *prev; + struct GLES2_ProgramCacheEntry *next; +} GLES2_ProgramCacheEntry; + +typedef struct GLES2_ProgramCache +{ + int count; + GLES2_ProgramCacheEntry *head; + GLES2_ProgramCacheEntry *tail; +} GLES2_ProgramCache; + +typedef enum +{ + GLES2_ATTRIBUTE_POSITION = 0, + GLES2_ATTRIBUTE_TEXCOORD = 1, + GLES2_ATTRIBUTE_ANGLE = 2, + GLES2_ATTRIBUTE_CENTER = 3, +} GLES2_Attribute; + +typedef enum +{ + GLES2_UNIFORM_PROJECTION, + GLES2_UNIFORM_TEXTURE, + GLES2_UNIFORM_MODULATION, + GLES2_UNIFORM_COLOR, + GLES2_UNIFORM_TEXTURE_U, + GLES2_UNIFORM_TEXTURE_V +} GLES2_Uniform; + +typedef enum +{ + GLES2_IMAGESOURCE_SOLID, + GLES2_IMAGESOURCE_TEXTURE_ABGR, + GLES2_IMAGESOURCE_TEXTURE_ARGB, + GLES2_IMAGESOURCE_TEXTURE_RGB, + GLES2_IMAGESOURCE_TEXTURE_BGR, + GLES2_IMAGESOURCE_TEXTURE_YUV, + GLES2_IMAGESOURCE_TEXTURE_NV12, + GLES2_IMAGESOURCE_TEXTURE_NV21, + GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES +} GLES2_ImageSource; + +typedef struct GLES2_DriverContext +{ + SDL_GLContext *context; + + SDL_bool debug_enabled; + + struct { + SDL_BlendMode blendMode; + SDL_bool tex_coords; + } current; + +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#include "SDL_gles2funcs.h" +#undef SDL_PROC + GLES2_FBOList *framebuffers; + GLuint window_framebuffer; + + int shader_format_count; + GLenum *shader_formats; + GLES2_ShaderCache shader_cache; + GLES2_ProgramCache program_cache; + GLES2_ProgramCacheEntry *current_program; + Uint8 clear_r, clear_g, clear_b, clear_a; + +#if SDL_GLES2_USE_VBOS + GLuint vertex_buffers[4]; + GLsizeiptr vertex_buffer_size[4]; +#endif +} GLES2_DriverContext; + +#define GLES2_MAX_CACHED_PROGRAMS 8 + + +SDL_FORCE_INLINE const char* +GL_TranslateError (GLenum error) +{ +#define GL_ERROR_TRANSLATE(e) case e: return #e; + switch (error) { + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) + default: + return "UNKNOWN"; +} +#undef GL_ERROR_TRANSLATE +} + +SDL_FORCE_INLINE void +GL_ClearErrors(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + + if (!data->debug_enabled) { + return; + } + while (data->glGetError() != GL_NO_ERROR) { + continue; + } +} + +SDL_FORCE_INLINE int +GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + int ret = 0; + + if (!data->debug_enabled) { + return 0; + } + /* check gl errors (can return multiple errors) */ + for (;;) { + GLenum error = data->glGetError(); + if (error != GL_NO_ERROR) { + if (prefix == NULL || prefix[0] == '\0') { + prefix = "generic"; + } + SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); + ret = -1; + } else { + break; + } + } + return ret; +} + +#if 0 +#define GL_CheckError(prefix, renderer) +#else +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION) +#endif + + +/************************************************************************************************* + * Renderer state APIs * + *************************************************************************************************/ + +static int GLES2_ActivateRenderer(SDL_Renderer *renderer); +static void GLES2_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GLES2_UpdateViewport(SDL_Renderer * renderer); +static void GLES2_DestroyRenderer(SDL_Renderer *renderer); +static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer); + + +static SDL_GLContext SDL_CurrentContext = NULL; + +static int GLES2_LoadFunctions(GLES2_DriverContext * data) +{ +#if SDL_VIDEO_DRIVER_UIKIT +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_ANDROID +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_PANDORA +#define __SDL_NOGETPROCADDR__ +#endif + +#if defined __SDL_NOGETPROCADDR__ +#define SDL_PROC(ret,func,params) data->func=func; +#else +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if ( ! data->func ) { \ + return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ + } \ + } while ( 0 ); +#endif /* __SDL_NOGETPROCADDR__ */ + +#include "SDL_gles2funcs.h" +#undef SDL_PROC + return 0; +} + +static GLES2_FBOList * +GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h) +{ + GLES2_FBOList *result = data->framebuffers; + while ((result) && ((result->w != w) || (result->h != h)) ) { + result = result->next; + } + if (result == NULL) { + result = SDL_malloc(sizeof(GLES2_FBOList)); + result->w = w; + result->h = h; + data->glGenFramebuffers(1, &result->FBO); + result->next = data->framebuffers; + data->framebuffers = result; + } + return result; +} + +static int +GLES2_ActivateRenderer(SDL_Renderer * renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* Null out the current program to ensure we set it again */ + data->current_program = NULL; + + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { + return -1; + } + SDL_CurrentContext = data->context; + + GLES2_UpdateViewport(renderer); + } + + GL_ClearErrors(renderer); + + return 0; +} + +static void +GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || + event->event == SDL_WINDOWEVENT_SHOWN || + event->event == SDL_WINDOWEVENT_HIDDEN) { + /* Rebind the context to the window area */ + SDL_CurrentContext = NULL; + } + + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + data->glFinish(); + } +} + +static int +GLES2_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + return 0; +} + +static GLenum GetBlendFunc(SDL_BlendFactor factor) +{ + switch (factor) { + case SDL_BLENDFACTOR_ZERO: + return GL_ZERO; + case SDL_BLENDFACTOR_ONE: + return GL_ONE; + case SDL_BLENDFACTOR_SRC_COLOR: + return GL_SRC_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return GL_ONE_MINUS_SRC_COLOR; + case SDL_BLENDFACTOR_SRC_ALPHA: + return GL_SRC_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return GL_ONE_MINUS_SRC_ALPHA; + case SDL_BLENDFACTOR_DST_COLOR: + return GL_DST_COLOR; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return GL_ONE_MINUS_DST_COLOR; + case SDL_BLENDFACTOR_DST_ALPHA: + return GL_DST_ALPHA; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return GL_ONE_MINUS_DST_ALPHA; + default: + return GL_INVALID_ENUM; + } +} + +static GLenum GetBlendEquation(SDL_BlendOperation operation) +{ + switch (operation) { + case SDL_BLENDOPERATION_ADD: + return GL_FUNC_ADD; + case SDL_BLENDOPERATION_SUBTRACT: + return GL_FUNC_SUBTRACT; + case SDL_BLENDOPERATION_REV_SUBTRACT: + return GL_FUNC_REVERSE_SUBTRACT; + default: + return GL_INVALID_ENUM; + } +} + +static SDL_bool +GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); + SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); + SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); + SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); + SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); + SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); + + if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(colorOperation) == GL_INVALID_ENUM || + GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM || + GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM || + GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int +GLES2_UpdateViewport(SDL_Renderer * renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + if (renderer->target) { + data->glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h), + renderer->viewport.w, renderer->viewport.h); + } + + if (data->current_program) { + GLES2_SetOrthographicProjection(renderer); + } + return GL_CheckError("", renderer); +} + +static int +GLES2_UpdateClipRect(SDL_Renderer * renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the clip rect after we rebind the context */ + return 0; + } + + if (renderer->clipping_enabled) { + const SDL_Rect *rect = &renderer->clip_rect; + data->glEnable(GL_SCISSOR_TEST); + if (renderer->target) { + data->glScissor(renderer->viewport.x + rect->x, renderer->viewport.y + rect->y, rect->w, rect->h); + } else { + int w, h; + + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h); + } + } else { + data->glDisable(GL_SCISSOR_TEST); + } + return 0; +} + +static void +GLES2_DestroyRenderer(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + /* Deallocate everything */ + if (data) { + GLES2_ActivateRenderer(renderer); + + { + GLES2_ShaderCacheEntry *entry; + GLES2_ShaderCacheEntry *next; + entry = data->shader_cache.head; + while (entry) { + data->glDeleteShader(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } + { + GLES2_ProgramCacheEntry *entry; + GLES2_ProgramCacheEntry *next; + entry = data->program_cache.head; + while (entry) { + data->glDeleteProgram(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } + if (data->context) { + while (data->framebuffers) { + GLES2_FBOList *nextnode = data->framebuffers->next; + data->glDeleteFramebuffers(1, &data->framebuffers->FBO); + GL_CheckError("", renderer); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; + } + SDL_GL_DeleteContext(data->context); + } + SDL_free(data->shader_formats); + SDL_free(data); + } + SDL_free(renderer); +} + +/************************************************************************************************* + * Texture APIs * + *************************************************************************************************/ + +static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch); +static int GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch); +static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); + +static int +GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *renderdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *data; + GLenum format; + GLenum type; + GLenum scaleMode; + + GLES2_ActivateRenderer(renderer); + + /* Determine the corresponding GLES texture format params */ + switch (texture->format) + { + case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGR888: + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + format = GL_LUMINANCE; + type = GL_UNSIGNED_BYTE; + break; +#ifdef GL_TEXTURE_EXTERNAL_OES + case SDL_PIXELFORMAT_EXTERNAL_OES: + format = GL_NONE; + type = GL_NONE; + break; +#endif + default: + return SDL_SetError("Texture format not supported"); + } + + if (texture->format == SDL_PIXELFORMAT_EXTERNAL_OES && + texture->access != SDL_TEXTUREACCESS_STATIC) { + return SDL_SetError("Unsupported texture access for SDL_PIXELFORMAT_EXTERNAL_OES"); + } + + /* Allocate a texture struct */ + data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); + if (!data) { + return SDL_OutOfMemory(); + } + data->texture = 0; +#ifdef GL_TEXTURE_EXTERNAL_OES + data->texture_type = (texture->format == SDL_PIXELFORMAT_EXTERNAL_OES) ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; +#else + data->texture_type = GL_TEXTURE_2D; +#endif + data->pixel_format = format; + data->pixel_type = type; + data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12)); + data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21)); + data->texture_u = 0; + data->texture_v = 0; + scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; + + /* Allocate a blob for image renderdata */ + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + size_t size; + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + size = texture->h * data->pitch; + if (data->yuv) { + /* Need to add size for the U and V planes */ + size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); + } + if (data->nv12) { + /* Need to add size for the U/V plane */ + size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); + } + data->pixel_data = SDL_calloc(1, size); + if (!data->pixel_data) { + SDL_free(data); + return SDL_OutOfMemory(); + } + } + + /* Allocate the texture */ + GL_CheckError("", renderer); + + if (data->yuv) { + renderdata->glGenTextures(1, &data->texture_v); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + renderdata->glActiveTexture(GL_TEXTURE2); + renderdata->glBindTexture(data->texture_type, data->texture_v); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL); + + renderdata->glGenTextures(1, &data->texture_u); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + renderdata->glActiveTexture(GL_TEXTURE1); + renderdata->glBindTexture(data->texture_type, data->texture_u); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; + } + } + + if (data->nv12) { + renderdata->glGenTextures(1, &data->texture_u); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + renderdata->glActiveTexture(GL_TEXTURE1); + renderdata->glBindTexture(data->texture_type, data->texture_u); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, GL_LUMINANCE_ALPHA, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; + } + } + + renderdata->glGenTextures(1, &data->texture); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + texture->driverdata = data; + renderdata->glActiveTexture(GL_TEXTURE0); + renderdata->glBindTexture(data->texture_type, data->texture); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (texture->format != SDL_PIXELFORMAT_EXTERNAL_OES) { + renderdata->glTexImage2D(data->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; + } + } + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); + } else { + data->fbo = NULL; + } + + return GL_CheckError("", renderer); +} + +static int +GLES2_TexSubImage2D(GLES2_DriverContext *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp) +{ + Uint8 *blob = NULL; + Uint8 *src; + int src_pitch; + int y; + + if ((width == 0) || (height == 0) || (bpp == 0)) { + return 0; /* nothing to do */ + } + + /* Reformat the texture data into a tightly packed array */ + src_pitch = width * bpp; + src = (Uint8 *)pixels; + if (pitch != src_pitch) { + blob = (Uint8 *)SDL_malloc(src_pitch * height); + if (!blob) { + return SDL_OutOfMemory(); + } + src = blob; + for (y = 0; y < height; ++y) + { + SDL_memcpy(src, pixels, src_pitch); + src += src_pitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; + } + + data->glTexSubImage2D(target, 0, xoffset, yoffset, width, height, format, type, src); + if (blob) { + SDL_free(blob); + } + return 0; +} + +static int +GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + /* Create a texture subimage with the supplied data */ + data->glBindTexture(tdata->texture_type, tdata->texture); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + pixels, pitch, SDL_BYTESPERPIXEL(texture->format)); + + if (tdata->yuv) { + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + if (texture->format == SDL_PIXELFORMAT_YV12) { + data->glBindTexture(tdata->texture_type, tdata->texture_v); + } else { + data->glBindTexture(tdata->texture_type, tdata->texture_u); + } + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + pixels, (pitch + 1) / 2, 1); + + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1)/2)); + if (texture->format == SDL_PIXELFORMAT_YV12) { + data->glBindTexture(tdata->texture_type, tdata->texture_u); + } else { + data->glBindTexture(tdata->texture_type, tdata->texture_v); + } + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + pixels, (pitch + 1) / 2, 1); + } + + if (tdata->nv12) { + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + data->glBindTexture(tdata->texture_type, tdata->texture_u); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + pixels, 2 * ((pitch + 1) / 2), 2); + } + + return GL_CheckError("glTexSubImage2D()", renderer); +} + +static int +GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + data->glBindTexture(tdata->texture_type, tdata->texture_v); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + Vplane, Vpitch, 1); + + data->glBindTexture(tdata->texture_type, tdata->texture_u); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + Uplane, Upitch, 1); + + data->glBindTexture(tdata->texture_type, tdata->texture); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + Yplane, Ypitch, 1); + + return GL_CheckError("glTexSubImage2D()", renderer); +} + +static int +GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + /* Retrieve the buffer/pitch for the specified region */ + *pixels = (Uint8 *)tdata->pixel_data + + (tdata->pitch * rect->y) + + (rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = tdata->pitch; + + return 0; +} + +static void +GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + SDL_Rect rect; + + /* We do whole texture updates, at least for now */ + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch); +} + +static int +GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + GLES2_TextureData *texturedata = NULL; + GLenum status; + + if (texture == NULL) { + data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); + } else { + texturedata = (GLES2_TextureData *) texture->driverdata; + data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO); + /* TODO: check if texture pixel format allows this operation */ + data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0); + /* Check FBO status */ + status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + return SDL_SetError("glFramebufferTexture2D() failed"); + } + } + return 0; +} + +static void +GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Destroy the texture */ + if (tdata) { + data->glDeleteTextures(1, &tdata->texture); + if (tdata->texture_v) { + data->glDeleteTextures(1, &tdata->texture_v); + } + if (tdata->texture_u) { + data->glDeleteTextures(1, &tdata->texture_u); + } + SDL_free(tdata->pixel_data); + SDL_free(tdata); + texture->driverdata = NULL; + } +} + +/************************************************************************************************* + * Shader management functions * + *************************************************************************************************/ + +static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type); +static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry); +static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer, + GLES2_ShaderCacheEntry *vertex, + GLES2_ShaderCacheEntry *fragment); +static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, int w, int h); + +static GLES2_ProgramCacheEntry * +GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, + GLES2_ShaderCacheEntry *fragment) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_ProgramCacheEntry *entry; + GLES2_ShaderCacheEntry *shaderEntry; + GLint linkSuccessful; + + /* Check if we've already cached this program */ + entry = data->program_cache.head; + while (entry) { + if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) { + break; + } + entry = entry->next; + } + if (entry) { + if (data->program_cache.head != entry) { + if (entry->next) { + entry->next->prev = entry->prev; + } + if (entry->prev) { + entry->prev->next = entry->next; + } + entry->prev = NULL; + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; + data->program_cache.head = entry; + } + return entry; + } + + /* Create a program cache entry */ + entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); + if (!entry) { + SDL_OutOfMemory(); + return NULL; + } + entry->vertex_shader = vertex; + entry->fragment_shader = fragment; + + /* Create the program and link it */ + entry->id = data->glCreateProgram(); + data->glAttachShader(entry->id, vertex->id); + data->glAttachShader(entry->id, fragment->id); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); + data->glLinkProgram(entry->id); + data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); + if (!linkSuccessful) { + data->glDeleteProgram(entry->id); + SDL_free(entry); + SDL_SetError("Failed to link shader program"); + return NULL; + } + + /* Predetermine locations of uniform variables */ + entry->uniform_locations[GLES2_UNIFORM_PROJECTION] = + data->glGetUniformLocation(entry->id, "u_projection"); + entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V] = + data->glGetUniformLocation(entry->id, "u_texture_v"); + entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U] = + data->glGetUniformLocation(entry->id, "u_texture_u"); + entry->uniform_locations[GLES2_UNIFORM_TEXTURE] = + data->glGetUniformLocation(entry->id, "u_texture"); + entry->uniform_locations[GLES2_UNIFORM_MODULATION] = + data->glGetUniformLocation(entry->id, "u_modulation"); + entry->uniform_locations[GLES2_UNIFORM_COLOR] = + data->glGetUniformLocation(entry->id, "u_color"); + + entry->modulation_r = entry->modulation_g = entry->modulation_b = entry->modulation_a = 255; + entry->color_r = entry->color_g = entry->color_b = entry->color_a = 255; + + data->glUseProgram(entry->id); + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V], 2); /* always texture unit 2. */ + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U], 1); /* always texture unit 1. */ + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + data->glUniformMatrix4fv(entry->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection); + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_MODULATION], 1.0f, 1.0f, 1.0f, 1.0f); + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f); + + /* Cache the linked program */ + if (data->program_cache.head) { + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; + } else { + data->program_cache.tail = entry; + } + data->program_cache.head = entry; + ++data->program_cache.count; + + /* Increment the refcount of the shaders we're using */ + ++vertex->references; + ++fragment->references; + + /* Evict the last entry from the cache if we exceed the limit */ + if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { + shaderEntry = data->program_cache.tail->vertex_shader; + if (--shaderEntry->references <= 0) { + GLES2_EvictShader(renderer, shaderEntry); + } + shaderEntry = data->program_cache.tail->fragment_shader; + if (--shaderEntry->references <= 0) { + GLES2_EvictShader(renderer, shaderEntry); + } + data->glDeleteProgram(data->program_cache.tail->id); + data->program_cache.tail = data->program_cache.tail->prev; + SDL_free(data->program_cache.tail->next); + data->program_cache.tail->next = NULL; + --data->program_cache.count; + } + return entry; +} + +static GLES2_ShaderCacheEntry * +GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + const GLES2_Shader *shader; + const GLES2_ShaderInstance *instance = NULL; + GLES2_ShaderCacheEntry *entry = NULL; + GLint compileSuccessful = GL_FALSE; + int i, j; + + /* Find the corresponding shader */ + shader = GLES2_GetShader(type); + if (!shader) { + SDL_SetError("No shader matching the requested characteristics was found"); + return NULL; + } + + /* Find a matching shader instance that's supported on this hardware */ + for (i = 0; i < shader->instance_count && !instance; ++i) { + for (j = 0; j < data->shader_format_count && !instance; ++j) { + if (!shader->instances[i]) { + continue; + } + if (shader->instances[i]->format != data->shader_formats[j]) { + continue; + } + instance = shader->instances[i]; + } + } + if (!instance) { + SDL_SetError("The specified shader cannot be loaded on the current platform"); + return NULL; + } + + /* Check if we've already cached this shader */ + entry = data->shader_cache.head; + while (entry) { + if (entry->instance == instance) { + break; + } + entry = entry->next; + } + if (entry) { + return entry; + } + + /* Create a shader cache entry */ + entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry)); + if (!entry) { + SDL_OutOfMemory(); + return NULL; + } + entry->type = type; + entry->instance = instance; + + /* Compile or load the selected shader instance */ + entry->id = data->glCreateShader(instance->type); + if (instance->format == (GLenum)-1) { + data->glShaderSource(entry->id, 1, (const char **)(char *)&instance->data, NULL); + data->glCompileShader(entry->id); + data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); + } else { + data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); + compileSuccessful = GL_TRUE; + } + if (!compileSuccessful) { + char *info = NULL; + int length = 0; + + data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); + if (length > 0) { + info = SDL_stack_alloc(char, length); + if (info) { + data->glGetShaderInfoLog(entry->id, length, &length, info); + } + } + if (info) { + SDL_SetError("Failed to load the shader: %s", info); + SDL_stack_free(info); + } else { + SDL_SetError("Failed to load the shader"); + } + data->glDeleteShader(entry->id); + SDL_free(entry); + return NULL; + } + + /* Link the shader entry in at the front of the cache */ + if (data->shader_cache.head) { + entry->next = data->shader_cache.head; + data->shader_cache.head->prev = entry; + } + data->shader_cache.head = entry; + ++data->shader_cache.count; + return entry; +} + +static void +GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + /* Unlink the shader from the cache */ + if (entry->next) { + entry->next->prev = entry->prev; + } + if (entry->prev) { + entry->prev->next = entry->next; + } + if (data->shader_cache.head == entry) { + data->shader_cache.head = entry->next; + } + --data->shader_cache.count; + + /* Deallocate the shader */ + data->glDeleteShader(entry->id); + SDL_free(entry); +} + +static int +GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, int w, int h) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_ShaderCacheEntry *vertex = NULL; + GLES2_ShaderCacheEntry *fragment = NULL; + GLES2_ShaderType vtype, ftype; + GLES2_ProgramCacheEntry *program; + + /* Select an appropriate shader pair for the specified modes */ + vtype = GLES2_SHADER_VERTEX_DEFAULT; + switch (source) { + case GLES2_IMAGESOURCE_SOLID: + ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_ABGR: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_ARGB: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_RGB: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_BGR: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_YUV: + switch (SDL_GetYUVConversionModeForResolution(w, h)) { + case SDL_YUV_CONVERSION_JPEG: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC; + break; + case SDL_YUV_CONVERSION_BT601: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC; + break; + case SDL_YUV_CONVERSION_BT709: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC; + break; + default: + SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); + goto fault; + } + break; + case GLES2_IMAGESOURCE_TEXTURE_NV12: + switch (SDL_GetYUVConversionModeForResolution(w, h)) { + case SDL_YUV_CONVERSION_JPEG: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC; + break; + case SDL_YUV_CONVERSION_BT601: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC; + break; + case SDL_YUV_CONVERSION_BT709: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC; + break; + default: + SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); + goto fault; + } + break; + case GLES2_IMAGESOURCE_TEXTURE_NV21: + switch (SDL_GetYUVConversionModeForResolution(w, h)) { + case SDL_YUV_CONVERSION_JPEG: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC; + break; + case SDL_YUV_CONVERSION_BT601: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC; + break; + case SDL_YUV_CONVERSION_BT709: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC; + break; + default: + SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); + goto fault; + } + break; + case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC; + break; + default: + goto fault; + } + + /* Load the requested shaders */ + vertex = GLES2_CacheShader(renderer, vtype); + if (!vertex) { + goto fault; + } + fragment = GLES2_CacheShader(renderer, ftype); + if (!fragment) { + goto fault; + } + + /* Check if we need to change programs at all */ + if (data->current_program && + data->current_program->vertex_shader == vertex && + data->current_program->fragment_shader == fragment) { + return 0; + } + + /* Generate a matching program */ + program = GLES2_CacheProgram(renderer, vertex, fragment); + if (!program) { + goto fault; + } + + /* Select that program in OpenGL */ + data->glUseProgram(program->id); + + /* Set the current program */ + data->current_program = program; + + /* Activate an orthographic projection */ + if (GLES2_SetOrthographicProjection(renderer) < 0) { + goto fault; + } + + /* Clean up and return */ + return 0; +fault: + if (vertex && vertex->references <= 0) { + GLES2_EvictShader(renderer, vertex); + } + if (fragment && fragment->references <= 0) { + GLES2_EvictShader(renderer, fragment); + } + data->current_program = NULL; + return -1; +} + +static int +GLES2_SetOrthographicProjection(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat projection[4][4]; + + if (!renderer->viewport.w || !renderer->viewport.h) { + return 0; + } + + /* Prepare an orthographic projection */ + projection[0][0] = 2.0f / renderer->viewport.w; + projection[0][1] = 0.0f; + projection[0][2] = 0.0f; + projection[0][3] = 0.0f; + projection[1][0] = 0.0f; + if (renderer->target) { + projection[1][1] = 2.0f / renderer->viewport.h; + } else { + projection[1][1] = -2.0f / renderer->viewport.h; + } + projection[1][2] = 0.0f; + projection[1][3] = 0.0f; + projection[2][0] = 0.0f; + projection[2][1] = 0.0f; + projection[2][2] = 0.0f; + projection[2][3] = 0.0f; + projection[3][0] = -1.0f; + if (renderer->target) { + projection[3][1] = -1.0f; + } else { + projection[3][1] = 1.0f; + } + projection[3][2] = 0.0f; + projection[3][3] = 1.0f; + + /* Set the projection matrix */ + if (SDL_memcmp(data->current_program->projection, projection, sizeof (projection)) != 0) { + const GLuint locProjection = data->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; + data->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + SDL_memcpy(data->current_program->projection, projection, sizeof (projection)); + } + + return 0; +} + +/************************************************************************************************* + * Rendering functions * + *************************************************************************************************/ + +static const float inv255f = 1.0f / 255.0f; + +static int GLES2_RenderClear(SDL_Renderer *renderer); +static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count); +static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count); +static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); +static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_FRect *dstrect); +static int GLES2_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); +static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GLES2_RenderPresent(SDL_Renderer *renderer); + +static SDL_bool +CompareColors(Uint8 r1, Uint8 g1, Uint8 b1, Uint8 a1, + Uint8 r2, Uint8 g2, Uint8 b2, Uint8 a2) +{ + Uint32 Pixel1, Pixel2; + RGBA8888_FROM_RGBA(Pixel1, r1, g1, b1, a1); + RGBA8888_FROM_RGBA(Pixel2, r2, g2, b2, a2); + return (Pixel1 == Pixel2); +} + +static int +GLES2_RenderClear(SDL_Renderer * renderer) +{ + Uint8 r, g, b, a; + + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + + GLES2_ActivateRenderer(renderer); + + if (!CompareColors(data->clear_r, data->clear_g, data->clear_b, data->clear_a, + renderer->r, renderer->g, renderer->b, renderer->a)) { + + /* Select the color to clear with */ + g = renderer->g; + a = renderer->a; + + if (renderer->target && + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + renderer->target->format == SDL_PIXELFORMAT_RGB888)) { + r = renderer->b; + b = renderer->r; + } else { + r = renderer->r; + b = renderer->b; + } + + data->glClearColor((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); + data->clear_r = renderer->r; + data->clear_g = renderer->g; + data->clear_b = renderer->b; + data->clear_a = renderer->a; + } + + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } + + data->glClear(GL_COLOR_BUFFER_BIT); + + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + + return 0; +} + +static void +GLES2_SetBlendMode(GLES2_DriverContext *data, SDL_BlendMode blendMode) +{ + if (blendMode != data->current.blendMode) { + if (blendMode == SDL_BLENDMODE_NONE) { + data->glDisable(GL_BLEND); + } else { + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)), + GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode))); + data->glBlendEquationSeparate(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)), + GetBlendEquation(SDL_GetBlendModeAlphaOperation(blendMode))); + } + data->current.blendMode = blendMode; + } +} + +static void +GLES2_SetTexCoords(GLES2_DriverContext * data, SDL_bool enabled) +{ + if (enabled != data->current.tex_coords) { + if (enabled) { + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + } else { + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + } + data->current.tex_coords = enabled; + } +} + +static int +GLES2_SetDrawingState(SDL_Renderer * renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; + + GLES2_ActivateRenderer(renderer); + + GLES2_SetBlendMode(data, renderer->blendMode); + + GLES2_SetTexCoords(data, SDL_FALSE); + + /* Activate an appropriate shader and set the projection matrix */ + if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, 0, 0) < 0) { + return -1; + } + + /* Select the color to draw with */ + g = renderer->g; + a = renderer->a; + + if (renderer->target && + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + renderer->target->format == SDL_PIXELFORMAT_RGB888)) { + r = renderer->b; + b = renderer->r; + } else { + r = renderer->r; + b = renderer->b; + } + + program = data->current_program; + if (!CompareColors(program->color_r, program->color_g, program->color_b, program->color_a, r, g, b, a)) { + /* Select the color to draw with */ + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_COLOR], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->color_r = r; + program->color_g = g; + program->color_b = b; + program->color_a = a; + } + + return 0; +} + +static int +GLES2_UpdateVertexBuffer(SDL_Renderer *renderer, GLES2_Attribute attr, + const void *vertexData, size_t dataSizeInBytes) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + +#if !SDL_GLES2_USE_VBOS + data->glVertexAttribPointer(attr, 2, GL_FLOAT, GL_FALSE, 0, vertexData); +#else + if (!data->vertex_buffers[attr]) { + data->glGenBuffers(1, &data->vertex_buffers[attr]); + } + + data->glBindBuffer(GL_ARRAY_BUFFER, data->vertex_buffers[attr]); + + if (data->vertex_buffer_size[attr] < dataSizeInBytes) { + data->glBufferData(GL_ARRAY_BUFFER, dataSizeInBytes, vertexData, GL_STREAM_DRAW); + data->vertex_buffer_size[attr] = dataSizeInBytes; + } else { + data->glBufferSubData(GL_ARRAY_BUFFER, 0, dataSizeInBytes, vertexData); + } + + data->glVertexAttribPointer(attr, 2, GL_FLOAT, GL_FALSE, 0, 0); +#endif + + return 0; +} + +static int +GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat *vertices; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit the specified vertices as points */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) { + GLfloat x = points[idx].x + 0.5f; + GLfloat y = points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, count * 2 * sizeof(GLfloat)); + data->glDrawArrays(GL_POINTS, 0, count); + SDL_stack_free(vertices); + return 0; +} + +static int +GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat *vertices; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit a line strip including the specified vertices */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) { + GLfloat x = points[idx].x + 0.5f; + GLfloat y = points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, count * 2 * sizeof(GLfloat)); + data->glDrawArrays(GL_LINE_STRIP, 0, count); + + /* We need to close the endpoint of the line */ + if (count == 2 || + points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + data->glDrawArrays(GL_POINTS, count-1, 1); + } + SDL_stack_free(vertices); + + return GL_CheckError("", renderer); +} + +static int +GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat vertices[8]; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit a line loop for each rectangle */ + for (idx = 0; idx < count; ++idx) { + const SDL_FRect *rect = &rects[idx]; + + GLfloat xMin = rect->x; + GLfloat xMax = (rect->x + rect->w); + GLfloat yMin = rect->y; + GLfloat yMax = (rect->y + rect->h); + + vertices[0] = xMin; + vertices[1] = yMin; + vertices[2] = xMax; + vertices[3] = yMin; + vertices[4] = xMin; + vertices[5] = yMax; + vertices[6] = xMax; + vertices[7] = yMax; + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat)); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + return GL_CheckError("", renderer); +} + +static int +GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; + + /* Activate an appropriate shader and set the projection matrix */ + if (renderer->target) { + /* Check if we need to do color mapping between the source and render target textures */ + if (renderer->target->format != texture->format) { + switch (texture->format) { + case SDL_PIXELFORMAT_ARGB8888: + switch (renderer->target->format) { + case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_BGR888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + case SDL_PIXELFORMAT_RGB888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + break; + } + break; + case SDL_PIXELFORMAT_ABGR8888: + switch (renderer->target->format) { + case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_RGB888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + case SDL_PIXELFORMAT_BGR888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + break; + } + break; + case SDL_PIXELFORMAT_RGB888: + switch (renderer->target->format) { + case SDL_PIXELFORMAT_ABGR8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + case SDL_PIXELFORMAT_ARGB8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; + break; + case SDL_PIXELFORMAT_BGR888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + } + break; + case SDL_PIXELFORMAT_BGR888: + switch (renderer->target->format) { + case SDL_PIXELFORMAT_ABGR8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; + break; + case SDL_PIXELFORMAT_ARGB8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; + break; + case SDL_PIXELFORMAT_RGB888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + } + break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; + break; + case SDL_PIXELFORMAT_NV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; + break; + case SDL_PIXELFORMAT_NV21: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; + break; + case SDL_PIXELFORMAT_EXTERNAL_OES: + sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES; + break; + default: + return SDL_SetError("Unsupported texture format"); + } + } else { + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ + } + } else { + switch (texture->format) { + case SDL_PIXELFORMAT_ARGB8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + case SDL_PIXELFORMAT_ABGR8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + break; + case SDL_PIXELFORMAT_RGB888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; + break; + case SDL_PIXELFORMAT_BGR888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; + break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; + break; + case SDL_PIXELFORMAT_NV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; + break; + case SDL_PIXELFORMAT_NV21: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; + break; + case SDL_PIXELFORMAT_EXTERNAL_OES: + sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES; + break; + default: + return SDL_SetError("Unsupported texture format"); + } + } + + if (GLES2_SelectProgram(renderer, sourceType, texture->w, texture->h) < 0) { + return -1; + } + + /* Select the target texture */ + if (tdata->yuv) { + data->glActiveTexture(GL_TEXTURE2); + data->glBindTexture(tdata->texture_type, tdata->texture_v); + + data->glActiveTexture(GL_TEXTURE1); + data->glBindTexture(tdata->texture_type, tdata->texture_u); + + data->glActiveTexture(GL_TEXTURE0); + } + if (tdata->nv12) { + data->glActiveTexture(GL_TEXTURE1); + data->glBindTexture(tdata->texture_type, tdata->texture_u); + + data->glActiveTexture(GL_TEXTURE0); + } + data->glBindTexture(tdata->texture_type, tdata->texture); + + /* Configure color modulation */ + g = texture->g; + a = texture->a; + + if (renderer->target && + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + renderer->target->format == SDL_PIXELFORMAT_RGB888)) { + r = texture->b; + b = texture->r; + } else { + r = texture->r; + b = texture->b; + } + + program = data->current_program; + + if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->modulation_r = r; + program->modulation_g = g; + program->modulation_b = b; + program->modulation_a = a; + } + + /* Configure texture blending */ + GLES2_SetBlendMode(data, texture->blendMode); + + GLES2_SetTexCoords(data, SDL_TRUE); + return 0; +} + +static int +GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_FRect *dstrect) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat vertices[8]; + GLfloat texCoords[8]; + + GLES2_ActivateRenderer(renderer); + + if (GLES2_SetupCopy(renderer, texture) < 0) { + return -1; + } + + /* Emit the textured quad */ + vertices[0] = dstrect->x; + vertices[1] = dstrect->y; + vertices[2] = (dstrect->x + dstrect->w); + vertices[3] = dstrect->y; + vertices[4] = dstrect->x; + vertices[5] = (dstrect->y + dstrect->h); + vertices[6] = (dstrect->x + dstrect->w); + vertices[7] = (dstrect->y + dstrect->h); + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat)); + texCoords[0] = srcrect->x / (GLfloat)texture->w; + texCoords[1] = srcrect->y / (GLfloat)texture->h; + texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[3] = srcrect->y / (GLfloat)texture->h; + texCoords[4] = srcrect->x / (GLfloat)texture->w; + texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_TEXCOORD, texCoords, 8 * sizeof(GLfloat)); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + return GL_CheckError("", renderer); +} + +static int +GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLfloat vertices[8]; + GLfloat texCoords[8]; + GLfloat translate[8]; + GLfloat fAngle[8]; + GLfloat tmp; + float radian_angle; + + GLES2_ActivateRenderer(renderer); + + if (GLES2_SetupCopy(renderer, texture) < 0) { + return -1; + } + + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + + radian_angle = (float)(M_PI * (360.0 - angle) / 180.0); + fAngle[0] = fAngle[2] = fAngle[4] = fAngle[6] = (GLfloat)SDL_sin(radian_angle); + /* render expects cos value - 1 (see GLES2_VertexSrc_Default_) */ + fAngle[1] = fAngle[3] = fAngle[5] = fAngle[7] = (GLfloat)SDL_cos(radian_angle) - 1.0f; + /* Calculate the center of rotation */ + translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x); + translate[1] = translate[3] = translate[5] = translate[7] = (center->y + dstrect->y); + + /* Emit the textured quad */ + vertices[0] = dstrect->x; + vertices[1] = dstrect->y; + vertices[2] = (dstrect->x + dstrect->w); + vertices[3] = dstrect->y; + vertices[4] = dstrect->x; + vertices[5] = (dstrect->y + dstrect->h); + vertices[6] = (dstrect->x + dstrect->w); + vertices[7] = (dstrect->y + dstrect->h); + if (flip & SDL_FLIP_HORIZONTAL) { + tmp = vertices[0]; + vertices[0] = vertices[4] = vertices[2]; + vertices[2] = vertices[6] = tmp; + } + if (flip & SDL_FLIP_VERTICAL) { + tmp = vertices[1]; + vertices[1] = vertices[3] = vertices[5]; + vertices[5] = vertices[7] = tmp; + } + + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/ + + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_ANGLE, fAngle, 8 * sizeof(GLfloat)); + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_CENTER, translate, 8 * sizeof(GLfloat)); + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat)); + + texCoords[0] = srcrect->x / (GLfloat)texture->w; + texCoords[1] = srcrect->y / (GLfloat)texture->h; + texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[3] = srcrect->y / (GLfloat)texture->h; + texCoords[4] = srcrect->x / (GLfloat)texture->w; + texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);*/ + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_TEXCOORD, texCoords, 8 * sizeof(GLfloat)); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + + return GL_CheckError("", renderer); +} + +static int +GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; + size_t buflen; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES2_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + buflen = (size_t) (rect->h * temp_pitch); + if (buflen == 0) { + return 0; /* nothing to do. */ + } + + temp_pixels = SDL_malloc(buflen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + + SDL_GetRendererOutputSize(renderer, &w, &h); + + data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + if (GL_CheckError("glReadPixels()", renderer) < 0) { + return -1; + } + + /* Flip the rows to be top-down if necessary */ + if (!renderer->target) { + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + } + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GLES2_RenderPresent(SDL_Renderer *renderer) +{ + GLES2_ActivateRenderer(renderer); + + /* Tell the video driver to swap buffers */ + SDL_GL_SwapWindow(renderer->window); +} + + +/************************************************************************************************* + * Bind/unbinding of textures + *************************************************************************************************/ +static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); +static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); + +static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; + GLES2_ActivateRenderer(renderer); + + data->glBindTexture(texturedata->texture_type, texturedata->texture); + + if (texw) { + *texw = 1.0; + } + if (texh) { + *texh = 1.0; + } + + return 0; +} + +static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; + GLES2_ActivateRenderer(renderer); + + data->glBindTexture(texturedata->texture_type, 0); + + return 0; +} + + +/************************************************************************************************* + * Renderer instantiation * + *************************************************************************************************/ + +#ifdef ZUNE_HD +#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B +#endif + +static void +GLES2_ResetState(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + + if (SDL_CurrentContext == data->context) { + GLES2_UpdateViewport(renderer); + } else { + GLES2_ActivateRenderer(renderer); + } + + data->current.blendMode = SDL_BLENDMODE_INVALID; + data->current.tex_coords = SDL_FALSE; + + data->glActiveTexture(GL_TEXTURE0); + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + data->glClearColor((GLfloat) data->clear_r * inv255f, + (GLfloat) data->clear_g * inv255f, + (GLfloat) data->clear_b * inv255f, + (GLfloat) data->clear_a * inv255f); + + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + + GL_CheckError("", renderer); +} + +static SDL_Renderer * +GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + SDL_Renderer *renderer; + GLES2_DriverContext *data; + GLint nFormats; +#ifndef ZUNE_HD + GLboolean hasCompiler; +#endif + Uint32 window_flags = 0; /* -Wconditional-uninitialized */ + GLint window_framebuffer; + GLint value; + int profile_mask = 0, major = 0, minor = 0; + SDL_bool changed_window = SDL_FALSE; + + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask) < 0) { + goto error; + } + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major) < 0) { + goto error; + } + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor) < 0) { + goto error; + } + + window_flags = SDL_GetWindowFlags(window); + /* OpenGL ES 3.0 is a superset of OpenGL ES 2.0 */ + if (!(window_flags & SDL_WINDOW_OPENGL) || + profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major < RENDERER_CONTEXT_MAJOR) { + + changed_window = SDL_TRUE; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + + if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { + goto error; + } + } + + /* Create the renderer struct */ + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer)); + if (!renderer) { + SDL_OutOfMemory(); + goto error; + } + + data = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); + if (!data) { + GLES2_DestroyRenderer(renderer); + SDL_OutOfMemory(); + goto error; + } + renderer->info = GLES2_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + renderer->window = window; + + /* Create an OpenGL ES 2.0 context */ + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GLES2_DestroyRenderer(renderer); + goto error; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GLES2_DestroyRenderer(renderer); + goto error; + } + + if (GLES2_LoadFunctions(data) < 0) { + GLES2_DestroyRenderer(renderer); + goto error; + } + +#if __WINRT__ + /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync + * is turned on. Not doing so will freeze the screen's contents to that + * of the first drawn frame. + */ + flags |= SDL_RENDERER_PRESENTVSYNC; +#endif + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + /* Check for debug output support */ + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && + (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { + data->debug_enabled = SDL_TRUE; + } + + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + + /* Determine supported shader formats */ + /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ +#ifdef ZUNE_HD + nFormats = 1; +#else /* !ZUNE_HD */ + data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); + data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); + if (hasCompiler) { + ++nFormats; + } +#endif /* ZUNE_HD */ + data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); + if (!data->shader_formats) { + GLES2_DestroyRenderer(renderer); + SDL_OutOfMemory(); + goto error; + } + data->shader_format_count = nFormats; +#ifdef ZUNE_HD + data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; +#else /* !ZUNE_HD */ + data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats); + if (hasCompiler) { + data->shader_formats[nFormats - 1] = (GLenum)-1; + } +#endif /* ZUNE_HD */ + + data->framebuffers = NULL; + data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); + data->window_framebuffer = (GLuint)window_framebuffer; + + /* Populate the function pointers for the module */ + renderer->WindowEvent = GLES2_WindowEvent; + renderer->GetOutputSize = GLES2_GetOutputSize; + renderer->SupportsBlendMode = GLES2_SupportsBlendMode; + renderer->CreateTexture = GLES2_CreateTexture; + renderer->UpdateTexture = GLES2_UpdateTexture; + renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV; + renderer->LockTexture = GLES2_LockTexture; + renderer->UnlockTexture = GLES2_UnlockTexture; + renderer->SetRenderTarget = GLES2_SetRenderTarget; + renderer->UpdateViewport = GLES2_UpdateViewport; + renderer->UpdateClipRect = GLES2_UpdateClipRect; + renderer->RenderClear = GLES2_RenderClear; + renderer->RenderDrawPoints = GLES2_RenderDrawPoints; + renderer->RenderDrawLines = GLES2_RenderDrawLines; + renderer->RenderFillRects = GLES2_RenderFillRects; + renderer->RenderCopy = GLES2_RenderCopy; + renderer->RenderCopyEx = GLES2_RenderCopyEx; + renderer->RenderReadPixels = GLES2_RenderReadPixels; + renderer->RenderPresent = GLES2_RenderPresent; + renderer->DestroyTexture = GLES2_DestroyTexture; + renderer->DestroyRenderer = GLES2_DestroyRenderer; + renderer->GL_BindTexture = GLES2_BindTexture; + renderer->GL_UnbindTexture = GLES2_UnbindTexture; + + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; +#ifdef GL_TEXTURE_EXTERNAL_OES + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES; +#endif + + GLES2_ResetState(renderer); + + return renderer; + +error: + if (changed_window) { + /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); + SDL_RecreateWindow(window, window_flags); + } + return NULL; +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.c b/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.c new file mode 100644 index 0000000..f428a49 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.c @@ -0,0 +1,573 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED + +#include "SDL_video.h" +#include "SDL_opengles2.h" +#include "SDL_shaders_gles2.h" +#include "SDL_stdinc.h" + +/************************************************************************************************* + * Vertex/fragment shader source * + *************************************************************************************************/ +/* Notes on a_angle: + * It is a vector containing sin and cos for rotation matrix + * To get correct rotation for most cases when a_angle is disabled cos + value is decremented by 1.0 to get proper output with 0.0 which is + default value +*/ +static const Uint8 GLES2_VertexSrc_Default_[] = " \ + uniform mat4 u_projection; \ + attribute vec2 a_position; \ + attribute vec2 a_texCoord; \ + attribute vec2 a_angle; \ + attribute vec2 a_center; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + float s = a_angle[0]; \ + float c = a_angle[1] + 1.0; \ + mat2 rotationMatrix = mat2(c, -s, s, c); \ + vec2 position = rotationMatrix * (a_position - a_center) + a_center; \ + v_texCoord = a_texCoord; \ + gl_Position = u_projection * vec4(position, 0.0, 1.0);\ + gl_PointSize = 1.0; \ + } \ +"; + +static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \ + precision mediump float; \ + uniform vec4 u_color; \ + \ + void main() \ + { \ + gl_FragColor = u_color; \ + } \ +"; + +static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + gl_FragColor = texture2D(u_texture, v_texCoord); \ + gl_FragColor *= u_modulation; \ + } \ +"; + +/* ARGB to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + vec4 abgr = texture2D(u_texture, v_texCoord); \ + gl_FragColor = abgr; \ + gl_FragColor.r = abgr.b; \ + gl_FragColor.b = abgr.r; \ + gl_FragColor *= u_modulation; \ + } \ +"; + +/* RGB to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + vec4 abgr = texture2D(u_texture, v_texCoord); \ + gl_FragColor = abgr; \ + gl_FragColor.r = abgr.b; \ + gl_FragColor.b = abgr.r; \ + gl_FragColor.a = 1.0; \ + gl_FragColor *= u_modulation; \ + } \ +"; + +/* BGR to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + vec4 abgr = texture2D(u_texture, v_texCoord); \ + gl_FragColor = abgr; \ + gl_FragColor.a = 1.0; \ + gl_FragColor *= u_modulation; \ + } \ +"; + +#define JPEG_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const mat3 matrix = mat3( 1, 1, 1,\n" \ +" 0, -0.3441, 1.772,\n" \ +" 1.402, -0.7141, 0);\n" \ + +#define BT601_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \ +" 0, -0.3918, 2.0172,\n" \ +" 1.596, -0.813, 0);\n" \ + +#define BT709_SHADER_CONSTANTS \ +"// YUV offset \n" \ +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ +"\n" \ +"// RGB coefficients \n" \ +"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \ +" 0, -0.2132, 2.1124,\n" \ +" 1.7927, -0.5329, 0);\n" \ + + +#define YUV_SHADER_PROLOGUE \ +"precision mediump float;\n" \ +"uniform sampler2D u_texture;\n" \ +"uniform sampler2D u_texture_u;\n" \ +"uniform sampler2D u_texture_v;\n" \ +"uniform vec4 u_modulation;\n" \ +"varying vec2 v_texCoord;\n" \ +"\n" \ + +#define YUV_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" mediump vec3 yuv;\n" \ +" lowp vec3 rgb;\n" \ +"\n" \ +" // Get the YUV values \n" \ +" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ +" yuv.y = texture2D(u_texture_u, v_texCoord).r;\n" \ +" yuv.z = texture2D(u_texture_v, v_texCoord).r;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb = matrix * yuv;\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1);\n" \ +" gl_FragColor *= u_modulation;\n" \ +"}" \ + +#define NV12_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" mediump vec3 yuv;\n" \ +" lowp vec3 rgb;\n" \ +"\n" \ +" // Get the YUV values \n" \ +" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ +" yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb = matrix * yuv;\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1);\n" \ +" gl_FragColor *= u_modulation;\n" \ +"}" \ + +#define NV21_SHADER_BODY \ +"\n" \ +"void main()\n" \ +"{\n" \ +" mediump vec3 yuv;\n" \ +" lowp vec3 rgb;\n" \ +"\n" \ +" // Get the YUV values \n" \ +" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ +" yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n" \ +"\n" \ +" // Do the color transform \n" \ +" yuv += offset;\n" \ +" rgb = matrix * yuv;\n" \ +"\n" \ +" // That was easy. :) \n" \ +" gl_FragColor = vec4(rgb, 1);\n" \ +" gl_FragColor *= u_modulation;\n" \ +"}" \ + +/* YUV to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \ + YUV_SHADER_PROLOGUE \ + JPEG_SHADER_CONSTANTS \ + YUV_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT601_SHADER_CONSTANTS \ + YUV_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT709_SHADER_CONSTANTS \ + YUV_SHADER_BODY \ +; + +/* NV12 to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \ + YUV_SHADER_PROLOGUE \ + JPEG_SHADER_CONSTANTS \ + NV12_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT601_SHADER_CONSTANTS \ + NV12_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT709_SHADER_CONSTANTS \ + NV12_SHADER_BODY \ +; + +/* NV21 to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \ + YUV_SHADER_PROLOGUE \ + JPEG_SHADER_CONSTANTS \ + NV21_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT601_SHADER_CONSTANTS \ + NV21_SHADER_BODY \ +; +static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \ + YUV_SHADER_PROLOGUE \ + BT709_SHADER_CONSTANTS \ + NV21_SHADER_BODY \ +; + +/* Custom Android video format texture */ +static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \ + #extension GL_OES_EGL_image_external : require\n\ + precision mediump float; \ + uniform samplerExternalOES u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + gl_FragColor = texture2D(u_texture, v_texCoord); \ + gl_FragColor *= u_modulation; \ + } \ +"; + +static const GLES2_ShaderInstance GLES2_VertexSrc_Default = { + GL_VERTEX_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_VertexSrc_Default_), + GLES2_VertexSrc_Default_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_SolidSrc_), + GLES2_FragmentSrc_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureABGRSrc_), + GLES2_FragmentSrc_TextureABGRSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureARGBSrc_), + GLES2_FragmentSrc_TextureARGBSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureRGBSrc_), + GLES2_FragmentSrc_TextureRGBSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureBGRSrc_), + GLES2_FragmentSrc_TextureBGRSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_), + GLES2_FragmentSrc_TextureYUVJPEGSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_), + GLES2_FragmentSrc_TextureYUVBT601Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_), + GLES2_FragmentSrc_TextureYUVBT709Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_), + GLES2_FragmentSrc_TextureNV12JPEGSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_), + GLES2_FragmentSrc_TextureNV12BT601Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_), + GLES2_FragmentSrc_TextureNV21BT709Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_), + GLES2_FragmentSrc_TextureNV21JPEGSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_), + GLES2_FragmentSrc_TextureNV21BT601Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_), + GLES2_FragmentSrc_TextureNV12BT709Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureExternalOESSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureExternalOESSrc_), + GLES2_FragmentSrc_TextureExternalOESSrc_ +}; + + +/************************************************************************************************* + * Vertex/fragment shader definitions * + *************************************************************************************************/ + +static GLES2_Shader GLES2_VertexShader_Default = { + 1, + { + &GLES2_VertexSrc_Default + } +}; + +static GLES2_Shader GLES2_FragmentShader_SolidSrc = { + 1, + { + &GLES2_FragmentSrc_SolidSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = { + 1, + { + &GLES2_FragmentSrc_TextureABGRSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = { + 1, + { + &GLES2_FragmentSrc_TextureARGBSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = { + 1, + { + &GLES2_FragmentSrc_TextureRGBSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = { + 1, + { + &GLES2_FragmentSrc_TextureBGRSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = { + 1, + { + &GLES2_FragmentSrc_TextureYUVJPEGSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = { + 1, + { + &GLES2_FragmentSrc_TextureYUVBT601Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = { + 1, + { + &GLES2_FragmentSrc_TextureYUVBT709Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = { + 1, + { + &GLES2_FragmentSrc_TextureNV12JPEGSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV12BT601Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV12BT709Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = { + 1, + { + &GLES2_FragmentSrc_TextureNV21JPEGSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV21BT601Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV21BT709Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureExternalOESSrc = { + 1, + { + &GLES2_FragmentSrc_TextureExternalOESSrc + } +}; + + +/************************************************************************************************* + * Shader selector * + *************************************************************************************************/ + +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type) +{ + switch (type) { + case GLES2_SHADER_VERTEX_DEFAULT: + return &GLES2_VertexShader_Default; + case GLES2_SHADER_FRAGMENT_SOLID_SRC: + return &GLES2_FragmentShader_SolidSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC: + return &GLES2_FragmentShader_TextureABGRSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC: + return &GLES2_FragmentShader_TextureARGBSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC: + return &GLES2_FragmentShader_TextureRGBSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC: + return &GLES2_FragmentShader_TextureBGRSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC: + return &GLES2_FragmentShader_TextureYUVJPEGSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC: + return &GLES2_FragmentShader_TextureYUVBT601Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC: + return &GLES2_FragmentShader_TextureYUVBT709Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC: + return &GLES2_FragmentShader_TextureNV12JPEGSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC: + return &GLES2_FragmentShader_TextureNV12BT601Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC: + return &GLES2_FragmentShader_TextureNV12BT709Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC: + return &GLES2_FragmentShader_TextureNV21JPEGSrc; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC: + return &GLES2_FragmentShader_TextureNV21BT601Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC: + return &GLES2_FragmentShader_TextureNV21BT709Src; + case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC: + return &GLES2_FragmentShader_TextureExternalOESSrc; + default: + return NULL; + } +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.h b/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.h new file mode 100644 index 0000000..c16ce12 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/opengles2/SDL_shaders_gles2.h @@ -0,0 +1,70 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_shaders_gles2_h_ +#define SDL_shaders_gles2_h_ + +#if SDL_VIDEO_RENDER_OGL_ES2 + +typedef struct GLES2_ShaderInstance +{ + GLenum type; + GLenum format; + int length; + const void *data; +} GLES2_ShaderInstance; + +typedef struct GLES2_Shader +{ + int instance_count; + const GLES2_ShaderInstance *instances[4]; +} GLES2_Shader; + +typedef enum +{ + GLES2_SHADER_VERTEX_DEFAULT, + GLES2_SHADER_FRAGMENT_SOLID_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC +} GLES2_ShaderType; + +#define GLES2_SOURCE_SHADER (GLenum)-1 + +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type); + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ + +#endif /* SDL_shaders_gles2_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/psp/SDL_render_psp.c b/source/3rd-party/SDL2/src/render/psp/SDL_render_psp.c new file mode 100644 index 0000000..babc252 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/psp/SDL_render_psp.c @@ -0,0 +1,1016 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_PSP + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" + +#include <pspkernel.h> +#include <pspdisplay.h> +#include <pspgu.h> +#include <pspgum.h> +#include <stdio.h> +#include <string.h> +#include <math.h> +#include <pspge.h> +#include <stdarg.h> +#include <stdlib.h> +#include <vram.h> + + + + +/* PSP renderer implementation, based on the PGE */ + + +extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); + + +static SDL_Renderer *PSP_CreateRenderer(SDL_Window * window, Uint32 flags); +static void PSP_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int PSP_SetTextureColorMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void PSP_UnlockTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static int PSP_SetRenderTarget(SDL_Renderer * renderer, + SDL_Texture * texture); +static int PSP_UpdateViewport(SDL_Renderer * renderer); +static int PSP_RenderClear(SDL_Renderer * renderer); +static int PSP_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int PSP_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int PSP_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int PSP_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); +static int PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static int PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); +static void PSP_RenderPresent(SDL_Renderer * renderer); +static void PSP_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void PSP_DestroyRenderer(SDL_Renderer * renderer); + +/* +SDL_RenderDriver PSP_RenderDriver = { + PSP_CreateRenderer, + { + "PSP", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 1, + {SDL_PIXELFORMAT_ABGR8888}, + 0, + 0} +}; +*/ +SDL_RenderDriver PSP_RenderDriver = { + .CreateRenderer = PSP_CreateRenderer, + .info = { + .name = "PSP", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 4, + .texture_formats = { [0] = SDL_PIXELFORMAT_BGR565, + [1] = SDL_PIXELFORMAT_ABGR1555, + [2] = SDL_PIXELFORMAT_ABGR4444, + [3] = SDL_PIXELFORMAT_ABGR8888, + }, + .max_texture_width = 512, + .max_texture_height = 512, + } +}; + +#define PSP_SCREEN_WIDTH 480 +#define PSP_SCREEN_HEIGHT 272 + +#define PSP_FRAME_BUFFER_WIDTH 512 +#define PSP_FRAME_BUFFER_SIZE (PSP_FRAME_BUFFER_WIDTH*PSP_SCREEN_HEIGHT) + +static unsigned int __attribute__((aligned(16))) DisplayList[262144]; + + +#define COL5650(r,g,b,a) ((r>>3) | ((g>>2)<<5) | ((b>>3)<<11)) +#define COL5551(r,g,b,a) ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10) | (a>0?0x7000:0)) +#define COL4444(r,g,b,a) ((r>>4) | ((g>>4)<<4) | ((b>>4)<<8) | ((a>>4)<<12)) +#define COL8888(r,g,b,a) ((r) | ((g)<<8) | ((b)<<16) | ((a)<<24)) + + +typedef struct +{ + void* frontbuffer ; + void* backbuffer ; + SDL_bool initialized ; + SDL_bool displayListAvail ; + unsigned int psm ; + unsigned int bpp ; + + SDL_bool vsync; + unsigned int currentColor; + int currentBlendMode; + +} PSP_RenderData; + + +typedef struct +{ + void *data; /**< Image data. */ + unsigned int size; /**< Size of data in bytes. */ + unsigned int width; /**< Image width. */ + unsigned int height; /**< Image height. */ + unsigned int textureWidth; /**< Texture width (power of two). */ + unsigned int textureHeight; /**< Texture height (power of two). */ + unsigned int bits; /**< Image bits per pixel. */ + unsigned int format; /**< Image format - one of ::pgePixelFormat. */ + unsigned int pitch; + SDL_bool swizzled; /**< Is image swizzled. */ + +} PSP_TextureData; + +typedef struct +{ + float x, y, z; +} VertV; + + +typedef struct +{ + float u, v; + float x, y, z; + +} VertTV; + + +/* Return next power of 2 */ +static int +TextureNextPow2(unsigned int w) +{ + if(w == 0) + return 0; + + unsigned int n = 2; + + while(w > n) + n <<= 1; + + return n; +} + + +static int +PixelFormatToPSPFMT(Uint32 format) +{ + switch (format) { + case SDL_PIXELFORMAT_BGR565: + return GU_PSM_5650; + case SDL_PIXELFORMAT_ABGR1555: + return GU_PSM_5551; + case SDL_PIXELFORMAT_ABGR4444: + return GU_PSM_4444; + case SDL_PIXELFORMAT_ABGR8888: + return GU_PSM_8888; + default: + return GU_PSM_8888; + } +} + +void +StartDrawing(SDL_Renderer * renderer) +{ + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + if(data->displayListAvail) + return; + + sceGuStart(GU_DIRECT, DisplayList); + data->displayListAvail = SDL_TRUE; +} + + +int +TextureSwizzle(PSP_TextureData *psp_texture) +{ + if(psp_texture->swizzled) + return 1; + + int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + int height = psp_texture->size / bytewidth; + + int rowblocks = (bytewidth>>4); + int rowblocksadd = (rowblocks-1)<<7; + unsigned int blockaddress = 0; + unsigned int *src = (unsigned int*) psp_texture->data; + + unsigned char *data = NULL; + data = malloc(psp_texture->size); + + int j; + + for(j = 0; j < height; j++, blockaddress += 16) + { + unsigned int *block; + + block = (unsigned int*)&data[blockaddress]; + + int i; + + for(i = 0; i < rowblocks; i++) + { + *block++ = *src++; + *block++ = *src++; + *block++ = *src++; + *block++ = *src++; + block += 28; + } + + if((j & 0x7) == 0x7) + blockaddress += rowblocksadd; + } + + free(psp_texture->data); + psp_texture->data = data; + psp_texture->swizzled = SDL_TRUE; + + return 1; +} +int TextureUnswizzle(PSP_TextureData *psp_texture) +{ + if(!psp_texture->swizzled) + return 1; + + int blockx, blocky; + + int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + int height = psp_texture->size / bytewidth; + + int widthblocks = bytewidth/16; + int heightblocks = height/8; + + int dstpitch = (bytewidth - 16)/4; + int dstrow = bytewidth * 8; + + unsigned int *src = (unsigned int*) psp_texture->data; + + unsigned char *data = NULL; + + data = malloc(psp_texture->size); + + if(!data) + return 0; + + sceKernelDcacheWritebackAll(); + + int j; + + unsigned char *ydst = (unsigned char *)data; + + for(blocky = 0; blocky < heightblocks; ++blocky) + { + unsigned char *xdst = ydst; + + for(blockx = 0; blockx < widthblocks; ++blockx) + { + unsigned int *block; + + block = (unsigned int*)xdst; + + for(j = 0; j < 8; ++j) + { + *(block++) = *(src++); + *(block++) = *(src++); + *(block++) = *(src++); + *(block++) = *(src++); + block += dstpitch; + } + + xdst += 16; + } + + ydst += dstrow; + } + + free(psp_texture->data); + + psp_texture->data = data; + + psp_texture->swizzled = SDL_FALSE; + + return 1; +} + +SDL_Renderer * +PSP_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + + SDL_Renderer *renderer; + PSP_RenderData *data; + int pixelformat; + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (PSP_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + PSP_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + + renderer->WindowEvent = PSP_WindowEvent; + renderer->CreateTexture = PSP_CreateTexture; + renderer->SetTextureColorMod = PSP_SetTextureColorMod; + renderer->UpdateTexture = PSP_UpdateTexture; + renderer->LockTexture = PSP_LockTexture; + renderer->UnlockTexture = PSP_UnlockTexture; + renderer->SetRenderTarget = PSP_SetRenderTarget; + renderer->UpdateViewport = PSP_UpdateViewport; + renderer->RenderClear = PSP_RenderClear; + renderer->RenderDrawPoints = PSP_RenderDrawPoints; + renderer->RenderDrawLines = PSP_RenderDrawLines; + renderer->RenderFillRects = PSP_RenderFillRects; + renderer->RenderCopy = PSP_RenderCopy; + renderer->RenderReadPixels = PSP_RenderReadPixels; + renderer->RenderCopyEx = PSP_RenderCopyEx; + renderer->RenderPresent = PSP_RenderPresent; + renderer->DestroyTexture = PSP_DestroyTexture; + renderer->DestroyRenderer = PSP_DestroyRenderer; + renderer->info = PSP_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + renderer->window = window; + + if (data->initialized != SDL_FALSE) + return 0; + data->initialized = SDL_TRUE; + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + data->vsync = SDL_TRUE; + } else { + data->vsync = SDL_FALSE; + } + + pixelformat=PixelFormatToPSPFMT(SDL_GetWindowPixelFormat(window)); + switch(pixelformat) + { + case GU_PSM_4444: + case GU_PSM_5650: + case GU_PSM_5551: + data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<1); + data->backbuffer = (unsigned int *)(0); + data->bpp = 2; + data->psm = pixelformat; + break; + default: + data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<2); + data->backbuffer = (unsigned int *)(0); + data->bpp = 4; + data->psm = GU_PSM_8888; + break; + } + + sceGuInit(); + /* setup GU */ + sceGuStart(GU_DIRECT, DisplayList); + sceGuDrawBuffer(data->psm, data->frontbuffer, PSP_FRAME_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, data->backbuffer, PSP_FRAME_BUFFER_WIDTH); + + + sceGuOffset(2048 - (PSP_SCREEN_WIDTH>>1), 2048 - (PSP_SCREEN_HEIGHT>>1)); + sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + + data->frontbuffer = vabsptr(data->frontbuffer); + data->backbuffer = vabsptr(data->backbuffer); + + /* Scissoring */ + sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuEnable(GU_SCISSOR_TEST); + + /* Backface culling */ + sceGuFrontFace(GU_CCW); + sceGuEnable(GU_CULL_FACE); + + /* Texturing */ + sceGuEnable(GU_TEXTURE_2D); + sceGuShadeModel(GU_SMOOTH); + sceGuTexWrap(GU_REPEAT, GU_REPEAT); + + /* Blending */ + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); + + sceGuTexFilter(GU_LINEAR,GU_LINEAR); + + sceGuFinish(); + sceGuSync(0,0); + sceDisplayWaitVblankStartCB(); + sceGuDisplay(GU_TRUE); + + return renderer; +} + +static void +PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + +} + + +static int +PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ +/* PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; */ + PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture)); + + if(!psp_texture) + return -1; + + psp_texture->swizzled = SDL_FALSE; + psp_texture->width = texture->w; + psp_texture->height = texture->h; + psp_texture->textureHeight = TextureNextPow2(texture->h); + psp_texture->textureWidth = TextureNextPow2(texture->w); + psp_texture->format = PixelFormatToPSPFMT(texture->format); + + switch(psp_texture->format) + { + case GU_PSM_5650: + case GU_PSM_5551: + case GU_PSM_4444: + psp_texture->bits = 16; + break; + + case GU_PSM_8888: + psp_texture->bits = 32; + break; + + default: + return -1; + } + + psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format); + psp_texture->size = psp_texture->textureHeight*psp_texture->pitch; + psp_texture->data = SDL_calloc(1, psp_texture->size); + + if(!psp_texture->data) + { + SDL_free(psp_texture); + return SDL_OutOfMemory(); + } + texture->driverdata = psp_texture; + + return 0; +} + +static int +PSP_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + return SDL_Unsupported(); +} + +void +TextureActivate(SDL_Texture * texture) +{ + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + int scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GU_NEAREST : GU_LINEAR; + + /* Swizzling is useless with small textures. */ + if (texture->w >= 16 || texture->h >= 16) + { + TextureSwizzle(psp_texture); + } + + sceGuEnable(GU_TEXTURE_2D); + sceGuTexWrap(GU_REPEAT, GU_REPEAT); + sceGuTexMode(psp_texture->format, 0, 0, psp_texture->swizzled); + sceGuTexFilter(scaleMode, scaleMode); /* GU_NEAREST good for tile-map */ + /* GU_LINEAR good for scaling */ + sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data); + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); +} + + +static int +PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ +/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; */ + const Uint8 *src; + Uint8 *dst; + int row, length,dpitch; + src = pixels; + + PSP_LockTexture(renderer, texture,rect,(void **)&dst, &dpitch); + length = rect->w * SDL_BYTESPERPIXEL(texture->format); + if (length == pitch && length == dpitch) { + SDL_memcpy(dst, src, length*rect->h); + } else { + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += dpitch; + } + } + + sceKernelDcacheWritebackAll(); + return 0; +} + +static int +PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) psp_texture->data + rect->y * psp_texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = psp_texture->pitch; + return 0; +} + +static void +PSP_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + SDL_Rect rect; + + /* We do whole texture updates, at least for now */ + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + PSP_UpdateTexture(renderer, texture, &rect, psp_texture->data, psp_texture->pitch); +} + +static int +PSP_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + + return 0; +} + +static int +PSP_UpdateViewport(SDL_Renderer * renderer) +{ + + return 0; +} + + +static void +PSP_SetBlendMode(SDL_Renderer * renderer, int blendMode) +{ + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + if (blendMode != data-> currentBlendMode) { + switch (blendMode) { + case SDL_BLENDMODE_NONE: + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuDisable(GU_BLEND); + break; + case SDL_BLENDMODE_BLEND: + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 ); + break; + case SDL_BLENDMODE_ADD: + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF ); + break; + case SDL_BLENDMODE_MOD: + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc( GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0); + break; + } + data->currentBlendMode = blendMode; + } +} + + + +static int +PSP_RenderClear(SDL_Renderer * renderer) +{ + /* start list */ + StartDrawing(renderer); + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + sceGuClearColor(color); + sceGuClearDepth(0); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT|GU_FAST_CLEAR_BIT); + + return 0; +} + +static int +PSP_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); + + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + } + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); + + return 0; +} + +static int +PSP_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); + + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + } + + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); + + return 0; +} + +static int +PSP_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, + int count) +{ + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + + for (i = 0; i < count; ++i) { + const SDL_FRect *rect = &rects[i]; + VertV* vertices = (VertV*)sceGuGetMemory((sizeof(VertV)<<1)); + vertices[0].x = rect->x; + vertices[0].y = rect->y; + vertices[0].z = 0.0f; + + vertices[1].x = rect->x + rect->w; + vertices[1].y = rect->y + rect->h; + vertices[1].z = 0.0f; + + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); + } + + return 0; +} + + +#define PI 3.14159265358979f + +#define radToDeg(x) ((x)*180.f/PI) +#define degToRad(x) ((x)*PI/180.f) + +float MathAbs(float x) +{ + float result; + + __asm__ volatile ( + "mtv %1, S000\n" + "vabs.s S000, S000\n" + "mfv %0, S000\n" + : "=r"(result) : "r"(x)); + + return result; +} + +void MathSincos(float r, float *s, float *c) +{ + __asm__ volatile ( + "mtv %2, S002\n" + "vcst.s S003, VFPU_2_PI\n" + "vmul.s S002, S002, S003\n" + "vrot.p C000, S002, [s, c]\n" + "mfv %0, S000\n" + "mfv %1, S001\n" + : "=r"(*s), "=r"(*c): "r"(r)); +} + +void Swap(float *a, float *b) +{ + float n=*a; + *a = *b; + *b = n; +} + +static int +PSP_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + float x, y, width, height; + float u0, v0, u1, v1; + unsigned char alpha; + + x = dstrect->x; + y = dstrect->y; + width = dstrect->w; + height = dstrect->h; + + u0 = srcrect->x; + v0 = srcrect->y; + u1 = srcrect->x + srcrect->w; + v1 = srcrect->y + srcrect->h; + + alpha = texture->a; + + StartDrawing(renderer); + TextureActivate(texture); + PSP_SetBlendMode(renderer, renderer->blendMode); + + if(alpha != 255) + { + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + sceGuColor(GU_RGBA(255, 255, 255, alpha)); + }else{ + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuColor(0xFFFFFFFF); + } + + if((MathAbs(u1) - MathAbs(u0)) < 64.0f) + { + VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); + + vertices[0].u = u0; + vertices[0].v = v0; + vertices[0].x = x; + vertices[0].y = y; + vertices[0].z = 0; + + vertices[1].u = u1; + vertices[1].v = v1; + vertices[1].x = x + width; + vertices[1].y = y + height; + vertices[1].z = 0; + + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + } + else + { + float start, end; + float curU = u0; + float curX = x; + float endX = x + width; + float slice = 64.0f; + float ustep = (u1 - u0)/width * slice; + + if(ustep < 0.0f) + ustep = -ustep; + + for(start = 0, end = width; start < end; start += slice) + { + VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); + + float polyWidth = ((curX + slice) > endX) ? (endX - curX) : slice; + float sourceWidth = ((curU + ustep) > u1) ? (u1 - curU) : ustep; + + vertices[0].u = curU; + vertices[0].v = v0; + vertices[0].x = curX; + vertices[0].y = y; + vertices[0].z = 0; + + curU += sourceWidth; + curX += polyWidth; + + vertices[1].u = curU; + vertices[1].v = v1; + vertices[1].x = curX; + vertices[1].y = (y + height); + vertices[1].z = 0; + + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + } + } + + if(alpha != 255) + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + return 0; +} + +static int +PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) + +{ + return SDL_Unsupported(); +} + + +static int +PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + float x, y, width, height; + float u0, v0, u1, v1; + unsigned char alpha; + float centerx, centery; + + x = dstrect->x; + y = dstrect->y; + width = dstrect->w; + height = dstrect->h; + + u0 = srcrect->x; + v0 = srcrect->y; + u1 = srcrect->x + srcrect->w; + v1 = srcrect->y + srcrect->h; + + centerx = center->x; + centery = center->y; + + alpha = texture->a; + + StartDrawing(renderer); + TextureActivate(texture); + PSP_SetBlendMode(renderer, renderer->blendMode); + + if(alpha != 255) + { + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + sceGuColor(GU_RGBA(255, 255, 255, alpha)); + }else{ + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuColor(0xFFFFFFFF); + } + +/* x += width * 0.5f; */ +/* y += height * 0.5f; */ + x += centerx; + y += centery; + + float c, s; + + MathSincos(degToRad(angle), &s, &c); + +/* width *= 0.5f; */ +/* height *= 0.5f; */ + width -= centerx; + height -= centery; + + + float cw = c*width; + float sw = s*width; + float ch = c*height; + float sh = s*height; + + VertTV* vertices = (VertTV*)sceGuGetMemory(sizeof(VertTV)<<2); + + vertices[0].u = u0; + vertices[0].v = v0; + vertices[0].x = x - cw + sh; + vertices[0].y = y - sw - ch; + vertices[0].z = 0; + + vertices[1].u = u0; + vertices[1].v = v1; + vertices[1].x = x - cw - sh; + vertices[1].y = y - sw + ch; + vertices[1].z = 0; + + vertices[2].u = u1; + vertices[2].v = v1; + vertices[2].x = x + cw - sh; + vertices[2].y = y + sw + ch; + vertices[2].z = 0; + + vertices[3].u = u1; + vertices[3].v = v0; + vertices[3].x = x + cw + sh; + vertices[3].y = y + sw - ch; + vertices[3].z = 0; + + if (flip & SDL_FLIP_VERTICAL) { + Swap(&vertices[0].v, &vertices[2].v); + Swap(&vertices[1].v, &vertices[3].v); + } + if (flip & SDL_FLIP_HORIZONTAL) { + Swap(&vertices[0].u, &vertices[2].u); + Swap(&vertices[1].u, &vertices[3].u); + } + + sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, vertices); + + if(alpha != 255) + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + return 0; +} + +static void +PSP_RenderPresent(SDL_Renderer * renderer) +{ + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + if(!data->displayListAvail) + return; + + data->displayListAvail = SDL_FALSE; + sceGuFinish(); + sceGuSync(0,0); + +/* if(data->vsync) */ + sceDisplayWaitVblankStart(); + + data->backbuffer = data->frontbuffer; + data->frontbuffer = vabsptr(sceGuSwapBuffers()); + +} + +static void +PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + + if (renderdata == 0) + return; + + if(psp_texture == 0) + return; + + SDL_free(psp_texture->data); + SDL_free(psp_texture); + texture->driverdata = NULL; +} + +static void +PSP_DestroyRenderer(SDL_Renderer * renderer) +{ + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + if (data) { + if (!data->initialized) + return; + + StartDrawing(renderer); + + sceGuTerm(); +/* vfree(data->backbuffer); */ +/* vfree(data->frontbuffer); */ + + data->initialized = SDL_FALSE; + data->displayListAvail = SDL_FALSE; + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* SDL_VIDEO_RENDER_PSP */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.c b/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.c new file mode 100644 index 0000000..8a3f750 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.c @@ -0,0 +1,336 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "SDL_draw.h" +#include "SDL_blendfillrect.h" + + +static int +SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555); + break; + default: + FILLRECT(Uint16, DRAW_SETPIXEL_RGB555); + break; + } + return 0; +} + +static int +SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565); + break; + default: + FILLRECT(Uint16, DRAW_SETPIXEL_RGB565); + break; + } + return 0; +} + +static int +SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888); + break; + default: + FILLRECT(Uint32, DRAW_SETPIXEL_RGB888); + break; + } + return 0; +} + +static int +SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888); + break; + default: + FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888); + break; + } + return 0; +} + +static int +SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + SDL_PixelFormat *fmt = dst->format; + unsigned inva = 0xff - a; + + switch (fmt->BytesPerPixel) { + case 2: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB); + break; + default: + FILLRECT(Uint16, DRAW_SETPIXEL_RGB); + break; + } + return 0; + case 4: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB); + break; + default: + FILLRECT(Uint32, DRAW_SETPIXEL_RGB); + break; + } + return 0; + default: + return SDL_Unsupported(); + } +} + +static int +SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + SDL_PixelFormat *fmt = dst->format; + unsigned inva = 0xff - a; + + switch (fmt->BytesPerPixel) { + case 4: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA); + break; + case SDL_BLENDMODE_ADD: + FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA); + break; + case SDL_BLENDMODE_MOD: + FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA); + break; + default: + FILLRECT(Uint32, DRAW_SETPIXEL_RGBA); + break; + } + return 0; + default: + return SDL_Unsupported(); + } +} + +int +SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + SDL_Rect clipped; + + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format"); + } + + /* If 'rect' == NULL, then fill the whole surface */ + if (rect) { + /* Perform clipping */ + if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) { + return 0; + } + rect = &clipped; + } else { + rect = &dst->clip_rect; + } + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(r, a); + g = DRAW_MUL(g, a); + b = DRAW_MUL(b, a); + } + + switch (dst->format->BitsPerPixel) { + case 15: + switch (dst->format->Rmask) { + case 0x7C00: + return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a); + } + break; + case 16: + switch (dst->format->Rmask) { + case 0xF800: + return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a); + } + break; + case 32: + switch (dst->format->Rmask) { + case 0x00FF0000: + if (!dst->format->Amask) { + return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a); + } else { + return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a); + } + /* break; -Wunreachable-code-break */ + } + break; + default: + break; + } + + if (!dst->format->Amask) { + return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a); + } else { + return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a); + } +} + +int +SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + SDL_Rect rect; + int i; + int (*func)(SDL_Surface * dst, const SDL_Rect * rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; + int status = 0; + + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format"); + } + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(r, a); + g = DRAW_MUL(g, a); + b = DRAW_MUL(b, a); + } + + /* FIXME: Does this function pointer slow things down significantly? */ + switch (dst->format->BitsPerPixel) { + case 15: + switch (dst->format->Rmask) { + case 0x7C00: + func = SDL_BlendFillRect_RGB555; + } + break; + case 16: + switch (dst->format->Rmask) { + case 0xF800: + func = SDL_BlendFillRect_RGB565; + } + break; + case 32: + switch (dst->format->Rmask) { + case 0x00FF0000: + if (!dst->format->Amask) { + func = SDL_BlendFillRect_RGB888; + } else { + func = SDL_BlendFillRect_ARGB8888; + } + break; + } + break; + default: + break; + } + + if (!func) { + if (!dst->format->Amask) { + func = SDL_BlendFillRect_RGB; + } else { + func = SDL_BlendFillRect_RGBA; + } + } + + for (i = 0; i < count; ++i) { + /* Perform clipping */ + if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) { + continue; + } + status = func(dst, &rect, blendMode, r, g, b, a); + } + return status; +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.h b/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.h new file mode 100644 index 0000000..3cac834 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendfillrect.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_blendfillrect_h_ +#define SDL_blendfillrect_h_ + +#include "../../SDL_internal.h" + + +extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +#endif /* SDL_blendfillrect_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendline.c b/source/3rd-party/SDL2/src/render/software/SDL_blendline.c new file mode 100644 index 0000000..0ed0ccd --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendline.c @@ -0,0 +1,777 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "SDL_draw.h" +#include "SDL_blendline.h" +#include "SDL_blendpoint.h" + + +static void +SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + const SDL_PixelFormat *fmt = dst->format; + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end); + break; + default: + HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end); + break; + default: + VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end); + break; + default: + DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end); + break; + default: + HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end); + break; + default: + VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end); + break; + default: + DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + const SDL_PixelFormat *fmt = dst->format; + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end); + break; + default: + DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + const SDL_PixelFormat *fmt = dst->format; + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end); + break; + default: + HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end); + break; + default: + VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end); + break; + default: + DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end); + break; + default: + HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end); + break; + default: + VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end); + break; + default: + DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888, + draw_end); + break; + } + } +} + +static void +SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) +{ + unsigned r, g, b, a, inva; + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(_r, _a); + g = DRAW_MUL(_g, _a); + b = DRAW_MUL(_b, _a); + a = _a; + } else { + r = _r; + g = _g; + b = _b; + a = _a; + } + inva = (a ^ 0xff); + + if (y1 == y2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_ADD: + HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_MOD: + HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end); + break; + default: + HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); + break; + } + } else if (x1 == x2) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_ADD: + VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_MOD: + VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end); + break; + default: + VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); + break; + } + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_ADD: + DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); + break; + case SDL_BLENDMODE_MOD: + DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end); + break; + default: + DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); + break; + } + } else { + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888, + draw_end); + break; + case SDL_BLENDMODE_ADD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888, + draw_end); + break; + case SDL_BLENDMODE_MOD: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888, + draw_end); + break; + default: + AALINE(x1, y1, x2, y2, + DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888, + draw_end); + break; + } + } +} + +typedef void (*BlendLineFunc) (SDL_Surface * dst, + int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, + SDL_bool draw_end); + +static BlendLineFunc +SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt) +{ + switch (fmt->BytesPerPixel) { + case 2: + if (fmt->Rmask == 0x7C00) { + return SDL_BlendLine_RGB555; + } else if (fmt->Rmask == 0xF800) { + return SDL_BlendLine_RGB565; + } else { + return SDL_BlendLine_RGB2; + } + /* break; -Wunreachable-code-break */ + case 4: + if (fmt->Rmask == 0x00FF0000) { + if (fmt->Amask) { + return SDL_BlendLine_ARGB8888; + } else { + return SDL_BlendLine_RGB888; + } + } else { + if (fmt->Amask) { + return SDL_BlendLine_RGBA4; + } else { + return SDL_BlendLine_RGB4; + } + } + } + return NULL; +} + +int +SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + BlendLineFunc func; + + if (!dst) { + return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface"); + } + + func = SDL_CalculateBlendLineFunc(dst->format); + if (!func) { + return SDL_SetError("SDL_BlendLine(): Unsupported surface format"); + } + + /* Perform clipping */ + /* FIXME: We don't actually want to clip, as it may change line slope */ + if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { + return 0; + } + + func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE); + return 0; +} + +int +SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + int i; + int x1, y1; + int x2, y2; + SDL_bool draw_end; + BlendLineFunc func; + + if (!dst) { + return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface"); + } + + func = SDL_CalculateBlendLineFunc(dst->format); + if (!func) { + return SDL_SetError("SDL_BlendLines(): Unsupported surface format"); + } + + for (i = 1; i < count; ++i) { + x1 = points[i-1].x; + y1 = points[i-1].y; + x2 = points[i].x; + y2 = points[i].y; + + /* Perform clipping */ + /* FIXME: We don't actually want to clip, as it may change line slope */ + if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { + continue; + } + + /* Draw the end if it was clipped */ + draw_end = (x2 != points[i].x || y2 != points[i].y); + + func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end); + } + if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + SDL_BlendPoint(dst, points[count-1].x, points[count-1].y, + blendMode, r, g, b, a); + } + return 0; +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendline.h b/source/3rd-party/SDL2/src/render/software/SDL_blendline.h new file mode 100644 index 0000000..a48a498 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendline.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_blendline_h_ +#define SDL_blendline_h_ + +#include "../../SDL_internal.h" + + +extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +#endif /* SDL_blendline_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.c b/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.c new file mode 100644 index 0000000..37fb498 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.c @@ -0,0 +1,341 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "SDL_draw.h" +#include "SDL_blendpoint.h" + + +static int +SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY_BLEND_RGB555(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY_ADD_RGB555(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY_MOD_RGB555(x, y); + break; + default: + DRAW_SETPIXELXY_RGB555(x, y); + break; + } + return 0; +} + +static int +SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY_BLEND_RGB565(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY_ADD_RGB565(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY_MOD_RGB565(x, y); + break; + default: + DRAW_SETPIXELXY_RGB565(x, y); + break; + } + return 0; +} + +static int +SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY_BLEND_RGB888(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY_ADD_RGB888(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY_MOD_RGB888(x, y); + break; + default: + DRAW_SETPIXELXY_RGB888(x, y); + break; + } + return 0; +} + +static int +SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, + Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + unsigned inva = 0xff - a; + + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY_BLEND_ARGB8888(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY_ADD_ARGB8888(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY_MOD_ARGB8888(x, y); + break; + default: + DRAW_SETPIXELXY_ARGB8888(x, y); + break; + } + return 0; +} + +static int +SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + SDL_PixelFormat *fmt = dst->format; + unsigned inva = 0xff - a; + + switch (fmt->BytesPerPixel) { + case 2: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY2_BLEND_RGB(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY2_ADD_RGB(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY2_MOD_RGB(x, y); + break; + default: + DRAW_SETPIXELXY2_RGB(x, y); + break; + } + return 0; + case 4: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY4_BLEND_RGB(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY4_ADD_RGB(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY4_MOD_RGB(x, y); + break; + default: + DRAW_SETPIXELXY4_RGB(x, y); + break; + } + return 0; + default: + return SDL_Unsupported(); + } +} + +static int +SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + SDL_PixelFormat *fmt = dst->format; + unsigned inva = 0xff - a; + + switch (fmt->BytesPerPixel) { + case 4: + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + DRAW_SETPIXELXY4_BLEND_RGBA(x, y); + break; + case SDL_BLENDMODE_ADD: + DRAW_SETPIXELXY4_ADD_RGBA(x, y); + break; + case SDL_BLENDMODE_MOD: + DRAW_SETPIXELXY4_MOD_RGBA(x, y); + break; + default: + DRAW_SETPIXELXY4_RGBA(x, y); + break; + } + return 0; + default: + return SDL_Unsupported(); + } +} + +int +SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) +{ + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_BlendPoint(): Unsupported surface format"); + } + + /* Perform clipping */ + if (x < dst->clip_rect.x || y < dst->clip_rect.y || + x >= (dst->clip_rect.x + dst->clip_rect.w) || + y >= (dst->clip_rect.y + dst->clip_rect.h)) { + return 0; + } + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(r, a); + g = DRAW_MUL(g, a); + b = DRAW_MUL(b, a); + } + + switch (dst->format->BitsPerPixel) { + case 15: + switch (dst->format->Rmask) { + case 0x7C00: + return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a); + } + break; + case 16: + switch (dst->format->Rmask) { + case 0xF800: + return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a); + } + break; + case 32: + switch (dst->format->Rmask) { + case 0x00FF0000: + if (!dst->format->Amask) { + return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b, a); + } else { + return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a); + } + /* break; -Wunreachable-code-break */ + } + break; + default: + break; + } + + if (!dst->format->Amask) { + return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a); + } else { + return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a); + } +} + +int +SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + int minx, miny; + int maxx, maxy; + int i; + int x, y; + int (*func)(SDL_Surface * dst, int x, int y, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; + int status = 0; + + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_BlendPoints(): Unsupported surface format"); + } + + if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { + r = DRAW_MUL(r, a); + g = DRAW_MUL(g, a); + b = DRAW_MUL(b, a); + } + + /* FIXME: Does this function pointer slow things down significantly? */ + switch (dst->format->BitsPerPixel) { + case 15: + switch (dst->format->Rmask) { + case 0x7C00: + func = SDL_BlendPoint_RGB555; + break; + } + break; + case 16: + switch (dst->format->Rmask) { + case 0xF800: + func = SDL_BlendPoint_RGB565; + break; + } + break; + case 32: + switch (dst->format->Rmask) { + case 0x00FF0000: + if (!dst->format->Amask) { + func = SDL_BlendPoint_RGB888; + } else { + func = SDL_BlendPoint_ARGB8888; + } + break; + } + break; + default: + break; + } + + if (!func) { + if (!dst->format->Amask) { + func = SDL_BlendPoint_RGB; + } else { + func = SDL_BlendPoint_RGBA; + } + } + + minx = dst->clip_rect.x; + maxx = dst->clip_rect.x + dst->clip_rect.w - 1; + miny = dst->clip_rect.y; + maxy = dst->clip_rect.y + dst->clip_rect.h - 1; + + for (i = 0; i < count; ++i) { + x = points[i].x; + y = points[i].y; + + if (x < minx || x > maxx || y < miny || y > maxy) { + continue; + } + status = func(dst, x, y, blendMode, r, g, b, a); + } + return status; +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.h b/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.h new file mode 100644 index 0000000..188557c --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_blendpoint.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_blendpoint_h_ +#define SDL_blendpoint_h_ + +#include "../../SDL_internal.h" + + +extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +#endif /* SDL_blendpoint_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_draw.h b/source/3rd-party/SDL2/src/render/software/SDL_draw.h new file mode 100644 index 0000000..945f2bc --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_draw.h @@ -0,0 +1,576 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "../../video/SDL_blit.h" + +/* This code assumes that r, g, b, a are the source color, + * and in the blend and add case, the RGB values are premultiplied by a. + */ + +#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255) + +#define DRAW_FASTSETPIXEL(type) \ + *pixel = (type) color + +#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8) +#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16) +#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32) + +#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \ + *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ + + (x) * bpp) = (type) color + +#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color) +#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color) +#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color) + +#define DRAW_SETPIXEL(setpixel) \ +do { \ + unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \ + setpixel; \ +} while (0) + +#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \ +do { \ + unsigned sr, sg, sb, sa = 0xFF; \ + getpixel; \ + sr = DRAW_MUL(inva, sr) + r; \ + sg = DRAW_MUL(inva, sg) + g; \ + sb = DRAW_MUL(inva, sb) + b; \ + sa = DRAW_MUL(inva, sa) + a; \ + setpixel; \ +} while (0) + +#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \ +do { \ + unsigned sr, sg, sb, sa; (void) sa; \ + getpixel; \ + sr += r; if (sr > 0xff) sr = 0xff; \ + sg += g; if (sg > 0xff) sg = 0xff; \ + sb += b; if (sb > 0xff) sb = 0xff; \ + setpixel; \ +} while (0) + +#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \ +do { \ + unsigned sr, sg, sb, sa; (void) sa; \ + getpixel; \ + sr = DRAW_MUL(sr, r); \ + sg = DRAW_MUL(sg, g); \ + sb = DRAW_MUL(sb, b); \ + setpixel; \ +} while (0) + +#define DRAW_SETPIXELXY(x, y, type, bpp, op) \ +do { \ + type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ + + (x) * bpp); \ + op; \ +} while (0) + +/* + * Define draw operators for RGB555 + */ + +#define DRAW_SETPIXEL_RGB555 \ + DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_BLEND_RGB555 \ + DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ + RGB555_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_ADD_RGB555 \ + DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ + RGB555_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_MOD_RGB555 \ + DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ + RGB555_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXELXY_RGB555(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555) + +#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555) + +#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555) + +#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555) + +/* + * Define draw operators for RGB565 + */ + +#define DRAW_SETPIXEL_RGB565 \ + DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_BLEND_RGB565 \ + DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ + RGB565_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_ADD_RGB565 \ + DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ + RGB565_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_MOD_RGB565 \ + DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ + RGB565_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXELXY_RGB565(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565) + +#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565) + +#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565) + +#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565) + +/* + * Define draw operators for RGB888 + */ + +#define DRAW_SETPIXEL_RGB888 \ + DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_BLEND_RGB888 \ + DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ + RGB888_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_ADD_RGB888 \ + DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ + RGB888_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXEL_MOD_RGB888 \ + DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ + RGB888_FROM_RGB(*pixel, sr, sg, sb)) + +#define DRAW_SETPIXELXY_RGB888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888) + +#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888) + +#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888) + +#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888) + +/* + * Define draw operators for ARGB8888 + */ + +#define DRAW_SETPIXEL_ARGB8888 \ + DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_BLEND_ARGB8888 \ + DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ + ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_ADD_ARGB8888 \ + DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ + ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_MOD_ARGB8888 \ + DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ + ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) + +#define DRAW_SETPIXELXY_ARGB8888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888) + +#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888) + +#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888) + +#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888) + +/* + * Define draw operators for general RGB + */ + +#define DRAW_SETPIXEL_RGB \ + DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) + +#define DRAW_SETPIXEL_BLEND_RGB \ + DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ + PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) + +#define DRAW_SETPIXEL_ADD_RGB \ + DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ + PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) + +#define DRAW_SETPIXEL_MOD_RGB \ + DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ + PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) + +#define DRAW_SETPIXELXY2_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB) + +#define DRAW_SETPIXELXY4_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB) + +#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB) + +#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB) + +#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB) + +#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB) + +#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB) + +#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB) + + +/* + * Define draw operators for general RGBA + */ + +#define DRAW_SETPIXEL_RGBA \ + DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_BLEND_RGBA \ + DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ + PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_ADD_RGBA \ + DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ + PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) + +#define DRAW_SETPIXEL_MOD_RGBA \ + DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ + PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) + +#define DRAW_SETPIXELXY4_RGBA(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA) + +#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA) + +#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA) + +#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \ + DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA) + +/* + * Define line drawing macro + */ + +#define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) + +/* Horizontal line */ +#define HLINE(type, op, draw_end) \ +{ \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (x1 <= x2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + length = draw_end ? (x2-x1+1) : (x2-x1); \ + } else { \ + pixel = (type *)dst->pixels + y1 * pitch + x2; \ + if (!draw_end) { \ + ++pixel; \ + } \ + length = draw_end ? (x1-x2+1) : (x1-x2); \ + } \ + while (length--) { \ + op; \ + ++pixel; \ + } \ +} + +/* Vertical line */ +#define VLINE(type, op, draw_end) \ +{ \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (y1 <= y2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + length = draw_end ? (y2-y1+1) : (y2-y1); \ + } else { \ + pixel = (type *)dst->pixels + y2 * pitch + x1; \ + if (!draw_end) { \ + pixel += pitch; \ + } \ + length = draw_end ? (y1-y2+1) : (y1-y2); \ + } \ + while (length--) { \ + op; \ + pixel += pitch; \ + } \ +} + +/* Diagonal line */ +#define DLINE(type, op, draw_end) \ +{ \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (y1 <= y2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + if (x1 <= x2) { \ + ++pitch; \ + } else { \ + --pitch; \ + } \ + length = (y2-y1); \ + } else { \ + pixel = (type *)dst->pixels + y2 * pitch + x2; \ + if (x2 <= x1) { \ + ++pitch; \ + } else { \ + --pitch; \ + } \ + if (!draw_end) { \ + pixel += pitch; \ + } \ + length = (y1-y2); \ + } \ + if (draw_end) { \ + ++length; \ + } \ + while (length--) { \ + op; \ + pixel += pitch; \ + } \ +} + +/* Bresenham's line algorithm */ +#define BLINE(x1, y1, x2, y2, op, draw_end) \ +{ \ + int i, deltax, deltay, numpixels; \ + int d, dinc1, dinc2; \ + int x, xinc1, xinc2; \ + int y, yinc1, yinc2; \ + \ + deltax = ABS(x2 - x1); \ + deltay = ABS(y2 - y1); \ + \ + if (deltax >= deltay) { \ + numpixels = deltax + 1; \ + d = (2 * deltay) - deltax; \ + dinc1 = deltay * 2; \ + dinc2 = (deltay - deltax) * 2; \ + xinc1 = 1; \ + xinc2 = 1; \ + yinc1 = 0; \ + yinc2 = 1; \ + } else { \ + numpixels = deltay + 1; \ + d = (2 * deltax) - deltay; \ + dinc1 = deltax * 2; \ + dinc2 = (deltax - deltay) * 2; \ + xinc1 = 0; \ + xinc2 = 1; \ + yinc1 = 1; \ + yinc2 = 1; \ + } \ + \ + if (x1 > x2) { \ + xinc1 = -xinc1; \ + xinc2 = -xinc2; \ + } \ + if (y1 > y2) { \ + yinc1 = -yinc1; \ + yinc2 = -yinc2; \ + } \ + \ + x = x1; \ + y = y1; \ + \ + if (!draw_end) { \ + --numpixels; \ + } \ + for (i = 0; i < numpixels; ++i) { \ + op(x, y); \ + if (d < 0) { \ + d += dinc1; \ + x += xinc1; \ + y += yinc1; \ + } else { \ + d += dinc2; \ + x += xinc2; \ + y += yinc2; \ + } \ + } \ +} + +/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */ +#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ +{ \ + Uint16 ErrorAdj, ErrorAcc; \ + Uint16 ErrorAccTemp, Weighting; \ + int DeltaX, DeltaY, Temp, XDir; \ + unsigned r, g, b, a, inva; \ + \ + /* Draw the initial pixel, which is always exactly intersected by \ + the line and so needs no weighting */ \ + opaque_op(x1, y1); \ + \ + /* Draw the final pixel, which is always exactly intersected by the line \ + and so needs no weighting */ \ + if (draw_end) { \ + opaque_op(x2, y2); \ + } \ + \ + /* Make sure the line runs top to bottom */ \ + if (y1 > y2) { \ + Temp = y1; y1 = y2; y2 = Temp; \ + Temp = x1; x1 = x2; x2 = Temp; \ + } \ + DeltaY = y2 - y1; \ + \ + if ((DeltaX = x2 - x1) >= 0) { \ + XDir = 1; \ + } else { \ + XDir = -1; \ + DeltaX = -DeltaX; /* make DeltaX positive */ \ + } \ + \ + /* line is not horizontal, diagonal, or vertical */ \ + ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \ + \ + /* Is this an X-major or Y-major line? */ \ + if (DeltaY > DeltaX) { \ + /* Y-major line; calculate 16-bit fixed-point fractional part of a \ + pixel that X advances each time Y advances 1 pixel, truncating the \ + result so that we won't overrun the endpoint along the X axis */ \ + ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \ + /* Draw all pixels other than the first and last */ \ + while (--DeltaY) { \ + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ + if (ErrorAcc <= ErrorAccTemp) { \ + /* The error accumulator turned over, so advance the X coord */ \ + x1 += XDir; \ + } \ + y1++; /* Y-major, so always advance Y */ \ + /* The IntensityBits most significant bits of ErrorAcc give us the \ + intensity weighting for this pixel, and the complement of the \ + weighting for the paired pixel */ \ + Weighting = ErrorAcc >> 8; \ + { \ + a = DRAW_MUL(_a, (Weighting ^ 255)); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1); \ + } \ + { \ + a = DRAW_MUL(_a, Weighting); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1 + XDir, y1); \ + } \ + } \ + } else { \ + /* X-major line; calculate 16-bit fixed-point fractional part of a \ + pixel that Y advances each time X advances 1 pixel, truncating the \ + result to avoid overrunning the endpoint along the X axis */ \ + ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \ + /* Draw all pixels other than the first and last */ \ + while (--DeltaX) { \ + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ + if (ErrorAcc <= ErrorAccTemp) { \ + /* The error accumulator turned over, so advance the Y coord */ \ + y1++; \ + } \ + x1 += XDir; /* X-major, so always advance X */ \ + /* The IntensityBits most significant bits of ErrorAcc give us the \ + intensity weighting for this pixel, and the complement of the \ + weighting for the paired pixel */ \ + Weighting = ErrorAcc >> 8; \ + { \ + a = DRAW_MUL(_a, (Weighting ^ 255)); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1); \ + } \ + { \ + a = DRAW_MUL(_a, Weighting); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1 + 1); \ + } \ + } \ + } \ +} + +#ifdef AA_LINES +#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ + WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) +#else +#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ + BLINE(x1, y1, x2, y2, opaque_op, draw_end) +#endif + +/* + * Define fill rect macro + */ + +#define FILLRECT(type, op) \ +do { \ + int width = rect->w; \ + int height = rect->h; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + int skip = pitch - width; \ + type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \ + while (height--) { \ + { int n = (width+3)/4; \ + switch (width & 3) { \ + case 0: do { op; pixel++; /* fallthrough */ \ + case 3: op; pixel++; /* fallthrough */ \ + case 2: op; pixel++; /* fallthrough */ \ + case 1: op; pixel++; /* fallthrough */ \ + } while ( --n > 0 ); \ + } \ + } \ + pixel += skip; \ + } \ +} while (0) + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_drawline.c b/source/3rd-party/SDL2/src/render/software/SDL_drawline.c new file mode 100644 index 0000000..eeb54ed --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_drawline.c @@ -0,0 +1,209 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "SDL_draw.h" +#include "SDL_drawline.h" +#include "SDL_drawpoint.h" + + +static void +SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) +{ + if (y1 == y2) { + int length; + int pitch = (dst->pitch / dst->format->BytesPerPixel); + Uint8 *pixel; + if (x1 <= x2) { + pixel = (Uint8 *)dst->pixels + y1 * pitch + x1; + length = draw_end ? (x2-x1+1) : (x2-x1); + } else { + pixel = (Uint8 *)dst->pixels + y1 * pitch + x2; + if (!draw_end) { + ++pixel; + } + length = draw_end ? (x1-x2+1) : (x1-x2); + } + SDL_memset(pixel, color, length); + } else if (x1 == x2) { + VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end); + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end); + } else { + BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end); + } +} + +static void +SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) +{ + if (y1 == y2) { + HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); + } else if (x1 == x2) { + VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); + } else { + Uint8 _r, _g, _b, _a; + const SDL_PixelFormat * fmt = dst->format; + SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a); + if (fmt->Rmask == 0x7C00) { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555, + draw_end); + } else if (fmt->Rmask == 0xF800) { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565, + draw_end); + } else { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB, + draw_end); + } + } +} + +static void +SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) +{ + if (y1 == y2) { + HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); + } else if (x1 == x2) { + VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); + } else if (ABS(x1 - x2) == ABS(y1 - y2)) { + DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); + } else { + Uint8 _r, _g, _b, _a; + const SDL_PixelFormat * fmt = dst->format; + SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a); + if (fmt->Rmask == 0x00FF0000) { + if (!fmt->Amask) { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888, + draw_end); + } else { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888, + draw_end); + } + } else { + AALINE(x1, y1, x2, y2, + DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB, + draw_end); + } + } +} + +typedef void (*DrawLineFunc) (SDL_Surface * dst, + int x1, int y1, int x2, int y2, + Uint32 color, SDL_bool draw_end); + +static DrawLineFunc +SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt) +{ + switch (fmt->BytesPerPixel) { + case 1: + if (fmt->BitsPerPixel < 8) { + break; + } + return SDL_DrawLine1; + case 2: + return SDL_DrawLine2; + case 4: + return SDL_DrawLine4; + } + return NULL; +} + +int +SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color) +{ + DrawLineFunc func; + + if (!dst) { + return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface"); + } + + func = SDL_CalculateDrawLineFunc(dst->format); + if (!func) { + return SDL_SetError("SDL_DrawLine(): Unsupported surface format"); + } + + /* Perform clipping */ + /* FIXME: We don't actually want to clip, as it may change line slope */ + if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { + return 0; + } + + func(dst, x1, y1, x2, y2, color, SDL_TRUE); + return 0; +} + +int +SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, + Uint32 color) +{ + int i; + int x1, y1; + int x2, y2; + SDL_bool draw_end; + DrawLineFunc func; + + if (!dst) { + return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface"); + } + + func = SDL_CalculateDrawLineFunc(dst->format); + if (!func) { + return SDL_SetError("SDL_DrawLines(): Unsupported surface format"); + } + + for (i = 1; i < count; ++i) { + x1 = points[i-1].x; + y1 = points[i-1].y; + x2 = points[i].x; + y2 = points[i].y; + + /* Perform clipping */ + /* FIXME: We don't actually want to clip, as it may change line slope */ + if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { + continue; + } + + /* Draw the end if it was clipped */ + draw_end = (x2 != points[i].x || y2 != points[i].y); + + func(dst, x1, y1, x2, y2, color, draw_end); + } + if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color); + } + return 0; +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_drawline.h b/source/3rd-party/SDL2/src/render/software/SDL_drawline.h new file mode 100644 index 0000000..4e8e2bd --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_drawline.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_drawline_h_ +#define SDL_drawline_h_ + +#include "../../SDL_internal.h" + + +extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color); +extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); + +#endif /* SDL_drawline_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.c b/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.c new file mode 100644 index 0000000..64a4e52 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.c @@ -0,0 +1,114 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "SDL_draw.h" +#include "SDL_drawpoint.h" + + +int +SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color) +{ + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_DrawPoint(): Unsupported surface format"); + } + + /* Perform clipping */ + if (x < dst->clip_rect.x || y < dst->clip_rect.y || + x >= (dst->clip_rect.x + dst->clip_rect.w) || + y >= (dst->clip_rect.y + dst->clip_rect.h)) { + return 0; + } + + switch (dst->format->BytesPerPixel) { + case 1: + DRAW_FASTSETPIXELXY1(x, y); + break; + case 2: + DRAW_FASTSETPIXELXY2(x, y); + break; + case 3: + return SDL_Unsupported(); + case 4: + DRAW_FASTSETPIXELXY4(x, y); + break; + } + return 0; +} + +int +SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, + Uint32 color) +{ + int minx, miny; + int maxx, maxy; + int i; + int x, y; + + if (!dst) { + return SDL_SetError("Passed NULL destination surface"); + } + + /* This function doesn't work on surfaces < 8 bpp */ + if (dst->format->BitsPerPixel < 8) { + return SDL_SetError("SDL_DrawPoints(): Unsupported surface format"); + } + + minx = dst->clip_rect.x; + maxx = dst->clip_rect.x + dst->clip_rect.w - 1; + miny = dst->clip_rect.y; + maxy = dst->clip_rect.y + dst->clip_rect.h - 1; + + for (i = 0; i < count; ++i) { + x = points[i].x; + y = points[i].y; + + if (x < minx || x > maxx || y < miny || y > maxy) { + continue; + } + + switch (dst->format->BytesPerPixel) { + case 1: + DRAW_FASTSETPIXELXY1(x, y); + break; + case 2: + DRAW_FASTSETPIXELXY2(x, y); + break; + case 3: + return SDL_Unsupported(); + case 4: + DRAW_FASTSETPIXELXY4(x, y); + break; + } + } + return 0; +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.h b/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.h new file mode 100644 index 0000000..454774d --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_drawpoint.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_drawpoint_h_ +#define SDL_drawpoint_h_ + +#include "../../SDL_internal.h" + + +extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color); +extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); + +#endif /* SDL_drawpoint_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_render_sw.c b/source/3rd-party/SDL2/src/render/software/SDL_render_sw.c new file mode 100644 index 0000000..709dfe8 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_render_sw.c @@ -0,0 +1,887 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if !SDL_RENDER_DISABLED + +#include "../SDL_sysrender.h" +#include "SDL_render_sw_c.h" +#include "SDL_hints.h" + +#include "SDL_draw.h" +#include "SDL_blendfillrect.h" +#include "SDL_blendline.h" +#include "SDL_blendpoint.h" +#include "SDL_drawline.h" +#include "SDL_drawpoint.h" +#include "SDL_rotate.h" + +/* SDL surface based renderer implementation */ + +static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags); +static void SW_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); +static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int SW_SetTextureColorMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_SetTextureAlphaMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_SetTextureBlendMode(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int SW_UpdateViewport(SDL_Renderer * renderer); +static int SW_UpdateClipRect(SDL_Renderer * renderer); +static int SW_RenderClear(SDL_Renderer * renderer); +static int SW_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int SW_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int SW_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip); +static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static void SW_RenderPresent(SDL_Renderer * renderer); +static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void SW_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver SW_RenderDriver = { + SW_CreateRenderer, + { + "software", + SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE, + 8, + { + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_BGRA8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_BGR888, + SDL_PIXELFORMAT_RGB565, + SDL_PIXELFORMAT_RGB555 + }, + 0, + 0} +}; + +typedef struct +{ + SDL_Surface *surface; + SDL_Surface *window; +} SW_RenderData; + + +static SDL_Surface * +SW_ActivateRenderer(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (!data->surface) { + data->surface = data->window; + } + if (!data->surface) { + SDL_Surface *surface = SDL_GetWindowSurface(renderer->window); + if (surface) { + data->surface = data->window = surface; + + SW_UpdateViewport(renderer); + SW_UpdateClipRect(renderer); + } + } + return data->surface; +} + +SDL_Renderer * +SW_CreateRendererForSurface(SDL_Surface * surface) +{ + SDL_Renderer *renderer; + SW_RenderData *data; + + if (!surface) { + SDL_SetError("Can't create renderer for NULL surface"); + return NULL; + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (SW_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SW_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + data->surface = surface; + data->window = surface; + + renderer->WindowEvent = SW_WindowEvent; + renderer->GetOutputSize = SW_GetOutputSize; + renderer->CreateTexture = SW_CreateTexture; + renderer->SetTextureColorMod = SW_SetTextureColorMod; + renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod; + renderer->SetTextureBlendMode = SW_SetTextureBlendMode; + renderer->UpdateTexture = SW_UpdateTexture; + renderer->LockTexture = SW_LockTexture; + renderer->UnlockTexture = SW_UnlockTexture; + renderer->SetRenderTarget = SW_SetRenderTarget; + renderer->UpdateViewport = SW_UpdateViewport; + renderer->UpdateClipRect = SW_UpdateClipRect; + renderer->RenderClear = SW_RenderClear; + renderer->RenderDrawPoints = SW_RenderDrawPoints; + renderer->RenderDrawLines = SW_RenderDrawLines; + renderer->RenderFillRects = SW_RenderFillRects; + renderer->RenderCopy = SW_RenderCopy; + renderer->RenderCopyEx = SW_RenderCopyEx; + renderer->RenderReadPixels = SW_RenderReadPixels; + renderer->RenderPresent = SW_RenderPresent; + renderer->DestroyTexture = SW_DestroyTexture; + renderer->DestroyRenderer = SW_DestroyRenderer; + renderer->info = SW_RenderDriver.info; + renderer->driverdata = data; + + SW_ActivateRenderer(renderer); + + return renderer; +} + +SDL_Renderer * +SW_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Surface *surface; + + surface = SDL_GetWindowSurface(window); + if (!surface) { + return NULL; + } + return SW_CreateRendererForSurface(surface); +} + +static void +SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + data->surface = NULL; + data->window = NULL; + } +} + +static int +SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + + if (surface) { + if (w) { + *w = surface->w; + } + if (h) { + *h = surface->h; + } + return 0; + } else { + SDL_SetError("Software renderer doesn't have an output surface"); + return -1; + } +} + +static int +SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + if (!SDL_PixelFormatEnumToMasks + (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + return SDL_SetError("Unknown texture format"); + } + + texture->driverdata = + SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, + Bmask, Amask); + SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g, + texture->b); + SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a); + SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode); + + /* Only RLE encode textures without an alpha channel since the RLE coder + * discards the color values of pixels with an alpha value of zero. + */ + if (texture->access == SDL_TEXTUREACCESS_STATIC && !Amask) { + SDL_SetSurfaceRLE(texture->driverdata, 1); + } + + if (!texture->driverdata) { + return -1; + } + return 0; +} + +static int +SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + /* If the color mod is ever enabled (non-white), permanently disable RLE (which doesn't support + * color mod) to avoid potentially frequent RLE encoding/decoding. + */ + if ((texture->r & texture->g & texture->b) != 255) { + SDL_SetSurfaceRLE(surface, 0); + } + return SDL_SetSurfaceColorMod(surface, texture->r, texture->g, + texture->b); +} + +static int +SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + /* If the texture ever has multiple alpha values (surface alpha plus alpha channel), permanently + * disable RLE (which doesn't support this) to avoid potentially frequent RLE encoding/decoding. + */ + if (texture->a != 255 && surface->format->Amask) { + SDL_SetSurfaceRLE(surface, 0); + } + return SDL_SetSurfaceAlphaMod(surface, texture->a); +} + +static int +SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + /* If add or mod blending are ever enabled, permanently disable RLE (which doesn't support + * them) to avoid potentially frequent RLE encoding/decoding. + */ + if ((texture->blendMode == SDL_BLENDMODE_ADD || texture->blendMode == SDL_BLENDMODE_MOD)) { + SDL_SetSurfaceRLE(surface, 0); + } + return SDL_SetSurfaceBlendMode(surface, texture->blendMode); +} + +static int +SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + Uint8 *src, *dst; + int row; + size_t length; + + if(SDL_MUSTLOCK(surface)) + SDL_LockSurface(surface); + src = (Uint8 *) pixels; + dst = (Uint8 *) surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel; + length = rect->w * surface->format->BytesPerPixel; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += surface->pitch; + } + if(SDL_MUSTLOCK(surface)) + SDL_UnlockSurface(surface); + return 0; +} + +static int +SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); + *pitch = surface->pitch; + return 0; +} + +static void +SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ +} + +static int +SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (texture ) { + data->surface = (SDL_Surface *) texture->driverdata; + } else { + data->surface = data->window; + } + return 0; +} + +static int +SW_UpdateViewport(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SDL_Surface *surface = data->surface; + + if (!surface) { + /* We'll update the viewport after we recreate the surface */ + return 0; + } + + SDL_SetClipRect(data->surface, &renderer->viewport); + return 0; +} + +static int +SW_UpdateClipRect(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SDL_Surface *surface = data->surface; + if (surface) { + if (renderer->clipping_enabled) { + SDL_Rect clip_rect; + clip_rect = renderer->clip_rect; + clip_rect.x += renderer->viewport.x; + clip_rect.y += renderer->viewport.y; + SDL_IntersectRect(&renderer->viewport, &clip_rect, &clip_rect); + SDL_SetClipRect(surface, &clip_rect); + } else { + SDL_SetClipRect(surface, &renderer->viewport); + } + } + return 0; +} + +static int +SW_RenderClear(SDL_Renderer * renderer) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + Uint32 color; + SDL_Rect clip_rect; + + if (!surface) { + return -1; + } + + color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, renderer->a); + + /* By definition the clear ignores the clip rect */ + clip_rect = surface->clip_rect; + SDL_SetClipRect(surface, NULL); + SDL_FillRect(surface, NULL, color); + SDL_SetClipRect(surface, &clip_rect); + return 0; +} + +static int +SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Point *final_points; + int i, status; + + if (!surface) { + return -1; + } + + final_points = SDL_stack_alloc(SDL_Point, count); + if (!final_points) { + return SDL_OutOfMemory(); + } + if (renderer->viewport.x || renderer->viewport.y) { + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + for (i = 0; i < count; ++i) { + final_points[i].x = (int)(x + points[i].x); + final_points[i].y = (int)(y + points[i].y); + } + } else { + for (i = 0; i < count; ++i) { + final_points[i].x = (int)points[i].x; + final_points[i].y = (int)points[i].y; + } + } + + /* Draw the points! */ + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + + status = SDL_DrawPoints(surface, final_points, count, color); + } else { + status = SDL_BlendPoints(surface, final_points, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + SDL_stack_free(final_points); + + return status; +} + +static int +SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, + int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Point *final_points; + int i, status; + + if (!surface) { + return -1; + } + + final_points = SDL_stack_alloc(SDL_Point, count); + if (!final_points) { + return SDL_OutOfMemory(); + } + if (renderer->viewport.x || renderer->viewport.y) { + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + for (i = 0; i < count; ++i) { + final_points[i].x = (int)(x + points[i].x); + final_points[i].y = (int)(y + points[i].y); + } + } else { + for (i = 0; i < count; ++i) { + final_points[i].x = (int)points[i].x; + final_points[i].y = (int)points[i].y; + } + } + + /* Draw the lines! */ + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + + status = SDL_DrawLines(surface, final_points, count, color); + } else { + status = SDL_BlendLines(surface, final_points, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + SDL_stack_free(final_points); + + return status; +} + +static int +SW_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Rect *final_rects; + int i, status; + + if (!surface) { + return -1; + } + + final_rects = SDL_stack_alloc(SDL_Rect, count); + if (!final_rects) { + return SDL_OutOfMemory(); + } + if (renderer->viewport.x || renderer->viewport.y) { + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + for (i = 0; i < count; ++i) { + final_rects[i].x = (int)(x + rects[i].x); + final_rects[i].y = (int)(y + rects[i].y); + final_rects[i].w = SDL_max((int)rects[i].w, 1); + final_rects[i].h = SDL_max((int)rects[i].h, 1); + } + } else { + for (i = 0; i < count; ++i) { + final_rects[i].x = (int)rects[i].x; + final_rects[i].y = (int)rects[i].y; + final_rects[i].w = SDL_max((int)rects[i].w, 1); + final_rects[i].h = SDL_max((int)rects[i].h, 1); + } + } + + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + status = SDL_FillRects(surface, final_rects, count, color); + } else { + status = SDL_BlendFillRects(surface, final_rects, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + SDL_stack_free(final_rects); + + return status; +} + +static int +SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Surface *src = (SDL_Surface *) texture->driverdata; + SDL_Rect final_rect; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + final_rect.x = (int)(renderer->viewport.x + dstrect->x); + final_rect.y = (int)(renderer->viewport.y + dstrect->y); + } else { + final_rect.x = (int)dstrect->x; + final_rect.y = (int)dstrect->y; + } + final_rect.w = (int)dstrect->w; + final_rect.h = (int)dstrect->h; + + if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) { + return SDL_BlitSurface(src, srcrect, surface, &final_rect); + } else { + /* If scaling is ever done, permanently disable RLE (which doesn't support scaling) + * to avoid potentially frequent RLE encoding/decoding. + */ + SDL_SetSurfaceRLE(surface, 0); + return SDL_BlitScaled(src, srcrect, surface, &final_rect); + } +} + +static int +SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Surface *src = (SDL_Surface *) texture->driverdata; + SDL_Rect final_rect, tmp_rect; + SDL_Surface *src_clone, *src_rotated, *src_scaled; + SDL_Surface *mask = NULL, *mask_rotated = NULL; + int retval = 0, dstwidth, dstheight, abscenterx, abscentery; + double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y; + SDL_BlendMode blendmode; + Uint8 alphaMod, rMod, gMod, bMod; + int applyModulation = SDL_FALSE; + int blitRequired = SDL_FALSE; + int isOpaque = SDL_FALSE; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + final_rect.x = (int)(renderer->viewport.x + dstrect->x); + final_rect.y = (int)(renderer->viewport.y + dstrect->y); + } else { + final_rect.x = (int)dstrect->x; + final_rect.y = (int)dstrect->y; + } + final_rect.w = (int)dstrect->w; + final_rect.h = (int)dstrect->h; + + tmp_rect = final_rect; + tmp_rect.x = 0; + tmp_rect.y = 0; + + /* It is possible to encounter an RLE encoded surface here and locking it is + * necessary because this code is going to access the pixel buffer directly. + */ + if (SDL_MUSTLOCK(src)) { + SDL_LockSurface(src); + } + + /* Clone the source surface but use its pixel buffer directly. + * The original source surface must be treated as read-only. + */ + src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch, + src->format->Rmask, src->format->Gmask, + src->format->Bmask, src->format->Amask); + if (src_clone == NULL) { + if (SDL_MUSTLOCK(src)) { + SDL_UnlockSurface(src); + } + return -1; + } + + SDL_GetSurfaceBlendMode(src, &blendmode); + SDL_GetSurfaceAlphaMod(src, &alphaMod); + SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod); + + /* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */ + if (src->format->BitsPerPixel != 32 || SDL_PIXELLAYOUT(src->format->format) != SDL_PACKEDLAYOUT_8888 || !src->format->Amask) { + blitRequired = SDL_TRUE; + } + + /* If scaling and cropping is necessary, it has to be taken care of before the rotation. */ + if (!(srcrect->w == final_rect.w && srcrect->h == final_rect.h && srcrect->x == 0 && srcrect->y == 0)) { + blitRequired = SDL_TRUE; + } + + /* srcrect is not selecting the whole src surface, so cropping is needed */ + if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) { + blitRequired = SDL_TRUE; + } + + /* The color and alpha modulation has to be applied before the rotation when using the NONE and MOD blend modes. */ + if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD) && (alphaMod & rMod & gMod & bMod) != 255) { + applyModulation = SDL_TRUE; + SDL_SetSurfaceAlphaMod(src_clone, alphaMod); + SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod); + } + + /* Opaque surfaces are much easier to handle with the NONE blend mode. */ + if (blendmode == SDL_BLENDMODE_NONE && !src->format->Amask && alphaMod == 255) { + isOpaque = SDL_TRUE; + } + + /* The NONE blend mode requires a mask for non-opaque surfaces. This mask will be used + * to clear the pixels in the destination surface. The other steps are explained below. + */ + if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { + mask = SDL_CreateRGBSurface(0, final_rect.w, final_rect.h, 32, + 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); + if (mask == NULL) { + retval = -1; + } else { + SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD); + } + } + + /* Create a new surface should there be a format mismatch or if scaling, cropping, + * or modulation is required. It's possible to use the source surface directly otherwise. + */ + if (!retval && (blitRequired || applyModulation)) { + SDL_Rect scale_rect = tmp_rect; + src_scaled = SDL_CreateRGBSurface(0, final_rect.w, final_rect.h, 32, + 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); + if (src_scaled == NULL) { + retval = -1; + } else { + SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); + retval = SDL_BlitScaled(src_clone, srcrect, src_scaled, &scale_rect); + SDL_FreeSurface(src_clone); + src_clone = src_scaled; + src_scaled = NULL; + } + } + + /* SDLgfx_rotateSurface is going to make decisions depending on the blend mode. */ + SDL_SetSurfaceBlendMode(src_clone, blendmode); + + if (!retval) { + SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, &dstwidth, &dstheight, &cangle, &sangle); + src_rotated = SDLgfx_rotateSurface(src_clone, angle, dstwidth/2, dstheight/2, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle); + if (src_rotated == NULL) { + retval = -1; + } + if (!retval && mask != NULL) { + /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ + mask_rotated = SDLgfx_rotateSurface(mask, angle, dstwidth/2, dstheight/2, SDL_FALSE, 0, 0, dstwidth, dstheight, cangle, sangle); + if (mask_rotated == NULL) { + retval = -1; + } + } + if (!retval) { + /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */ + abscenterx = final_rect.x + (int)center->x; + abscentery = final_rect.y + (int)center->y; + /* Compensate the angle inversion to match the behaviour of the other backends */ + sangle = -sangle; + + /* Top Left */ + px = final_rect.x - abscenterx; + py = final_rect.y - abscentery; + p1x = px * cangle - py * sangle + abscenterx; + p1y = px * sangle + py * cangle + abscentery; + + /* Top Right */ + px = final_rect.x + final_rect.w - abscenterx; + py = final_rect.y - abscentery; + p2x = px * cangle - py * sangle + abscenterx; + p2y = px * sangle + py * cangle + abscentery; + + /* Bottom Left */ + px = final_rect.x - abscenterx; + py = final_rect.y + final_rect.h - abscentery; + p3x = px * cangle - py * sangle + abscenterx; + p3y = px * sangle + py * cangle + abscentery; + + /* Bottom Right */ + px = final_rect.x + final_rect.w - abscenterx; + py = final_rect.y + final_rect.h - abscentery; + p4x = px * cangle - py * sangle + abscenterx; + p4y = px * sangle + py * cangle + abscentery; + + tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x)); + tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y)); + tmp_rect.w = dstwidth; + tmp_rect.h = dstheight; + + /* The NONE blend mode needs some special care with non-opaque surfaces. + * Other blend modes or opaque surfaces can be blitted directly. + */ + if (blendmode != SDL_BLENDMODE_NONE || isOpaque) { + if (applyModulation == SDL_FALSE) { + /* If the modulation wasn't already applied, make it happen now. */ + SDL_SetSurfaceAlphaMod(src_rotated, alphaMod); + SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod); + } + retval = SDL_BlitSurface(src_rotated, NULL, surface, &tmp_rect); + } else { + /* The NONE blend mode requires three steps to get the pixels onto the destination surface. + * First, the area where the rotated pixels will be blitted to get set to zero. + * This is accomplished by simply blitting a mask with the NONE blend mode. + * The colorkey set by the rotate function will discard the correct pixels. + */ + SDL_Rect mask_rect = tmp_rect; + SDL_SetSurfaceBlendMode(mask_rotated, SDL_BLENDMODE_NONE); + retval = SDL_BlitSurface(mask_rotated, NULL, surface, &mask_rect); + if (!retval) { + /* The next step copies the alpha value. This is done with the BLEND blend mode and + * by modulating the source colors with 0. Since the destination is all zeros, this + * will effectively set the destination alpha to the source alpha. + */ + SDL_SetSurfaceColorMod(src_rotated, 0, 0, 0); + mask_rect = tmp_rect; + retval = SDL_BlitSurface(src_rotated, NULL, surface, &mask_rect); + if (!retval) { + /* The last step gets the color values in place. The ADD blend mode simply adds them to + * the destination (where the color values are all zero). However, because the ADD blend + * mode modulates the colors with the alpha channel, a surface without an alpha mask needs + * to be created. This makes all source pixels opaque and the colors get copied correctly. + */ + SDL_Surface *src_rotated_rgb; + src_rotated_rgb = SDL_CreateRGBSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h, + src_rotated->format->BitsPerPixel, src_rotated->pitch, + src_rotated->format->Rmask, src_rotated->format->Gmask, + src_rotated->format->Bmask, 0); + if (src_rotated_rgb == NULL) { + retval = -1; + } else { + SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD); + retval = SDL_BlitSurface(src_rotated_rgb, NULL, surface, &tmp_rect); + SDL_FreeSurface(src_rotated_rgb); + } + } + } + SDL_FreeSurface(mask_rotated); + } + if (src_rotated != NULL) { + SDL_FreeSurface(src_rotated); + } + } + } + + if (SDL_MUSTLOCK(src)) { + SDL_UnlockSurface(src); + } + if (mask != NULL) { + SDL_FreeSurface(mask); + } + if (src_clone != NULL) { + SDL_FreeSurface(src_clone); + } + return retval; +} + +static int +SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + Uint32 src_format; + void *src_pixels; + + if (!surface) { + return -1; + } + + /* NOTE: The rect is already adjusted according to the viewport by + * SDL_RenderReadPixels. + */ + + if (rect->x < 0 || rect->x+rect->w > surface->w || + rect->y < 0 || rect->y+rect->h > surface->h) { + return SDL_SetError("Tried to read outside of surface bounds"); + } + + src_format = surface->format->format; + src_pixels = (void*)((Uint8 *) surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); + + return SDL_ConvertPixels(rect->w, rect->h, + src_format, src_pixels, surface->pitch, + format, pixels, pitch); +} + +static void +SW_RenderPresent(SDL_Renderer * renderer) +{ + SDL_Window *window = renderer->window; + + if (window) { + SDL_UpdateWindowSurface(window); + } +} + +static void +SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + + SDL_FreeSurface(surface); +} + +static void +SW_DestroyRenderer(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + SDL_free(data); + SDL_free(renderer); +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_render_sw_c.h b/source/3rd-party/SDL2/src/render/software/SDL_render_sw_c.h new file mode 100644 index 0000000..f228517 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_render_sw_c.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_render_sw_c_h_ +#define SDL_render_sw_c_h_ + +extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface); + +#endif /* SDL_render_sw_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/source/3rd-party/SDL2/src/render/software/SDL_rotate.c b/source/3rd-party/SDL2/src/render/software/SDL_rotate.c new file mode 100644 index 0000000..09e099c --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_rotate.c @@ -0,0 +1,534 @@ +/* + +SDL_rotate.c: rotates 32bit or 8bit surfaces + +Shamelessly stolen from SDL_gfx by Andreas Schiffler. Original copyright follows: + +Copyright (C) 2001-2011 Andreas Schiffler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + +Andreas Schiffler -- aschiffler at ferzkopp dot net + +*/ +#include "../../SDL_internal.h" + +#if defined(__WIN32__) +#include "../../core/windows/SDL_windows.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#include "SDL.h" +#include "SDL_rotate.h" + +/* ---- Internally used structures */ + +/* ! +\brief A 32 bit RGBA pixel. +*/ +typedef struct tColorRGBA { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} tColorRGBA; + +/* ! +\brief A 8bit Y/palette pixel. +*/ +typedef struct tColorY { + Uint8 y; +} tColorY; + +/* ! +\brief Returns maximum of two numbers a and b. +*/ +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) + +/* ! +\brief Number of guard rows added to destination surfaces. + +This is a simple but effective workaround for observed issues. +These rows allocate extra memory and are then hidden from the surface. +Rows are added to the end of destination surfaces when they are allocated. +This catches any potential overflows which seem to happen with +just the right src image dimensions and scale/rotation and can lead +to a situation where the program can segfault. +*/ +#define GUARD_ROWS (2) + +/* ! +\brief Returns colorkey info for a surface +*/ +static Uint32 +_colorkey(SDL_Surface *src) +{ + Uint32 key = 0; + if (SDL_HasColorKey(src)) { + SDL_GetColorKey(src, &key); + } + return key; +} + + +/* ! +\brief Internal target surface sizing function for rotations with trig result return. + +\param width The source surface width. +\param height The source surface height. +\param angle The angle to rotate in degrees. +\param dstwidth The calculated width of the destination surface. +\param dstheight The calculated height of the destination surface. +\param cangle The sine of the angle +\param sangle The cosine of the angle + +*/ +void +SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, + int *dstwidth, int *dstheight, + double *cangle, double *sangle) +{ + /* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */ + int angle90 = (int)(angle/90); + if(angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */ + angle90 %= 4; + if(angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ + if(angle90 & 1) { + *dstwidth = height; + *dstheight = width; + *cangle = 0; + *sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */ + } else { + *dstwidth = width; + *dstheight = height; + *cangle = angle90 == 0 ? 1 : -1; + *sangle = 0; + } + } else { + double x, y, cx, cy, sx, sy; + double radangle; + int dstwidthhalf, dstheighthalf; + /* + * Determine destination width and height by rotating a centered source box + */ + radangle = angle * (M_PI / -180.0); /* reverse the angle because our rotations are clockwise */ + *sangle = SDL_sin(radangle); + *cangle = SDL_cos(radangle); + x = (double)(width / 2); + y = (double)(height / 2); + cx = *cangle * x; + cy = *cangle * y; + sx = *sangle * x; + sy = *sangle * y; + + dstwidthhalf = MAX((int) + SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1); + dstheighthalf = MAX((int) + SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1); + *dstwidth = 2 * dstwidthhalf; + *dstheight = 2 * dstheighthalf; + } +} + +/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */ +static void +computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy, + int *sincx, int *sincy, int *signx, int *signy) +{ + int pitch = flipy ? -src->pitch : src->pitch; + if (flipx) { + bpp = -bpp; + } + switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ + case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break; + case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break; + case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break; + case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break; + } + if (flipx) { + *signx = -*signx; + } + if (flipy) { + *signy = -*signy; + } +} + +/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */ +#define TRANSFORM_SURFACE_90(pixelType) \ + int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \ + Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \ + \ + computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \ + if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \ + if (signy < 0) sp += (src->h-1)*src->pitch; \ + \ + for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \ + if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \ + SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \ + sp += dst->w*sizeof(pixelType); \ + dp += dst->w*sizeof(pixelType); \ + } else { \ + for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \ + *(pixelType*)dp = *(pixelType*)sp; \ + } \ + } \ + } + +static void +transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy) +{ + TRANSFORM_SURFACE_90(tColorRGBA); +} + +static void +transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy) +{ + TRANSFORM_SURFACE_90(tColorY); +} + +#undef TRANSFORM_SURFACE_90 + +/* ! +\brief Internal 32 bit rotozoomer with optional anti-aliasing. + +Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control +parameters by scanning the destination surface and applying optionally anti-aliasing +by bilinear interpolation. +Assumes src and dst surfaces are of 32 bit depth. +Assumes dst surface was allocated with the correct dimensions. + +\param src Source surface. +\param dst Destination surface. +\param cx Horizontal center coordinate. +\param cy Vertical center coordinate. +\param isin Integer version of sine of angle. +\param icos Integer version of cosine of angle. +\param flipx Flag indicating horizontal mirroring should be applied. +\param flipy Flag indicating vertical mirroring should be applied. +\param smooth Flag indicating anti-aliasing should be used. +*/ +static void +_transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) +{ + int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh; + tColorRGBA c00, c01, c10, c11, cswap; + tColorRGBA *pc, *sp; + int gap; + + /* + * Variable setup + */ + xd = ((src->w - dst->w) << 15); + yd = ((src->h - dst->h) << 15); + ax = (cx << 16) - (icos * cx); + ay = (cy << 16) - (isin * cx); + sw = src->w - 1; + sh = src->h - 1; + pc = (tColorRGBA*) dst->pixels; + gap = dst->pitch - dst->w * 4; + + /* + * Switch between interpolating and non-interpolating code + */ + if (smooth) { + for (y = 0; y < dst->h; y++) { + dy = cy - y; + sdx = (ax + (isin * dy)) + xd; + sdy = (ay - (icos * dy)) + yd; + for (x = 0; x < dst->w; x++) { + dx = (sdx >> 16); + dy = (sdy >> 16); + if (flipx) dx = sw - dx; + if (flipy) dy = sh - dy; + if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) { + sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx; + c00 = *sp; + sp += 1; + c01 = *sp; + sp += (src->pitch/4); + c11 = *sp; + sp -= 1; + c10 = *sp; + if (flipx) { + cswap = c00; c00=c01; c01=cswap; + cswap = c10; c10=c11; c11=cswap; + } + if (flipy) { + cswap = c00; c00=c10; c10=cswap; + cswap = c01; c01=c11; c11=cswap; + } + /* + * Interpolate colors + */ + ex = (sdx & 0xffff); + ey = (sdy & 0xffff); + t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff; + t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff; + pc->r = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff; + t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff; + pc->g = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff; + t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff; + pc->b = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff; + t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff; + pc->a = (((t2 - t1) * ey) >> 16) + t1; + } + sdx += icos; + sdy += isin; + pc++; + } + pc = (tColorRGBA *) ((Uint8 *) pc + gap); + } + } else { + for (y = 0; y < dst->h; y++) { + dy = cy - y; + sdx = (ax + (isin * dy)) + xd; + sdy = (ay - (icos * dy)) + yd; + for (x = 0; x < dst->w; x++) { + dx = (sdx >> 16); + dy = (sdy >> 16); + if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) { + if(flipx) dx = sw - dx; + if(flipy) dy = sh - dy; + *pc = *((tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx); + } + sdx += icos; + sdy += isin; + pc++; + } + pc = (tColorRGBA *) ((Uint8 *) pc + gap); + } + } +} + +/* ! + +\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing. + +Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control +parameters by scanning the destination surface. +Assumes src and dst surfaces are of 8 bit depth. +Assumes dst surface was allocated with the correct dimensions. + +\param src Source surface. +\param dst Destination surface. +\param cx Horizontal center coordinate. +\param cy Vertical center coordinate. +\param isin Integer version of sine of angle. +\param icos Integer version of cosine of angle. +\param flipx Flag indicating horizontal mirroring should be applied. +\param flipy Flag indicating vertical mirroring should be applied. +*/ +static void +transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy) +{ + int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay; + tColorY *pc; + int gap; + + /* + * Variable setup + */ + xd = ((src->w - dst->w) << 15); + yd = ((src->h - dst->h) << 15); + ax = (cx << 16) - (icos * cx); + ay = (cy << 16) - (isin * cx); + pc = (tColorY*) dst->pixels; + gap = dst->pitch - dst->w; + /* + * Clear surface to colorkey + */ + SDL_memset(pc, (int)(_colorkey(src) & 0xff), dst->pitch * dst->h); + /* + * Iterate through destination surface + */ + for (y = 0; y < dst->h; y++) { + dy = cy - y; + sdx = (ax + (isin * dy)) + xd; + sdy = (ay - (icos * dy)) + yd; + for (x = 0; x < dst->w; x++) { + dx = (sdx >> 16); + dy = (sdy >> 16); + if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) { + if (flipx) dx = (src->w-1)-dx; + if (flipy) dy = (src->h-1)-dy; + *pc = *((tColorY *)src->pixels + src->pitch * dy + dx); + } + sdx += icos; + sdy += isin; + pc++; + } + pc += gap; + } +} + + +/* ! +\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing. + +Rotates a 32-bit or 8-bit 'src' surface to newly created 'dst' surface. +'angle' is the rotation in degrees, 'centerx' and 'centery' the rotation center. If 'smooth' is set +then the destination 32-bit surface is anti-aliased. 8-bit surfaces must have a colorkey. 32-bit +surfaces must have a 8888 layout with red, green, blue and alpha masks (any ordering goes). +The blend mode of the 'src' surface has some effects on generation of the 'dst' surface: The NONE +mode will set the BLEND mode on the 'dst' surface. The MOD mode either generates a white 'dst' +surface and sets the colorkey or fills the it with the colorkey before copying the pixels. +When using the NONE and MOD modes, color and alpha modulation must be applied before using this function. + +\param src The surface to rotozoom. +\param angle The angle to rotate in degrees. +\param centerx The horizontal coordinate of the center of rotation +\param zoomy The vertical coordinate of the center of rotation +\param smooth Antialiasing flag; set to SMOOTHING_ON to enable. +\param flipx Set to 1 to flip the image horizontally +\param flipy Set to 1 to flip the image vertically +\param dstwidth The destination surface width +\param dstheight The destination surface height +\param cangle The angle cosine +\param sangle The angle sine +\return The new rotated surface. + +*/ + +SDL_Surface * +SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle) +{ + SDL_Surface *rz_dst; + int is8bit, angle90; + int i; + SDL_BlendMode blendmode; + Uint32 colorkey = 0; + int colorKeyAvailable = SDL_FALSE; + double sangleinv, cangleinv; + + /* Sanity check */ + if (src == NULL) + return NULL; + + if (SDL_HasColorKey(src)) { + if (SDL_GetColorKey(src, &colorkey) == 0) { + colorKeyAvailable = SDL_TRUE; + } + } + + /* This function requires a 32-bit surface or 8-bit surface with a colorkey */ + is8bit = src->format->BitsPerPixel == 8 && colorKeyAvailable; + if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask))) + return NULL; + + /* Calculate target factors from sin/cos and zoom */ + sangleinv = sangle*65536.0; + cangleinv = cangle*65536.0; + + /* Alloc space to completely contain the rotated surface */ + rz_dst = NULL; + if (is8bit) { + /* Target surface is 8 bit */ + rz_dst = SDL_CreateRGBSurface(0, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0); + if (rz_dst != NULL) { + for (i = 0; i < src->format->palette->ncolors; i++) { + rz_dst->format->palette->colors[i] = src->format->palette->colors[i]; + } + rz_dst->format->palette->ncolors = src->format->palette->ncolors; + } + } else { + /* Target surface is 32 bit with source RGBA ordering */ + rz_dst = SDL_CreateRGBSurface(0, dstwidth, dstheight + GUARD_ROWS, 32, + src->format->Rmask, src->format->Gmask, + src->format->Bmask, src->format->Amask); + } + + /* Check target */ + if (rz_dst == NULL) + return NULL; + + /* Adjust for guard rows */ + rz_dst->h = dstheight; + + SDL_GetSurfaceBlendMode(src, &blendmode); + + if (colorKeyAvailable == SDL_TRUE) { + /* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */ + SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey); + SDL_FillRect(rz_dst, NULL, colorkey); + } else if (blendmode == SDL_BLENDMODE_NONE) { + blendmode = SDL_BLENDMODE_BLEND; + } else if (blendmode == SDL_BLENDMODE_MOD) { + /* Without a colorkey, the target texture has to be white for the MOD blend mode so + * that the pixels outside the rotated area don't affect the destination surface. + */ + colorkey = SDL_MapRGBA(rz_dst->format, 255, 255, 255, 0); + SDL_FillRect(rz_dst, NULL, colorkey); + /* Setting a white colorkey for the destination surface makes the final blit discard + * all pixels outside of the rotated area. This doesn't interfere with anything because + * white pixels are already a no-op and the MOD blend mode does not interact with alpha. + */ + SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey); + } + + SDL_SetSurfaceBlendMode(rz_dst, blendmode); + + /* Lock source surface */ + if (SDL_MUSTLOCK(src)) { + SDL_LockSurface(src); + } + + /* check if the rotation is a multiple of 90 degrees so we can take a fast path and also somewhat reduce + * the off-by-one problem in _transformSurfaceRGBA that expresses itself when the rotation is near + * multiples of 90 degrees. + */ + angle90 = (int)(angle/90); + if (angle90 == angle/90) { + angle90 %= 4; + if (angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ + } else { + angle90 = -1; + } + + if (is8bit) { + /* Call the 8-bit transformation routine to do the rotation */ + if(angle90 >= 0) { + transformSurfaceY90(src, rz_dst, angle90, flipx, flipy); + } else { + transformSurfaceY(src, rz_dst, centerx, centery, (int)sangleinv, (int)cangleinv, + flipx, flipy); + } + } else { + /* Call the 32-bit transformation routine to do the rotation */ + if (angle90 >= 0) { + transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy); + } else { + _transformSurfaceRGBA(src, rz_dst, centerx, centery, (int)sangleinv, (int)cangleinv, + flipx, flipy, smooth); + } + } + + /* Unlock source surface */ + if (SDL_MUSTLOCK(src)) { + SDL_UnlockSurface(src); + } + + /* Return rotated surface */ + return rz_dst; +} diff --git a/source/3rd-party/SDL2/src/render/software/SDL_rotate.h b/source/3rd-party/SDL2/src/render/software/SDL_rotate.h new file mode 100644 index 0000000..54c0927 --- /dev/null +++ b/source/3rd-party/SDL2/src/render/software/SDL_rotate.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_rotate_h_ +#define SDL_rotate_h_ + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); +extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); + +#endif /* SDL_rotate_h_ */ |