void ESVideo::PresentFrame (GLuint aID, uint32_t aWidth, uint32_t aHeight, const Area& aViewPort, bool aFlip) { //Enter present state EnterPresentState(); //Calculate output area Area presentArea; if(NoAspect) { uint32_t x = PresentArea.X, y = PresentArea.Y, w = PresentArea.Width, h = PresentArea.Height; Utility::CenterAndScale(x, y, w, h, aViewPort.Width, aViewPort.Height); presentArea = Area(x, y, w, h); } else { presentArea = PresentArea; } //Call kiddie present if possible if(SupportsShaders()) { Present(aID, aWidth, aHeight, aViewPort, presentArea, aFlip); /* Reset vertex buffer */ ApplyVertexBuffer(VertexBuffer); } else { float xl = (float)aViewPort.X / (float)aWidth; float xr = (float)aViewPort.Right() / (float)aWidth; float yl = (float)aViewPort.Y / (float)aHeight; float yr = (float)aViewPort.Bottom() / (float)aHeight; if(aFlip) { std::swap(yl, yr); } glBindTexture(GL_TEXTURE_2D, aID); glSplat(); SetVertex(&VertexBuffer[0 * VertexSize], presentArea.X, presentArea.Y, 1.0f, 1.0f, 1.0f, 1.0f, xl, yl); SetVertex(&VertexBuffer[1 * VertexSize], presentArea.Right(), presentArea.Y, 1.0f, 1.0f, 1.0f, 1.0f, xr, yl); SetVertex(&VertexBuffer[2 * VertexSize], presentArea.Right(), presentArea.Bottom(), 1.0f, 1.0f, 1.0f, 1.0f, xr, yr); SetVertex(&VertexBuffer[3 * VertexSize], presentArea.X, presentArea.Bottom(), 1.0f, 1.0f, 1.0f, 1.0f, xl, yr); glDrawArrays(GL_QUADS, 0, 4); glSplat(); } //Exit present state ExitPresentState(); }
void ESVideo::PlaceTexture (Texture* aTexture, const Area& aDestination, const Area& aSource, uint32_t aColor) { float r = (float)((aColor >> 24) & 0xFF) / 256.0f; float g = (float)((aColor >> 16) & 0xFF) / 256.0f; float b = (float)((aColor >> 8) & 0xFF) / 256.0f; float a = (float)((aColor >> 0) & 0xFF) / 256.0f; float xl = ((float)aSource.X + .5f) / (float)aTexture->GetWidth(); float xr = ((float)aSource.Right() - .5f) / (float)aTexture->GetWidth(); float yl = ((float)aSource.Y + .5f) / (float)aTexture->GetHeight(); float yr = ((float)aSource.Bottom() - .5f) / (float)aTexture->GetHeight(); const Area& Clip = ESVideo::GetClip(); aTexture->Apply(); SetVertex(&VertexBuffer[0 * VertexSize], Clip.X + aDestination.X, Clip.Y + aDestination.Y, r, g, b, a, xl, yl); SetVertex(&VertexBuffer[1 * VertexSize], Clip.X + aDestination.Right(), Clip.Y + aDestination.Y, r, g, b, a, xr, yl); SetVertex(&VertexBuffer[2 * VertexSize], Clip.X + aDestination.Right(), Clip.Y + aDestination.Bottom(), r, g, b, a, xr, yr); SetVertex(&VertexBuffer[3 * VertexSize], Clip.X + aDestination.X, Clip.Y + aDestination.Bottom(), r, g, b, a, xl, yr); glDrawArrays(GL_QUADS, 0, 4); }
/** * Perform layout on the area. */ void Area::DoLayout() { if (Content() == NULL) return; // empty areas need no layout // if there is a childArea, then it is the childArea that actually contains the content Area* area = (fChildArea != NULL) ? fChildArea : this; // set content location and size area->Content()->MoveTo(floor(area->Left()->Value() + 0.5), floor(area->Top()->Value() + 0.5)); int32 width = (int32)floor(area->Right()->Value() - area->Left()->Value() + 0.5); int32 height = (int32)floor(area->Bottom()->Value() - area->Top()->Value() + 0.5); area->Content()->ResizeTo(width, height); }
BALMLayoutBuilder& BALMLayoutBuilder::AddToLeft(BView* view, XTab* _left, YTab* top, YTab* bottom) { Area* currentArea = _CurrentArea(); BReference<XTab> left = _left; if (_left == NULL) left = fLayout->AddXTab(); XTab* right = currentArea->Left(); if (!top) top = currentArea->Top(); if (!bottom) bottom = currentArea->Bottom(); return Add(view, left, top, right, bottom); }
BALMLayoutBuilder& BALMLayoutBuilder::AddBelow(BLayoutItem* item, YTab* _bottom, XTab* left, XTab* right) { Area* currentArea = _CurrentArea(); if (!left) left = currentArea->Left(); if (!right) right = currentArea->Right(); YTab* top = currentArea->Bottom(); BReference<YTab> bottom = _bottom; if (_bottom == NULL) bottom = fLayout->AddYTab(); return Add(item, left, top, right, bottom); }
BALMLayoutBuilder& BALMLayoutBuilder::AddToRight(BLayoutItem* item, XTab* _right, YTab* top, YTab* bottom) { Area* currentArea = _CurrentArea(); XTab* left = currentArea->Right(); BReference<XTab> right = _right; if (_right == NULL) right = fLayout->AddXTab(); if (!top) top = currentArea->Top(); if (!bottom) bottom = currentArea->Bottom(); return Add(item, left, top, right, bottom); }