Kaydet (Commit) c091a9f0 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Don't wrap glyphy source files in namespace GLyphyDemo

...as the source files themselves include standard headers, which must not be
included from within a namespace (which confuses clang-cl).  According to Tor,
the original intent was to try not to pollute the global namespace, but that
seems to cause no problems in practice (esp. as nothing from these files gets
exported).

Change-Id: I204c1db932996a09d16e84dd5c6033caa5362caa
üst 9a2764bd
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
#include <prewin.h> #include <prewin.h>
#include <postwin.h> #include <postwin.h>
namespace GLyphyDemo {
#include "demo/demo-atlas.cc" #include "demo/demo-atlas.cc"
#include "demo/demo-buffer.cc" #include "demo/demo-buffer.cc"
#include "demo/demo-font.cc" #include "demo/demo-font.cc"
#include "demo/demo-shader.cc" #include "demo/demo-shader.cc"
#include "demo/matrix4x4.c" #include "demo/matrix4x4.c"
}
...@@ -10,12 +10,10 @@ ...@@ -10,12 +10,10 @@
#ifndef INCLUDED_VCL_INC_GLYPHY_DEMO_HXX #ifndef INCLUDED_VCL_INC_GLYPHY_DEMO_HXX
#define INCLUDED_VCL_INC_GLYPHY_DEMO_HXX #define INCLUDED_VCL_INC_GLYPHY_DEMO_HXX
namespace GLyphyDemo {
#include "demo-atlas.h" #include "demo-atlas.h"
#include "demo-buffer.h" #include "demo-buffer.h"
#include "demo-font.h" #include "demo-font.h"
#include "demo-shader.h" #include "demo-shader.h"
#include "matrix4x4.h" #include "matrix4x4.h"
}
#endif // INCLUDED_VCL_INC_GLYPHY_DEMO_HXX #endif // INCLUDED_VCL_INC_GLYPHY_DEMO_HXX
...@@ -109,8 +109,8 @@ public: ...@@ -109,8 +109,8 @@ public:
int GetMinKashidaGlyph() const { return mnMinKashidaGlyph; } int GetMinKashidaGlyph() const { return mnMinKashidaGlyph; }
static GLuint mnGLyphyProgram; static GLuint mnGLyphyProgram;
GLyphyDemo::demo_atlas_t* mpGLyphyAtlas; demo_atlas_t* mpGLyphyAtlas;
GLyphyDemo::demo_font_t* mpGLyphyFont; demo_font_t* mpGLyphyFont;
bool GlyphIsCached(int nGlyphIndex) const; bool GlyphIsCached(int nGlyphIndex) const;
bool AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayout, SalGraphics& rGraphics); bool AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayout, SalGraphics& rGraphics);
...@@ -501,10 +501,10 @@ void ImplWinFontEntry::setupGLyphy(HDC hDC) ...@@ -501,10 +501,10 @@ void ImplWinFontEntry::setupGLyphy(HDC hDC)
} }
if (mnGLyphyProgram == 0) if (mnGLyphyProgram == 0)
mnGLyphyProgram = GLyphyDemo::demo_shader_create_program(); mnGLyphyProgram = demo_shader_create_program();
mpGLyphyAtlas = GLyphyDemo::demo_atlas_create(2048, 1024, 64, 8); mpGLyphyAtlas = demo_atlas_create(2048, 1024, 64, 8);
mpGLyphyFont = GLyphyDemo::demo_font_create(hNewDC, mpGLyphyAtlas); mpGLyphyFont = demo_font_create(hNewDC, mpGLyphyAtlas);
} }
WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWFE, bool bUseOpenGL) WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWFE, bool bUseOpenGL)
...@@ -1827,9 +1827,9 @@ bool UniscribeLayout::CacheGlyphs(SalGraphics& rGraphics) const ...@@ -1827,9 +1827,9 @@ bool UniscribeLayout::CacheGlyphs(SalGraphics& rGraphics) const
if (mpOutGlyphs[i] == DROPPED_OUTGLYPH) if (mpOutGlyphs[i] == DROPPED_OUTGLYPH)
continue; continue;
GLyphyDemo::glyph_info_t aGI; glyph_info_t aGI;
VCL_GL_INFO("Calling demo_font_lookup_glyph"); VCL_GL_INFO("Calling demo_font_lookup_glyph");
GLyphyDemo::demo_font_lookup_glyph( mrWinFontEntry.mpGLyphyFont, mpOutGlyphs[i], &aGI ); demo_font_lookup_glyph( mrWinFontEntry.mpGLyphyFont, mpOutGlyphs[i], &aGI );
} }
} }
else else
...@@ -1863,7 +1863,7 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const ...@@ -1863,7 +1863,7 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
rGraphics.GetOpenGLContext()->UseNoProgram(); rGraphics.GetOpenGLContext()->UseNoProgram();
glUseProgram( mrWinFontEntry.mnGLyphyProgram ); glUseProgram( mrWinFontEntry.mnGLyphyProgram );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
GLyphyDemo::demo_atlas_set_uniforms( mrWinFontEntry.mpGLyphyAtlas ); demo_atlas_set_uniforms( mrWinFontEntry.mpGLyphyAtlas );
GLint nLoc; GLint nLoc;
...@@ -1942,7 +1942,7 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const ...@@ -1942,7 +1942,7 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
// font_size = 1; // ??? // font_size = 1; // ???
std::vector<GLyphyDemo::glyph_vertex_t> vertices; std::vector<glyph_vertex_t> vertices;
for (int i = nMinGlyphPos; i < nEndGlyphPos; i++) for (int i = nMinGlyphPos; i < nEndGlyphPos; i++)
{ {
// Ignore dropped glyphs. // Ignore dropped glyphs.
...@@ -1950,18 +1950,18 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const ...@@ -1950,18 +1950,18 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
continue; continue;
// Total crack // Total crack
GLyphyDemo::glyphy_point_t pt; glyphy_point_t pt;
pt.x = nAdvance + aPos.X() + mpGlyphOffsets[i].du; pt.x = nAdvance + aPos.X() + mpGlyphOffsets[i].du;
pt.y = aPos.Y() + mpGlyphOffsets[i].dv; pt.y = aPos.Y() + mpGlyphOffsets[i].dv;
GLyphyDemo::glyph_info_t gi; glyph_info_t gi;
GLyphyDemo::demo_font_lookup_glyph( mrWinFontEntry.mpGLyphyFont, mpOutGlyphs[i], &gi ); demo_font_lookup_glyph( mrWinFontEntry.mpGLyphyFont, mpOutGlyphs[i], &gi );
GLyphyDemo::demo_shader_add_glyph_vertices( pt, font_size, &gi, &vertices, NULL ); demo_shader_add_glyph_vertices( pt, font_size, &gi, &vertices, NULL );
nAdvance += pGlyphWidths[i]; nAdvance += pGlyphWidths[i];
} }
GLfloat mat[16]; GLfloat mat[16];
GLyphyDemo::m4LoadIdentity( mat ); m4LoadIdentity( mat );
GLint viewport[4]; GLint viewport[4];
glGetIntegerv( GL_VIEWPORT, viewport ); glGetIntegerv( GL_VIEWPORT, viewport );
...@@ -1982,27 +1982,27 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const ...@@ -1982,27 +1982,27 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
double near = d / 4; double near = d / 4;
double far = near + d; double far = near + d;
double factor = near / (2 * near + d); double factor = near / (2 * near + d);
GLyphyDemo::m4Frustum( mat, -width * factor, width * factor, -height * factor, height * factor, near, far ); m4Frustum( mat, -width * factor, width * factor, -height * factor, height * factor, near, far );
GLyphyDemo::m4Translate( mat, 0, 0, -(near + d * 0.5) ); m4Translate( mat, 0, 0, -(near + d * 0.5) );
} }
// No rotation here // No rotation here
// Fix 'up' // Fix 'up'
GLyphyDemo::m4Scale( mat, 1, -1, 1 ); m4Scale( mat, 1, -1, 1 );
// Foo // Foo
// GLyphyDemo::m4Scale( mat, 0.5, 0.5, 1 ); // m4Scale( mat, 0.5, 0.5, 1 );
// The "Center buffer" part in demo_view_display() // The "Center buffer" part in demo_view_display()
GLyphyDemo::m4Translate( mat, width/2, height/2, 0 ); m4Translate( mat, width/2, height/2, 0 );
#else #else
// Crack that just happens to show something (even if not completely in correct location) in // Crack that just happens to show something (even if not completely in correct location) in
// some cases, but not all. I don't understand why. // some cases, but not all. I don't understand why.
double scale = std::max( 2/width, 2/height ); double scale = std::max( 2/width, 2/height );
GLyphyDemo::m4Scale( mat, scale, -scale, 1); m4Scale( mat, scale, -scale, 1);
GLyphyDemo::m4Translate( mat, -width/2, -height/2, 0 ); m4Translate( mat, -width/2, -height/2, 0 );
#endif #endif
GLuint u_matViewProjection_loc = glGetUniformLocation( mrWinFontEntry.mnGLyphyProgram, "u_matViewProjection" ); GLuint u_matViewProjection_loc = glGetUniformLocation( mrWinFontEntry.mnGLyphyProgram, "u_matViewProjection" );
...@@ -2017,11 +2017,11 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const ...@@ -2017,11 +2017,11 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
glBindBuffer( GL_ARRAY_BUFFER, buf_name ); glBindBuffer( GL_ARRAY_BUFFER, buf_name );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glBufferData( GL_ARRAY_BUFFER, sizeof(GLyphyDemo::glyph_vertex_t) * vertices.size(), (const char *) &vertices[0], GL_STATIC_DRAW ); glBufferData( GL_ARRAY_BUFFER, sizeof(glyph_vertex_t) * vertices.size(), (const char *) &vertices[0], GL_STATIC_DRAW );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glEnableVertexAttribArray( a_glyph_vertex_loc ); glEnableVertexAttribArray( a_glyph_vertex_loc );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glVertexAttribPointer( a_glyph_vertex_loc, 4, GL_FLOAT, GL_FALSE, sizeof(GLyphyDemo::glyph_vertex_t), 0 ); glVertexAttribPointer( a_glyph_vertex_loc, 4, GL_FLOAT, GL_FALSE, sizeof(glyph_vertex_t), 0 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glDrawArrays( GL_TRIANGLES, 0, vertices.size() ); glDrawArrays( GL_TRIANGLES, 0, vertices.size() );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment