bool BaseSurfaceOSystem::startPixelOp() { //SDL_LockTexture(_texture, nullptr, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; }
bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->free(); _surface->copyFrom(surface); _hasAlpha = hasAlpha; BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; }
bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transform) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); if (!_loaded) { finishLoad(); } if (renderer->_forceAlphaColor != 0) { transform._rgbaMod = renderer->_forceAlphaColor; } // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. Common::Rect srcRect; srcRect.left = rect->left; srcRect.top = rect->top; srcRect.setWidth(rect->right - rect->left); srcRect.setHeight(rect->bottom - rect->top); Common::Rect position; if (newRect) { position.top = y; position.left = x; position.setWidth(newRect->width()); position.setHeight(newRect->height()); } else { Rect32 r; r.top = 0; r.left = 0; r.setWidth(rect->width()); r.setHeight(rect->height()); r = TransformTools::newRect(r, transform, 0); position.top = r.top + y + transform._offset.y; position.left = r.left + x + transform._offset.x; position.setWidth(r.width() * transform._numTimesX); position.setHeight(r.height() * transform._numTimesY); } renderer->modTargetRect(&position); // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. // Optimize by not doing alpha-blits if we lack alpha if (_alphaType == TransparentSurface::ALPHA_OPAQUE && !transform._alphaDisable) { transform._alphaDisable = true; } renderer->drawSurface(this, _surface, &srcRect, &position, transform); return STATUS_OK; }
bool BasePlatform::setCursorPos(int x, int y) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); Point32 p; p.x = x; p.y = y; renderer->pointToScreen(&p); g_system->warpMouse(x, y); return true; }
////////////////////////////////////////////////////////////////////////// // Win32 API bindings ////////////////////////////////////////////////////////////////////////// bool BasePlatform::getCursorPos(Point32 *lpPoint) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); lpPoint->x = p.x; lpPoint->y = p.y; renderer->pointFromScreen(lpPoint); return true; }
BaseSurfaceOSystem::~BaseSurfaceOSystem() { if (_surface) { _surface->free(); delete _surface; _surface = nullptr; } delete[] _alphaMask; _alphaMask = nullptr; _gameRef->addMem(-_width * _height * 4); BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); }
bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->free(); _surface->copyFrom(surface); if (hasAlpha) { _alphaType = TransparentSurface::ALPHA_FULL; } else { _alphaType = TransparentSurface::ALPHA_OPAQUE; } BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; }
bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; if (surface.format == _surface->format && surface.pitch == _surface->pitch && surface.h == _surface->h) { const byte *src = (const byte *)surface.getBasePtr(0, 0); byte *dst = (byte *)_surface->getBasePtr(0, 0); memcpy(dst, src, surface.pitch * surface.h); } else { _surface->free(); _surface->copyFrom(surface); } if (hasAlpha) { _alphaType = TransparentSurface::ALPHA_FULL; } else { _alphaType = TransparentSurface::ALPHA_OPAQUE; } BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; }
bool BaseSurfaceOSystem::repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); renderer->repeatLastDraw(offsetX, offsetY, numTimesX, numTimesY); return STATUS_OK; }
bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); if (!_loaded) { finishLoad(); } if (renderer->_forceAlphaColor != 0) { alpha = renderer->_forceAlphaColor; } byte r = RGBCOLGetR(alpha); byte g = RGBCOLGetG(alpha); byte b = RGBCOLGetB(alpha); byte a = RGBCOLGetA(alpha); renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); #if 0 // These are kept for reference if BlendMode is reimplemented at some point. if (alphaDisable) { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); } else { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); } #endif // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. Common::Rect srcRect; srcRect.left = rect->left; srcRect.top = rect->top; srcRect.setWidth(rect->right - rect->left); srcRect.setHeight(rect->bottom - rect->top); Common::Rect position; position.left = x + offsetX; position.top = y + offsetY; // Crop off-by-ones: if (position.left == -1) { position.left = 0; // TODO: Something is wrong } if (position.top == -1) { position.top = 0; // TODO: Something is wrong } position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); renderer->modTargetRect(&position); /* position.left += offsetX; position.top += offsetY;*/ // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. // TODO: Optimize by not doing alpha-blits if we lack or disable alpha bool hasAlpha; if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; } if (alphaDisable) { warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); return STATUS_OK; }