84 #ifdef DEBUG_SDL_SURFACES
86 #define MSDL_RenderCopy(render, texture, src, dst) \
87 FakeSDL_RenderCopy(render, texture, src, dst)
89 static int FakeSDL_RenderCopy(SDL_Renderer *
restrict const renderer,
91 const SDL_Rect *
restrict const srcrect,
92 const SDL_Rect *
restrict const dstrect)
94 int ret = SDL_RenderCopy(renderer, texture, srcrect, dstrect);
97 logger->
log(
"rendering error in texture %p: %s",
98 static_cast<void*
>(texture), SDL_GetError());
105 #define MSDL_RenderCopy(render, texture, src, dst) \
106 SDL_RenderCopy(render, texture, src, dst)
110 #define setRenderDrawColor(mColor) \
111 SDL_SetRenderDrawColor(mRenderer, \
117 #define defRectFromArea(rect, area) \
118 const SDL_Rect rect = \
122 CAST_S32(area.width), \
123 CAST_S32(area.height) \
128 mRendererFlags(SDL_RENDERER_SOFTWARE),
133 mName =
"SDL2 default";
142 const int desiredWidth,
147 if (!mWindow || !image || !image->mTexture)
151 const SDL_Rect &bounds = image->mBounds;
152 const SDL_Rect srcRect =
159 const SDL_Rect dstRect =
167 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
181 if (!mWindow || !image || !image->mTexture)
188 const SDL_Rect &bounds = image->mBounds;
189 const SDL_Rect srcRect =
197 const SDL_Rect dstRect =
205 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
219 if (!mWindow || !image || !image->mTexture)
226 const SDL_Rect &bounds = image->mBounds;
227 const SDL_Rect srcRect =
235 const SDL_Rect dstRect =
243 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
247 const int x,
const int y,
252 if (!mWindow || !image)
254 if (!image->mTexture)
261 const SDL_Rect &bounds = image->mBounds;
262 const
int iw = bounds.w;
263 const
int ih = bounds.h;
264 if (iw == 0 || ih == 0)
267 const
int xOffset =
top.xOffset +
x;
268 const
int yOffset =
top.yOffset +
y;
274 for (
int py = 0; py < h; py += ih)
276 const int dh = (py + ih >= h) ? h - py : ih;
281 for (
int px = 0; px < w; px += iw)
283 const int dw = (px + iw >= w) ? w - px : iw;
288 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
298 const int x,
const int y,
305 const int x,
const int y,
310 if (!mWindow || !image)
312 if (!image->mTexture)
319 const SDL_Rect &bounds = image->mBounds;
320 const
int iw = bounds.w;
321 const
int ih = bounds.h;
322 if (iw == 0 || ih == 0)
325 const
int xOffset =
top.xOffset +
x;
326 const
int yOffset =
top.yOffset +
y;
332 for (
int py = 0; py < h; py += ih)
334 const int dh = (py + ih >= h) ? h - py : ih;
339 for (
int px = 0; px < w; px += iw)
341 const int dw = (px + iw >= w) ? w - px : iw;
346 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
352 const int x,
const int y,
353 const int w,
const int h,
354 const int scaledWidth,
358 if (!mWindow || !image)
360 if (!image->mTexture)
363 if (scaledHeight == 0 || scaledWidth == 0)
367 if (!
top.width || !
top.height)
370 Image *
const tmpImage = image->SDLgetScaledImage(
371 scaledWidth, scaledHeight);
375 const SDL_Rect &bounds = tmpImage->mBounds;
376 const int iw = bounds.w;
377 const int ih = bounds.h;
378 if (iw == 0 || ih == 0)
381 const int xOffset =
top.xOffset +
x;
382 const int yOffset =
top.yOffset +
y;
388 for (
int py = 0; py < h; py += ih)
390 const int dh = (py + ih >= h) ? h - py : ih;
395 for (
int px = 0; px < w; px += iw)
397 const int dw = (px + iw >= w) ? w - px : iw;
402 MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
411 const int x,
const int y,
412 const int w,
const int h)
const restrict2
419 const int x,
const int y,
420 const int w,
const int h)
const restrict2
423 if (!vert || !mWindow || !image || !image->mTexture)
427 if (!
top.width || !
top.height)
430 const SDL_Rect &bounds = image->mBounds;
431 const int iw = bounds.w;
432 const int ih = bounds.h;
433 if (iw == 0 || ih == 0)
436 const int xOffset =
top.xOffset +
x;
437 const int yOffset =
top.yOffset +
y;
438 const int srcX = bounds.x;
439 const int srcY = bounds.y;
440 for (
int py = 0; py < h; py += ih)
442 const int dh = (py + ih >= h) ? h - py : ih;
443 const int dstY = py + yOffset;
445 for (
int px = 0; px < w; px += iw)
447 const int dw = (px + iw >= w) ? w - px : iw;
448 const int dstX = px + xOffset;
451 SDL_Rect &dstRect = r->
dst;
452 SDL_Rect &srcRect = r->
src;
462 vert->sdl.push_back(r);
469 const int x,
const int y,
470 const int w,
const int h)
const restrict2
473 if (vertCol->currentImage != image)
476 vertCol->currentImage = image;
477 vertCol->currentVert = vert;
479 vertCol->draws.push_back(vert);
483 vert = vertCol->currentVert;
509 if (!vert || !vert->
image || !vert->
image->mTexture)
513 if (!
top.width || !
top.height)
517 const SDL_Rect &bounds = image->mBounds;
523 SDL_Rect &dstRect = rect->
dst;
524 SDL_Rect &srcRect = rect->
src;
535 vert->
sdl.push_back(rect);
544 if (vertCol->currentImage != image)
547 vertCol->currentImage = image;
548 vertCol->currentVert = vert;
550 vertCol->draws.push_back(vert);
569 DoubleRects::const_iterator it2 = rects->begin();
570 const DoubleRects::const_iterator it2_end = rects->end();
571 while (it2 != it2_end)
573 MSDL_RenderCopy(mRenderer, img->mTexture,
574 &(*it2)->src, &(*it2)->dst);
588 DoubleRects::const_iterator it = rects->begin();
589 const DoubleRects::const_iterator it_end = rects->end();
592 MSDL_RenderCopy(mRenderer, img->mTexture, &(*it)->src, &(*it)->dst);
600 SDL_RenderPresent(mRenderer);
606 const
int x, const
int y,
607 const
int w, const
int h,
611 Image *
const image = imgRect.grid[4];
614 if (vertCol->currentImage != image)
617 vertCol->currentImage = image;
618 vertCol->currentVert = vert;
620 vertCol->draws.push_back(vert);
624 vert = vertCol->currentVert;
632 const SDL_Rect rect =
640 setRenderDrawColor(
mColor);
641 SDL_RenderFillRects(mRenderer, &rect, 1);
659 defRectFromArea(rect, carea);
660 SDL_RenderSetClipRect(mRenderer, &rect);
671 defRectFromArea(rect, carea);
672 SDL_RenderSetClipRect(mRenderer, &rect);
685 if (!
top.isPointInRect(
x,
y))
688 setRenderDrawColor(
mColor);
689 const SDL_Point point =
695 SDL_RenderDrawPoints(mRenderer, &point, 1);
702 setRenderDrawColor(
mColor);
704 const int x1 = rectangle.x +
top.xOffset;
705 const int y1 = rectangle.y +
top.yOffset;
706 const int x2 = x1 + rectangle.width - 1;
707 const int y2 = y1 + rectangle.height - 1;
717 SDL_RenderDrawLines(mRenderer, points, 5);
724 setRenderDrawColor(
mColor);
726 const int x0 =
top.xOffset;
727 const int y0 =
top.yOffset;
735 SDL_RenderDrawLines(mRenderer, points, 2);
766 SDL_GetWindowSize(
mWindow, &w1, &h1);
771 SDLImageHelper::setRenderer(mRenderer);
776 const int w,
const int h,
783 const int x,
const int y,
784 const int w,
const int h,
static SDL_Surface * createWindow(const int w, const int h, const int bpp, const int flags)
virtual void updateScreen()=0
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void setMainFlags(const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)
virtual void popClipArea()
virtual void drawRescaledPattern(const Image *const image, const int x, const int y, const int w, const int h, const int scaledWidth, const int scaledHeight)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual bool setVideoMode(const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void drawImageCached(const Image *const image, int srcX, int srcY)=0
virtual void calcPattern(ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const =0
virtual void calcTileSDL(ImageVertexes *const vert, int x, int y) const
virtual void drawRectangle(const Rect &rectangle)=0
MStack< ClipRect > mClipStack
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void drawLine(int x1, int y1, int x2, int y2)=0
virtual void calcTileVertexes(ImageVertexes *const vert, const Image *const image, int x, int y) const =0
virtual void drawPattern(const Image *const image, const int x, const int y, const int w, const int h)=0
virtual void drawPoint(int x, int y)=0
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void copyImage(const Image *const image, int dstX, int dstY)=0
virtual void pushClipArea(const Rect &area)
virtual void drawTileVertexes(const ImageVertexes *const vert)=0
virtual void drawPatternCached(const Image *const image, const int x, const int y, const int w, const int h)=0
virtual void completeCache()=0
int getSoftwareFlags() const
virtual void drawRescaledImage(const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)=0
void log(const char *const log_text,...)
const Image *restrict const top
void calcPatternInline(ImageVertexes *restrict const vert, const Image *restrict const image, const int x, const int y, const int w, const int h) const restrict2 A_INLINE
void drawPatternInline(const Image *restrict const image, const int x, const int y, const int w, const int h) restrict2 A_INLINE
void void drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 A_INLINE
void calcTileVertexesInline(ImageVertexes *restrict const vert, const Image *restrict const image, int x, int y) const restrict2 A_INLINE A_NONNULL(2
void calcImageRect(ImageVertexes *restrict const vert, int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 A_INLINE
GraphicsManager graphicsManager
std::vector< ImageVertexes * > ImageVertexesVector
std::vector< DoubleRect * > DoubleRects
ImageVertexesVector::const_iterator ImageCollectionCIter
#define FUNC_BLOCK(name, id)
#define BLOCK_START(name)
void calcTileSDL(ImageVertexes *restrict const vert, int x, int y) const restrict2 override final