void PageItem_NoteFrame::layout() { if (!invalid || l_notes.isEmpty()) return; if (!m_Doc->flag_layoutNotesFrames) return; if (itemText.length() == 0) return; if ((masterFrame() != NULL) && masterFrame()->invalid) return; //while layouting notes frames undo should be disabled UndoManager::instance()->setUndoEnabled(false); if (m_nstyle->isAutoNotesWidth() && (m_width != m_masterFrame->width())) { oldWidth = m_width = m_masterFrame->width(); updateClip(); } if ((m_Doc->appMode == modeEdit) && isSelected()) updateNotesText(); PageItem_TextFrame::layout(); int oldH = m_height; if (notesStyle()->isAutoNotesHeight()) { if (frameOverflows()) { //increase height while text don`t fit in frame double maxH = m_Doc->currentPage()->height() - m_xPos; while (frameOverflows()) { oldHeight = m_height += 8; updateClip(false); invalid = true; PageItem_TextFrame::layout(); if (m_height >= maxH) break; } } double hackValue = 0.5; oldHeight = m_height = ceil(maxY) + m_textDistanceMargins.bottom() + hackValue; updateConstants(); updateClip(); invalid = true; PageItem_TextFrame::layout(); } if (oldH != height()) { if (masterFrame() != NULL) { foreach(PageItem_NoteFrame* nF, masterFrame()->notesFramesList()) nF->invalid = true; } } invalid = false; m_Doc->regionsChanged()->update(getBoundingRect()); UndoManager::instance()->setUndoEnabled(true); }
void dx11ShaderProgram::drawArrays(ShapeType shape, int first, unsigned int count) { ShaderEngine::Engine->prepareDraw(this); activate(); updateConstants(); if (shape == Point) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); else if (shape == TriangleStrip) g_devcon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); else if (shape == TriangleFan) { D3D11_MAPPED_SUBRESOURCE ms; int ntris = count - 2; ID3D11Buffer *vbo = getGenericVBO(0, 2, 1, 3 * ntris); g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer unsigned short *i = (unsigned short *) ms.pData; for (int t = 0; t < ntris; t++) { *(i++) = first; *(i++) = first + t + 1; *(i++) = first + t + 2; } g_devcon->Unmap(vbo, NULL); // unmap the buffer g_devcon->IASetIndexBuffer(vbo, DXGI_FORMAT_R16_UINT, 0); curIndicesVBO = vbo; g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); g_devcon->DrawIndexed(ntris * 3, 0, 0); return; } else if (shape == Triangles) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); else if (shape == LineLoop) { D3D11_MAPPED_SUBRESOURCE ms; ID3D11Buffer *vbo = getGenericVBO(0, 2, 1, count + 1); g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer unsigned short *i = (unsigned short *) ms.pData; for (int t = 0; t < count; t++) *(i++) = first + t; *(i++) = first; g_devcon->Unmap(vbo, NULL); // unmap the buffer g_devcon->IASetIndexBuffer(vbo, DXGI_FORMAT_R16_UINT, 0); curIndicesVBO = vbo; g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP); g_devcon->DrawIndexed(count + 1, 0, 0); return; } else if (shape == Lines) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); else { glog_e("glDrawArrays unknown pattern\n"); exit(1); } g_devcon->Draw(count, 0); }
void dx11ShaderProgram::drawElements(ShapeType shape, unsigned int count, DataType type, const void *indices, bool modified, ShaderBufferCache **cache,unsigned int first,unsigned int dcount) { ShaderEngine::Engine->prepareDraw(this); activate(); updateConstants(); int indiceSize = 4; DXGI_FORMAT iFmt = DXGI_FORMAT_R32_UINT; if (type == DUSHORT) { indiceSize = 2; iFmt = DXGI_FORMAT_R16_UINT; } D3D11_MAPPED_SUBRESOURCE ms; ID3D11Buffer *vbo = cache ? getCachedVBO(cache, true, indiceSize, 1, count) : getGenericVBO(0,indiceSize,1,count); if (modified || (!cache)) { g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer memcpy(ms.pData, indices, indiceSize * count); // copy the data g_devcon->Unmap(vbo, NULL); // unmap the buffer } UINT stride = indiceSize; UINT offset = 0; if ((curIndicesVBO != vbo) || (!cache)) { g_devcon->IASetIndexBuffer(vbo, iFmt, 0); curIndicesVBO = vbo; } if (shape == Point) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); else if (shape == TriangleStrip) g_devcon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); else if (shape == Triangles) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); else if (shape == LineLoop) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP); else if (shape == Lines) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); else { glog_e("glDrawElements: bad mode\n"); exit(1); } g_devcon->DrawIndexed(dcount?dcount:count, first, 0); }
void dx11ShaderProgram::drawArrays(ShapeType shape, int first, unsigned int count) { ShaderEngine::Engine->prepareDraw(this); activate(); updateConstants(); if (shape == Point) { if (flags&ShaderProgram::Flag_PointShader) { D3D11_MAPPED_SUBRESOURCE ms; int ntris = count; bool changed = ((genVBO[0] == NULL) || (genVBOcapacity[0] < (6 * ntris))); //We should really check if first is still the same here, but current gideros code uses 0 for Point Shaders ID3D11Buffer *vbo = getGenericVBO(0, 2, 1, 6 * ntris); if (changed) { g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer unsigned short *i = (unsigned short *)ms.pData; for (int t = 0; t < ntris; t++) { unsigned short b = (first + t) * 4; *(i++) = b + 0; *(i++) = b + 1; *(i++) = b + 2; *(i++) = b + 0; *(i++) = b + 2; *(i++) = b + 3; } g_devcon->Unmap(vbo, NULL); // unmap the buffer } g_devcon->IASetIndexBuffer(vbo, DXGI_FORMAT_R16_UINT, 0); curIndicesVBO = vbo; g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); g_devcon->DrawIndexed(ntris * 6, 0, 0); return; } else g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); } else if (shape == TriangleStrip) g_devcon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); else if (shape == TriangleFan) { D3D11_MAPPED_SUBRESOURCE ms; int ntris = count - 2; ID3D11Buffer *vbo = getGenericVBO(0, 2, 1, 3 * ntris); g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer unsigned short *i = (unsigned short *) ms.pData; for (int t = 0; t < ntris; t++) { *(i++) = first; *(i++) = first + t + 1; *(i++) = first + t + 2; } g_devcon->Unmap(vbo, NULL); // unmap the buffer g_devcon->IASetIndexBuffer(vbo, DXGI_FORMAT_R16_UINT, 0); curIndicesVBO = vbo; g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); g_devcon->DrawIndexed(ntris * 3, 0, 0); return; } else if (shape == Triangles) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); else if (shape == LineLoop) { D3D11_MAPPED_SUBRESOURCE ms; ID3D11Buffer *vbo = getGenericVBO(0, 2, 1, count + 1); g_devcon->Map(vbo, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer unsigned short *i = (unsigned short *) ms.pData; for (int t = 0; t < count; t++) *(i++) = first + t; *(i++) = first; g_devcon->Unmap(vbo, NULL); // unmap the buffer g_devcon->IASetIndexBuffer(vbo, DXGI_FORMAT_R16_UINT, 0); curIndicesVBO = vbo; g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP); g_devcon->DrawIndexed(count + 1, 0, 0); return; } else if (shape == Lines) g_devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); else { glog_e("glDrawArrays unknown pattern\n"); exit(1); } g_devcon->Draw(count, 0); }