gl::Error FramebufferD3D::readPixels(const gl::Context *context, const gl::Rectangle &origArea, GLenum format, GLenum type, void *pixels) { // Clip read area to framebuffer. const gl::Extents fbSize = getState().getReadAttachment()->getSize(); const gl::Rectangle fbRect(0, 0, fbSize.width, fbSize.height); gl::Rectangle area; if (!ClipRectangle(origArea, fbRect, &area)) { // nothing to read return gl::NoError(); } const gl::PixelPackState &packState = context->getGLState().getPackState(); const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(format, type); GLuint outputPitch = 0; ANGLE_TRY_RESULT(sizedFormatInfo.computeRowPitch(type, origArea.width, packState.alignment, packState.rowLength), outputPitch); GLuint outputSkipBytes = 0; ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(outputPitch, 0, packState, false), outputSkipBytes); outputSkipBytes += (area.x - origArea.x) * sizedFormatInfo.pixelBytes + (area.y - origArea.y) * outputPitch; return readPixelsImpl(context, area, format, type, outputPitch, packState, reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes); }
void TiledMap_draw(Bitmap *surface, TiledMap *map, int xo, int yo) { if (map->tileSize != 0) { // Indices of top-left most tile to draw int tx = divRD(xo, SCREEN_X); int ty = divRD(yo, SCREEN_Y); // Number of tiles per screen int txs = divRD(SCREEN_X, map->tileSize + 1); int tys = divRD(SCREEN_Y, map->tileSize + 1); ClipRectangle(&tx, &ty, &txs, &tys, map->sizeX, map->sizeY); for (int y = ty; y < tys + ty; y++) for (int x = tx; x < txs + tx; x++) DrawRLEBitmap(surface, map->tileInfo[ TiledMap_getTile(map, x, y) ].bitmap, xo + (x * map->tileSize), yo + (y * map->tileSize)); } // Draw objects list_el *i = map->objects.head; while (i) { MObj_draw(surface, (MapObject*) i->val, xo, yo); i = i->next; } }
angle::Result FramebufferD3D::readPixels(const gl::Context *context, const gl::Rectangle &area, GLenum format, GLenum type, void *pixels) { // Clip read area to framebuffer. const gl::Extents fbSize = getState().getReadAttachment()->getSize(); const gl::Rectangle fbRect(0, 0, fbSize.width, fbSize.height); gl::Rectangle clippedArea; if (!ClipRectangle(area, fbRect, &clippedArea)) { // nothing to read return angle::Result::Continue; } const gl::PixelPackState &packState = context->getState().getPackState(); const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(format, type); ContextD3D *contextD3D = GetImplAs<ContextD3D>(context); GLuint outputPitch = 0; ANGLE_CHECK_GL_MATH(contextD3D, sizedFormatInfo.computeRowPitch(type, area.width, packState.alignment, packState.rowLength, &outputPitch)); GLuint outputSkipBytes = 0; ANGLE_CHECK_GL_MATH(contextD3D, sizedFormatInfo.computeSkipBytes( type, outputPitch, 0, packState, false, &outputSkipBytes)); outputSkipBytes += (clippedArea.x - area.x) * sizedFormatInfo.pixelBytes + (clippedArea.y - area.y) * outputPitch; return readPixelsImpl(context, clippedArea, format, type, outputPitch, packState, static_cast<uint8_t *>(pixels) + outputSkipBytes); }