Merge branch 'annotation-compile-issues' into 'master'

Fix minor compile issues with font classes



See merge request !435
This commit is contained in:
Kenneth Moreland 2016-06-01 18:53:10 -04:00
commit 0e114bb14d
5 changed files with 31 additions and 18 deletions

@ -22,7 +22,10 @@
#ifndef vtk_m_BitmapFont_h
#define vtk_m_BitmapFont_h
#include <vtkm/Types.h>
#include <string>
#include <vector>
namespace vtkm {
namespace rendering {
@ -87,7 +90,9 @@ public:
}
Character GetChar(char c)
{
return this->Chars[ShortMap[(unsigned char)c]];
std::size_t mappedCharIndex =
static_cast<std::size_t>(this->ShortMap[(unsigned char)c]);
return this->Chars[mappedCharIndex];
}
std::vector<unsigned char> &GetRawImageData()
{
@ -174,7 +179,8 @@ convert_to_rgba32: optional parameter, true by default.
works for trusted PNG files. Use LodePNG instead of picoPNG if you need this information.
return: 0 if success, not 0 if some error occured.
*/
static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image_width, unsigned long& image_height, const unsigned char* in_png, std::size_t in_size, bool convert_to_rgba32=true)
VTKM_CONT_EXPORT
int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image_width, unsigned long& image_height, const unsigned char* in_png, std::size_t in_size, bool convert_to_rgba32=true)
{
// picoPNG version 20101224
// Copyright (c) 2005-2010 Lode Vandevenne
@ -194,14 +200,14 @@ static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// picoPNG is a PNG decoder in one C++ function of around 500 lines. Use picoPNG for
// programs that need only 1 .cpp file. Since it's a single function, it's very limited,
// it can convert a PNG to raw pixel data either converted to 32-bit RGBA color or
// with no color conversion at all. For anything more complex, another tiny library
// is available: LodePNG (lodepng.c(pp)), which is a single source and header file.
// Apologies for the compact code style, it's to make this tiny.
static const unsigned long LENBASE[29] = {3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258};
static const unsigned long LENEXTRA[29] = {0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
static const unsigned long DISTBASE[30] = {1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577};
@ -343,7 +349,7 @@ static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image
error = tree.makeFromLengths(bitlen, 15); if(error) return; //now we've finally got HLIT and HDIST, so generate the code trees, and the function is done
error = treeD.makeFromLengths(bitlenD, 15); if(error) return;
}
void inflateHuffmanBlock(std::vector<unsigned char>& out, const unsigned char* in, std::size_t& bp, std::size_t& pos, std::size_t inlength, unsigned long btype)
void inflateHuffmanBlock(std::vector<unsigned char>& out, const unsigned char* in, std::size_t& bp, std::size_t& pos, std::size_t inlength, unsigned long btype)
{
if(btype == 1) { generateFixedTrees(codetree, codetreeD); }
else if(btype == 2) { getTreeInflateDynamic(codetree, codetreeD, in, bp, inlength); if(error) return; }
@ -406,7 +412,7 @@ static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image
std::vector<unsigned char> palette;
} info;
int error;
void decode(std::vector<unsigned char>& out, const unsigned char* in, std::size_t size, bool convert_to_rgba32)
void decode(std::vector<unsigned char>& out, const unsigned char* in, std::size_t size, bool convert_to_rgba32_flag)
{
error = 0;
if(size == 0 || in == 0) { error = 48; return; } //the given data is empty
@ -510,7 +516,7 @@ static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image
for(int i = 0; i < 7; i++)
adam7Pass(&out_[0], &scanlinen[0], &scanlineo[0], &scanlines[passstart[i]], info.width, pattern[i], pattern[i + 7], pattern[i + 14], pattern[i + 21], passw[i], passh[i], bpp);
}
if(convert_to_rgba32 && (info.colorType != 6 || info.bitDepth != 8)) //conversion needed
if(convert_to_rgba32_flag && (info.colorType != 6 || info.bitDepth != 8)) //conversion needed
{
std::vector<unsigned char> data = out;
error = convert(out, &data[0], info, info.width, info.height);
@ -594,7 +600,7 @@ static int decodePNG(std::vector<unsigned char>& out_image, unsigned long& image
return result;
}
void setBitOfReversedStream(std::size_t& bitp, unsigned char* bits, unsigned long bit) { bits[bitp >> 3] |= (unsigned char)( (bit << (7 - (bitp & 0x7))) ); bitp++; }
unsigned long read32bitInt(const unsigned char* buffer) { return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]; }
unsigned long read32bitInt(const unsigned char* buffer) { return ((unsigned long)buffer[0] << 24) | ((unsigned long)buffer[1] << 16) | ((unsigned long)buffer[2] << 8) | (unsigned long)buffer[3]; }
int checkColorValidity(unsigned long colorType, unsigned long bd) //return type is a LodePNG error code
{
if((colorType == 2 || colorType == 4 || colorType == 6)) { if(!(bd == 8 || bd == 16)) return 37; else return 0; }

@ -22,10 +22,13 @@ set(headers
AxisAnnotation.h
AxisAnnotation2D.h
AxisAnnotation3D.h
BitmapFont.h
BitmapFontFactory.h
BoundingBoxAnnotation.h
Color.h
ColorBarAnnotation.h
ColorTable.h
MatrixHelpers.h
Plot.h
RenderSurface.h
RenderSurfaceRayTracer.h
@ -33,6 +36,7 @@ set(headers
SceneRenderer.h
SceneRendererRayTracer.h
SceneRendererVolume.h
TextAnnotation.h
Triangulator.h
View.h
Window.h
@ -42,6 +46,7 @@ set(headers
set(opengl_headers
RenderSurfaceGL.h
SceneRendererGL.h
TextureGL.h
WorldAnnotatorGL.h
)

@ -21,6 +21,7 @@
#define vtk_m_rendering_MatrixHelpers_h
#include <vtkm/Matrix.h>
#include <vtkm/VectorAnalysis.h>
namespace vtkm {
namespace rendering {
@ -47,7 +48,7 @@ struct MatrixHelpers
oglM[13] = mtx[1][3];
oglM[14] = mtx[2][3];
oglM[15] = mtx[3][3];
}
}
static VTKM_CONT_EXPORT
vtkm::Matrix<vtkm::Float32,4,4> ViewMatrix(const vtkm::Vec<vtkm::Float32,3> &position,

@ -24,6 +24,7 @@
#include <vtkm/rendering/ColorTable.h>
#include <vtkm/rendering/View.h>
#include <vtkm/rendering/RenderSurface.h>
#include <vtkm/rendering/WorldAnnotator.h>
namespace vtkm {
namespace rendering {
@ -81,7 +82,7 @@ public:
// For vertical alignment, "center" is generally the center
// of only the above-baseline contents of the font, so we
// use a value slightly off of zero for VCenter.
// (We don't use an offset value instead of -1.0 for the
// (We don't use an offset value instead of -1.0 for the
// bottom value, because generally we want a true minimum
// extent, e.g. to have text sitting at the bottom of a
// window, and in that case, we need to keep all the text,
@ -170,7 +171,7 @@ public:
P = view.CreateProjectionMatrix();
vtkm::Vec<vtkm::Float32,4> p4w(XPos,YPos,ZPos,1);
vtkm::Vec<vtkm::Float32,4> p4s =
vtkm::Vec<vtkm::Float32,4> p4s =
vtkm::MatrixMultiply(vtkm::MatrixMultiply(P,V), p4w);
renderSurface.SetViewToScreenSpace(view,true);
@ -207,17 +208,17 @@ public:
vtkm::Vec<vtkm::Float32,4> right4(1,0,0,0);
vtkm::Vec<vtkm::Float32,4> up4(0,1,0,0);
vtkm::Matrix<vtkm::Float32, 4, 4> M =
vtkm::MatrixMultiply(T,
vtkm::Matrix<vtkm::Float32, 4, 4> M =
vtkm::MatrixMultiply(T,
vtkm::MatrixMultiply(SW,
vtkm::MatrixMultiply(SV,
vtkm::MatrixMultiply(SV,
R)));
vtkm::Vec<vtkm::Float32,4> new_origin4 =
vtkm::Vec<vtkm::Float32,4> new_origin4 =
vtkm::MatrixMultiply(M, origin4);
vtkm::Vec<vtkm::Float32,4> new_right4 =
vtkm::Vec<vtkm::Float32,4> new_right4 =
vtkm::MatrixMultiply(M, right4);
vtkm::Vec<vtkm::Float32,4> new_up4 =
vtkm::Vec<vtkm::Float32,4> new_up4 =
vtkm::MatrixMultiply(M, up4);
vtkm::Float32 px = new_origin4[0] / new_origin4[3];

@ -22,7 +22,7 @@
#ifndef vtk_m_TextureGL_h
#define vtk_m_TextureGL_h
#include <GL/gl.h>
#include <vtkm/rendering/internal/OpenGLHeaders.h>
#include <vtkm/rendering/ColorTable.h>
#include <vector>