1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "graphics/surface.h"
#include "graphics/managed_surface.h"
#include "graphics/cursorman.h"
#include "mtropolis/render.h"
#include "mtropolis/runtime.h"
namespace MTropolis {
template<class TNumber, int TResolution>
struct OrderedDitherGenerator {
static void generateOrderedDither(TNumber (&pattern)[TResolution][TResolution]);
};
template<class TNumber>
struct OrderedDitherGenerator<TNumber, 1> {
static void generateOrderedDither(TNumber (&pattern)[1][1]);
};
struct RenderItem {
VisualElement *element;
size_t sceneStackDepth;
};
template<class TNumber, int TResolution>
void OrderedDitherGenerator<TNumber, TResolution>::generateOrderedDither(TNumber (&pattern)[TResolution][TResolution]) {
const int kHalfResolution = TResolution / 2;
TNumber halfRes[kHalfResolution][kHalfResolution];
OrderedDitherGenerator<TNumber, kHalfResolution>::generateOrderedDither(halfRes);
const int kHalfResNumSteps = kHalfResolution * kHalfResolution;
for (int y = 0; y < kHalfResolution; y++) {
for (int x = 0; x < kHalfResolution; x++) {
pattern[y * 2][x * 2] = halfRes[y][x];
pattern[y * 2 + 1][x * 2 + 1] = halfRes[y][x] + kHalfResNumSteps * 1;
pattern[y * 2][x * 2 + 1] = halfRes[y][x] + kHalfResNumSteps * 2;
pattern[y * 2 + 1][x * 2] = halfRes[y][x] + kHalfResNumSteps * 3;
}
}
}
template<class TNumber>
void OrderedDitherGenerator<TNumber, 1>::generateOrderedDither(TNumber (&pattern)[1][1]) {
pattern[0][0] = 0;
}
inline int quantize8To5Byte(int value, byte orderedDither16x16) {
return (value * 249 + (orderedDither16x16 << 3)) >> 11;
}
inline int quantize8To5UShort(int value, uint16 orderedDither16x16) {
return (value * 249 + orderedDither16x16) >> 11;
}
inline int expand5To8(int value) {
return (value * 33) >> 2;
}
TextStyleFlags::TextStyleFlags() : bold(false), italic(false), underline(false), outline(false), shadow(false), condensed(false), expanded(false) {
}
bool TextStyleFlags::load(uint8 dataStyleFlags) {
bold = ((dataStyleFlags & 0x01) != 0);
italic = ((dataStyleFlags & 0x02) != 0);
underline = ((dataStyleFlags & 0x03) != 0);
outline = ((dataStyleFlags & 0x04) != 0);
shadow = ((dataStyleFlags & 0x10) != 0);
condensed = ((dataStyleFlags & 0x20) != 0);
expanded = ((dataStyleFlags & 0x40) != 0);
return true;
}
MacFontFormatting::MacFontFormatting() : fontID(0), fontFlags(0), size(12) {
}
MacFontFormatting::MacFontFormatting(uint16 mff_fontID, uint8 mff_fontFlags, uint16 mff_size) : fontID(mff_fontID), fontFlags(mff_fontFlags), size(mff_size) {
}
MacFormattingSpan::MacFormattingSpan() : spanStart(0) {
}
WindowParameters::WindowParameters(Runtime *wp_runtime, int32 wp_x, int32 wp_y, int16 wp_width, int16 wp_height, const Graphics::PixelFormat &wp_format)
: runtime(wp_runtime), x(wp_x), y(wp_y), width(wp_width), height(wp_height), format(wp_format) {
}
Window::Window(const WindowParameters &windowParams)
: _runtime(windowParams.runtime), _x(windowParams.x), _y(windowParams.y), _strata(0), _isMouseTransparent(false), _isMouseVisible(true) {
_surface.reset(new Graphics::ManagedSurface(windowParams.width, windowParams.height, windowParams.format));
}
Window::~Window() {
}
int32 Window::getX() const {
return _x;
}
int32 Window::getY() const {
return _y;
}
int32 Window::getWidth() const {
return _surface->w;
}
int32 Window::getHeight() const {
return _surface->h;
}
void Window::setPosition(int32 x, int32 y) {
_x = x;
_y = y;
}
void Window::resizeWindow(int32 width, int32 height) {
Graphics::PixelFormat pixFmt = _surface->format;
_surface.reset();
_surface.reset(new Graphics::ManagedSurface(width, height, pixFmt));
}
const Common::SharedPtr<Graphics::ManagedSurface> &Window::getSurface() const {
return _surface;
}
const Graphics::PixelFormat& Window::getPixelFormat() const {
return _surface->format;
}
const Common::SharedPtr<CursorGraphic> &Window::getCursorGraphic() const {
return _cursor;
}
void Window::setCursorGraphic(const Common::SharedPtr<CursorGraphic>& cursor) {
_cursor = cursor;
}
bool Window::getMouseVisible() const {
return _isMouseVisible;
}
void Window::setMouseVisible(bool visible) {
_isMouseVisible = visible;
}
void Window::setStrata(int strata) {
_strata = strata;
}
int Window::getStrata() const {
return _strata;
}
// Mouse transparency = ignores mouse events
void Window::setMouseTransparent(bool isTransparent) {
_isMouseTransparent = isTransparent;
}
bool Window::isMouseTransparent() const {
return _isMouseTransparent;
}
void Window::close() {
Runtime *runtime = _runtime;
_runtime = nullptr;
if (runtime)
runtime->removeWindow(this);
}
void Window::detachFromRuntime() {
_runtime = nullptr;
}
void Window::onMouseDown(int32 x, int32 y, int mouseButton) {
}
void Window::onMouseMove(int32 x, int32 y) {
}
void Window::onMouseUp(int32 x, int32 y, int mouseButton) {
}
void Window::onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt) {
}
void Window::onAction(Actions::Action action) {
}
namespace Render {
uint32 resolveRGB(uint8 r, uint8 g, uint8 b, const Graphics::PixelFormat &fmt) {
uint32 rPlaced = (static_cast<uint32>(r) >> (8 - fmt.rBits())) << fmt.rShift;
uint32 gPlaced = (static_cast<uint32>(g) >> (8 - fmt.gBits())) << fmt.gShift;
uint32 bPlaced = (static_cast<uint32>(b) >> (8 - fmt.bBits())) << fmt.bShift;
uint32 aPlaced = (static_cast<uint32>(255) >> (8 - fmt.aBits())) << fmt.aShift;
return rPlaced | gPlaced | bPlaced | aPlaced;
}
static void recursiveCollectDrawElementsAndUpdateOrigins(const Common::Point &parentOrigin, Structural *structural, size_t sceneStackDepth, Common::Array<RenderItem> &normalBucket, Common::Array<RenderItem> &directBucket) {
Common::Point elementOrigin = parentOrigin;
if (structural->isElement()) {
Element *element = static_cast<Element *>(structural);
if (element->isVisual()) {
VisualElement *visualElement = static_cast<VisualElement *>(element);
const Common::Rect &elementRect = visualElement->getRelativeRect();
elementOrigin.x += elementRect.left;
elementOrigin.y += elementRect.top;
visualElement->setCachedAbsoluteOrigin(Common::Point(elementOrigin.x, elementOrigin.y));
RenderItem item;
item.element = visualElement;
item.sceneStackDepth = sceneStackDepth;
if (visualElement->isVisible()) {
if (visualElement->isDirectToScreen())
directBucket.push_back(item);
else
normalBucket.push_back(item);
}
}
}
for (Common::Array<Common::SharedPtr<Structural> >::const_iterator it = structural->getChildren().begin(), itEnd = structural->getChildren().end(); it != itEnd; ++it) {
recursiveCollectDrawElementsAndUpdateOrigins(elementOrigin, it->get(), sceneStackDepth, normalBucket, directBucket);
}
}
static bool renderItemLess(const RenderItem &a, const RenderItem &b) {
const uint16 aLayer = a.element->getLayer();
const uint16 bLayer = b.element->getLayer();
if (aLayer != bLayer)
return aLayer < bLayer;
return a.sceneStackDepth < b.sceneStackDepth;
}
static void renderNormalElement(const RenderItem &item, Window *mainWindow) {
item.element->render(mainWindow);
item.element->finalizeRender();
}
static void renderDirectElement(const RenderItem &item, Window *mainWindow) {
renderNormalElement(item, mainWindow); // Meh
}
void renderProject(Runtime *runtime, Window *mainWindow, bool *outSkipped) {
bool sceneChanged = runtime->isSceneGraphDirty();
Common::Array<Structural *> scenes;
runtime->getScenesInRenderOrder(scenes);
Common::Array<RenderItem> normalBucket;
Common::Array<RenderItem> directBucket;
size_t sceneStackDepth = 0;
for (Common::Array<Structural *>::const_iterator it = scenes.begin(), itEnd = scenes.end(); it != itEnd; ++it) {
recursiveCollectDrawElementsAndUpdateOrigins(Common::Point(0, 0), *it, sceneStackDepth, normalBucket, directBucket);
sceneStackDepth++;
}
Common::sort(normalBucket.begin(), normalBucket.end(), renderItemLess);
Common::sort(directBucket.begin(), directBucket.end(), renderItemLess);
if (!sceneChanged) {
for (Common::Array<RenderItem>::const_iterator it = normalBucket.begin(), itEnd = normalBucket.end(); it != itEnd; ++it) {
if (it->element->needsRender()) {
sceneChanged = true;
break;
}
}
}
if (!sceneChanged) {
for (Common::Array<RenderItem>::const_iterator it = directBucket.begin(), itEnd = directBucket.end(); it != itEnd; ++it) {
if (it->element->needsRender()) {
sceneChanged = true;
break;
}
}
}
if (sceneChanged) {
if (outSkipped)
*outSkipped = false;
for (Common::Array<RenderItem>::const_iterator it = normalBucket.begin(), itEnd = normalBucket.end(); it != itEnd; ++it)
renderNormalElement(*it, mainWindow);
for (Common::Array<RenderItem>::const_iterator it = directBucket.begin(), itEnd = directBucket.end(); it != itEnd; ++it)
renderDirectElement(*it, mainWindow);
for (const IPostEffect *postEffect : runtime->getPostEffects())
postEffect->renderPostEffect(*mainWindow->getSurface());
} else {
if (outSkipped)
*outSkipped = true;
}
runtime->clearSceneGraphDirty();
}
class DissolveOrderedDitherPatternGenerator {
public:
DissolveOrderedDitherPatternGenerator();
uint8 getNext();
void nextLine();
private:
uint8 _ditherPattern[16][16];
uint16 _x;
uint16 _y;
};
DissolveOrderedDitherPatternGenerator::DissolveOrderedDitherPatternGenerator() : _x(0), _y(0) {
OrderedDitherGenerator<uint8, 16>::generateOrderedDither(_ditherPattern);
}
inline uint8 DissolveOrderedDitherPatternGenerator::getNext() {
uint8 result = _ditherPattern[_y][_x];
uint16 newX = _x + 1;
if (newX == 16)
newX = 0;
_x = newX;
return result;
}
inline void DissolveOrderedDitherPatternGenerator::nextLine() {
_x = 0;
uint16 newY = _y + 1;
if (newY == 16)
newY = 0;
_y = newY;
}
class DissolveOrderedDitherRandomGenerator {
public:
DissolveOrderedDitherRandomGenerator();
uint8 getNext();
void nextLine();
private:
uint32 _lcgState;
};
DissolveOrderedDitherRandomGenerator::DissolveOrderedDitherRandomGenerator() : _lcgState(13) {
}
inline uint8 DissolveOrderedDitherRandomGenerator::getNext() {
_lcgState = ((_lcgState * 1103515245u) + 12345u) & 0x7fffffffu;
return (_lcgState >> 16) & 0xff;
}
inline void DissolveOrderedDitherRandomGenerator::nextLine() {
}
template<class TPixel, class TGenerator>
static void runDissolveTransitionWithType(Graphics::ManagedSurface &surface, const Graphics::ManagedSurface &oldFrame, const Graphics::ManagedSurface &newFrame, uint8 breakpoint) {
TGenerator generator;
assert(surface.format.bytesPerPixel == oldFrame.format.bytesPerPixel);
assert(surface.format.bytesPerPixel == newFrame.format.bytesPerPixel);
uint16 w = surface.w;
uint16 h = surface.h;
for (uint y = 0; y < h; y++) {
TPixel *destRow = static_cast<TPixel *>(surface.getBasePtr(0, y));
const TPixel *oldRow = static_cast<const TPixel *>(oldFrame.getBasePtr(0, y));
const TPixel *newRow = static_cast<const TPixel *>(newFrame.getBasePtr(0, y));
for (uint x = 0; x < w; x++) {
if (generator.getNext() <= breakpoint)
destRow[x] = newRow[x];
else
destRow[x] = oldRow[x];
}
generator.nextLine();
}
}
template<class TGenerator>
static void runDissolveTransition(Graphics::ManagedSurface &surface, const Graphics::ManagedSurface &oldFrame, const Graphics::ManagedSurface &newFrame, uint8 breakpoint) {
switch (surface.format.bytesPerPixel) {
case 1:
runDissolveTransitionWithType<uint8, TGenerator>(surface, oldFrame, newFrame, breakpoint);
break;
case 2:
runDissolveTransitionWithType<uint16, TGenerator>(surface, oldFrame, newFrame, breakpoint);
break;
case 4:
runDissolveTransitionWithType<uint32, TGenerator>(surface, oldFrame, newFrame, breakpoint);
break;
default:
assert(false);
break;
}
}
static void safeCopyRectToSurface(Graphics::ManagedSurface &surface, const Graphics::ManagedSurface &srcSurface, int destX, int destY, const Common::Rect subRect) {
if (subRect.width() == 0 || subRect.height() == 0)
return;
surface.copyRectToSurface(srcSurface, destX, destY, subRect);
}
void renderSceneTransition(Runtime *runtime, Window *mainWindow, const SceneTransitionEffect &effect, uint32 startTime, uint32 endTime, uint32 currentTime, const Graphics::ManagedSurface &oldFrame, const Graphics::ManagedSurface &newFrame) {
Graphics::ManagedSurface &surface = *mainWindow->getSurface();
assert(endTime > startTime);
uint32 duration = endTime - startTime;
uint16 w = surface.w;
uint16 h = surface.h;
if (effect._transitionType == SceneTransitionTypes::kSlide || effect._transitionType == SceneTransitionTypes::kWipe)
safeCopyRectToSurface(surface, oldFrame, 0, 0, Common::Rect(0, 0, w, h));
switch (effect._transitionType) {
case SceneTransitionTypes::kPatternDissolve:
runDissolveTransition<DissolveOrderedDitherPatternGenerator>(surface, oldFrame, newFrame, (currentTime - startTime) * 255 / duration);
break;
case SceneTransitionTypes::kRandomDissolve:
runDissolveTransition<DissolveOrderedDitherRandomGenerator>(surface, oldFrame, newFrame, (currentTime - startTime) * 255 / duration);
break;
case SceneTransitionTypes::kFade:
// Fade transitions fade to black and then fade from black in the new scene
warning("Fade transitions are not implemented");
break;
case SceneTransitionTypes::kSlide:
case SceneTransitionTypes::kPush: {
uint32 directionalOffset = 0;
switch (effect._transitionDirection) {
case SceneTransitionDirections::kUp:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(h) / duration;
if (effect._transitionType == SceneTransitionTypes::kPush)
safeCopyRectToSurface(surface, oldFrame, 0, 0, Common::Rect(0, directionalOffset, w, h));
safeCopyRectToSurface(surface, newFrame, 0, h - directionalOffset, Common::Rect(0, 0, w, directionalOffset));
break;
case SceneTransitionDirections::kDown:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(h) / duration;
if (effect._transitionType == SceneTransitionTypes::kPush)
safeCopyRectToSurface(surface, oldFrame, 0, directionalOffset, Common::Rect(0, 0, w, h - directionalOffset));
safeCopyRectToSurface(surface, newFrame, 0, 0, Common::Rect(0, h - directionalOffset, w, h));
break;
case SceneTransitionDirections::kLeft:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(w) / duration;
if (effect._transitionType == SceneTransitionTypes::kPush)
safeCopyRectToSurface(surface, oldFrame, 0, 0, Common::Rect(directionalOffset, 0, w, h));
safeCopyRectToSurface(surface, newFrame, w - directionalOffset, 0, Common::Rect(0, 0, directionalOffset, h));
break;
case SceneTransitionDirections::kRight:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(w) / duration;
if (effect._transitionType == SceneTransitionTypes::kPush)
safeCopyRectToSurface(surface, oldFrame, directionalOffset, 0, Common::Rect(0, 0, w - directionalOffset, h));
safeCopyRectToSurface(surface, newFrame, 0, 0, Common::Rect(w - directionalOffset, 0, w, h));
break;
default:
assert(false);
break;
}
} break;
case SceneTransitionTypes::kZoom:
warning("Zoom transitions are not implemented");
break;
case SceneTransitionTypes::kWipe:{
uint32 directionalOffset = 0;
switch (effect._transitionDirection) {
case SceneTransitionDirections::kUp:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(h) / duration;
safeCopyRectToSurface(surface, newFrame, 0, h - directionalOffset, Common::Rect(0, h - directionalOffset, w, h));
break;
case SceneTransitionDirections::kDown:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(h) / duration;
safeCopyRectToSurface(surface, newFrame, 0, 0, Common::Rect(0, 0, w, directionalOffset));
break;
case SceneTransitionDirections::kLeft:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(w) / duration;
safeCopyRectToSurface(surface, newFrame, w - directionalOffset, 0, Common::Rect(w - directionalOffset, 0, w, h));
break;
case SceneTransitionDirections::kRight:
directionalOffset = static_cast<uint32>(currentTime - startTime) * static_cast<uint32>(w) / duration;
safeCopyRectToSurface(surface, newFrame, 0, 0, Common::Rect(0, 0, directionalOffset, h));
break;
default:
assert(false);
break;
}
} break;
default:
assert(false);
break;
}
}
void convert32To16(Graphics::ManagedSurface &destSurface, const Graphics::ManagedSurface &srcSurface) {
const Graphics::PixelFormat srcFmt = srcSurface.format;
const Graphics::PixelFormat destFmt = destSurface.format;
assert(srcFmt.bytesPerPixel == 4);
assert(destFmt.bytesPerPixel == 2);
assert(destSurface.w == srcSurface.w);
assert(srcSurface.h == destSurface.h);
uint16 ditherPattern[16][16];
OrderedDitherGenerator<uint16, 16>::generateOrderedDither(ditherPattern);
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++)
ditherPattern[y][x] <<= 3;
}
size_t w = srcSurface.w;
size_t h = srcSurface.h;
for (size_t y = 0; y < h; y++) {
const uint16 *ditherRow = ditherPattern[y % 16];
const uint32 *srcRow = static_cast<const uint32*>(srcSurface.getBasePtr(0, y));
uint16 *destRow = static_cast<uint16 *>(destSurface.getBasePtr(0, y));
for (size_t x = 0; x < w; x++) {
uint16 ditherOffset = ditherRow[x % 16];
uint32 packed32 = srcRow[x];
uint8 r = (packed32 >> srcFmt.rShift) & 0xff;
uint8 g = (packed32 >> srcFmt.gShift) & 0xff;
uint8 b = (packed32 >> srcFmt.bShift) & 0xff;
r = quantize8To5UShort(r, ditherOffset);
g = quantize8To5UShort(g, ditherOffset);
b = quantize8To5UShort(b, ditherOffset);
destRow[x] = (r << destFmt.rShift) | (g << destFmt.gShift) | (b << destFmt.bShift);
}
}
}
void convert16To32(Graphics::ManagedSurface &destSurface, const Graphics::ManagedSurface &srcSurface) {
const Graphics::PixelFormat srcFmt = srcSurface.format;
const Graphics::PixelFormat destFmt = destSurface.format;
assert(srcFmt.bytesPerPixel == 2);
assert(destFmt.bytesPerPixel == 4);
assert(destSurface.w == srcSurface.w);
assert(srcSurface.h == destSurface.h);
size_t w = srcSurface.w;
size_t h = srcSurface.h;
for (size_t y = 0; y < h; y++) {
const uint16 *srcRow = static_cast<const uint16 *>(srcSurface.getBasePtr(0, y));
uint32 *destRow = static_cast<uint32 *>(destSurface.getBasePtr(0, y));
for (size_t x = 0; x < w; x++) {
uint32 packed16 = srcRow[x];
uint8 r = (packed16 >> srcFmt.rShift) & 0x1f;
uint8 g = (packed16 >> srcFmt.gShift) & 0x1f;
uint8 b = (packed16 >> srcFmt.bShift) & 0x1f;
r = expand5To8(r);
g = expand5To8(g);
b = expand5To8(b);
destRow[x] = (r << destFmt.rShift) | (g << destFmt.gShift) | (b << destFmt.bShift) | (0xffu << destFmt.aShift);
}
}
}
} // End of namespace Render
} // End of namespace MTropolis
|