// Create a selection of imagefilter-based paints to test
static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) {
    {
        SkMatrix scale;
        scale.setScale(2.0f, 2.0f);

        SkAutoTUnref<SkImageFilter> scaleMIF(
            SkImageFilter::CreateMatrixFilter(scale, kLow_SkFilterQuality, source));

        add_paint(scaleMIF, paints);
    }

    {
        SkMatrix rot;
        rot.setRotate(-33.3f);

        SkAutoTUnref<SkImageFilter> rotMIF(
            SkImageFilter::CreateMatrixFilter(rot, kLow_SkFilterQuality, source));

        add_paint(rotMIF, paints);
    }

    {
        static const SkDropShadowImageFilter::ShadowMode kBoth =
                    SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode;

        SkAutoTUnref<SkDropShadowImageFilter> dsif(
            SkDropShadowImageFilter::Create(10.0f, 10.0f,
                                            3.0f, 3.0f,
                                            SK_ColorRED, kBoth,
                                            source, nullptr));

        add_paint(dsif, paints);
    }

    {
        SkAutoTUnref<SkDropShadowImageFilter> dsif(
            SkDropShadowImageFilter::Create(27.0f, 27.0f,
                                            3.0f, 3.0f,
                                            SK_ColorRED,
                                            SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode,
                                            source, nullptr));

        add_paint(dsif, paints);
    }

    {
        SkAutoTUnref<SkBlurImageFilter> bif(SkBlurImageFilter::Create(3, 3, source));

        add_paint(bif, paints);
    }

    {
        SkAutoTUnref<SkOffsetImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source));

        add_paint(oif, paints);
    }
}
void test()
{
    {
    token t = "fashion";
    const char* v = "test";

    std::ostringstream ost;
    ost << t << v;
    }

    //binstream out and in test
/*
    bofstream bof("stl.test");

    const char* t = "some string";

    STLMIX x;
    x.x1.push_back("hallo");
    x.x1.push_back("co sa stallo");

    bof << t << x;
    bof.close();


    STLMIX y;
    bifstream bif("stl.test");

    bif >> t >> y;
    bif.close();*/

    //::free((void*)t);

    
    //metastream out and in test

    bofstream bof("stl_meta.test");
    fmtstreamxml2 txpo(bof);
    metastream meta(txpo);

    STLMIX x;
    meta.stream_out(x);

    bof.close();


    bifstream bif("stl_meta.test");

    fmtstreamxml2 txpi(bif);
    meta.bind_formatting_stream(txpi);

    STLMIX y;
    meta.stream_in(y);

    bif.close();
}
void scene_buildings::load_tile(glm::ivec2 pos)
{ 
	BuildingTileDCData building;
	building._tile_pos = pos;

	std::string file_name = "bld_tiles/buildingTile";
	file_name += '0' + pos.x;
	file_name += '0' + pos.y;
	file_name += ".osm.bin";

	// load buildings
	std::ifstream bif(file_name.c_str(),std::ios::binary);

	if (!bif.is_open()){
		_app->shutdown();
		return;
	}

	std::vector<Building> blds;
	
	uint32 blockCount = 0;

	bif.read((char*)(&blockCount),sizeof(uint32));

	base::stats()._ntriangles += uint64(blockCount) * 10;
	base::stats()._nvertices += uint64(blockCount) * 8;
	base::stats()._ndrawcalls++;

	std::vector<glm::ivec4> blocks;

	blocks.resize(blockCount);

	bif.read((char*)(blocks.begin()._Ptr), sizeof(glm::ivec4)*blockCount);

	building._blocks_count = blockCount;

	building._blocks_vbo = base::create_buffer<glm::int4>(blockCount, 0, blocks.begin()._Ptr);

	glGenTextures(1, &building._blocks_tb);
	glBindTexture(GL_TEXTURE_BUFFER, building._blocks_tb);
	glTexBuffer(GL_TEXTURE_BUFFER,
		base::get_pfd(base::PF_RGBA32I)->_internal,
		building._blocks_vbo);
	glBindTexture(GL_TEXTURE_BUFFER, 0);

	_tiles.push_back(building);

	base::cfg().buildings_count += blockCount;
}
Beispiel #4
0
GTEST_TEST(BIFFile11, mergeKEY) {
	Common::MemoryReadStream *stream = new Common::MemoryReadStream(kBIF11File);
	Aurora::BIFFile bif(stream);

	Common::MemoryReadStream keyStream(kKEYFile);
	Aurora::KEYFile key(keyStream);

	bif.mergeKEY(key, 0);

	EXPECT_EQ(bif.findResource("ozymandias", Aurora::kFileTypeTXT), 0);

	const Aurora::BIFFile::ResourceList &resources = bif.getResources();
	ASSERT_EQ(resources.size(), 1);

	const Aurora::BIFFile::Resource &resource = *resources.begin();

	EXPECT_STREQ(resource.name.c_str(), "ozymandias");
	EXPECT_EQ(resource.type, Aurora::kFileTypeTXT);
	EXPECT_EQ(resource.hash, 0);
	EXPECT_EQ(resource.index, 0);
}
Beispiel #5
0
/*-------------------------------------------------------------------------
 * Function:    parse_init
 *
 * Purpose:     Initialize the parse system.
 *
 * Return:      void
 *
 * Programmer:  Robb Matzke
 *              [email protected]
 *              Dec  4 1996
 *
 * Modifications:
 *
 *      Robb Matzke, 3 Feb 1997
 *      Added commands `end' and `quit' as aliases for `exit'.  Renamed
 *      command `with' as `open'.
 *
 *      Robb Matzke, 2000-06-02
 *      The `help' command doesn't evaluate its arguments.
 *
 *      Robb Matzke, 2000-06-06
 *      Added documentation strings.
 *-------------------------------------------------------------------------
 */
void
parse_init (void) {

   /*** user functions ***/
   bif ("array",        V_array,        0,
        "Create an array datatype.",
        "Creates a new array datatype. The arguments are the "
        "size of the array in each dimension and the datatype of the array "
        "elements. The array size arguments can be either integers or strings "
        "that look like comma- and/or space-separated integers. Browser "
        "arrays use C element ordering.");

   bif ("cd",           V_setcwd,       IMP_STRING,
        "Change current working directory.",
        "Each file has a current working directory (CWD) which is initially "
        "set to the root directory (`/'). This command will set the CWD to "
        "some other directory. The first argument is the name of the new CWD. "
        "If the name contains special characters it should be enclosed in "
        "quotes to protect it from the parser. If the name is relative "
        "(doesn't start with a `/') then the name looked up with respect to "
        "the current CWD.  The second optional argument is the file whose "
        "CWD is being set (default is the file represented by the browser "
        "variable `$1'). If the second argument evaluates to a list of files "
        "then the CWD is set for each file of the list (e.g., `cd domain_0 "
        "$*').");

   bif ("close",        V_close,        HOLD,
        "Close a SILO file.",
        "This function takes zero or more arguments which should all be "
        "symbol names (like `$1') and closes the files represented by each "
        "symbol.  The symbol becomes unbound. Closing the file associated "
        "with symbol FOO is equivalent to saying `FOO=nil', except with "
        "extra sanity checks.");

   bif ("diff",         V_diff,         0,
        "Compare two objects.",
        "Calculates the differences between its arguments similar to the "
        "Unix `diff' command. If called with an even number of arguments "
        "the argument list is split in half and each argument from the first "
        "half is compared with the corresponding argument of the second half. "
        "If called with no arguments then the argument list will be the "
        "SILO files from the command-line ($1, $2, etc).  If called with a "
        "single argument which is a silo object from file $1, that object "
        "will be differenced against an object with the same name from file "
        "$2. The behavior is influenced by the $diff browser variable (see "
        "`help $diff'). In general, if no differences are found then no "
        "output is produced.");

   bif ("end",          V_exit,         0,
        NULL,
        "A synonym for `exit'");
   
   bif ("exit",         V_exit,         0,
        "Exit the browser.", 
        "Causes the browser to exit with zero status. If an integer argument "
        "is supplied then the browser will use it as the exit status. End of "
        "input (usually Control-D for interactive input) causes an implicit "
        "call to `exit 0'.");

   bif ("file",         V_file,         IMP_STRING,
        "Dereference a name to get a SILO file.",
        "Returns the file whose name is specified by the first argument. If "
        "the file name contains special characters then the argument should "
        "be enclosed in quotes to protect it from the parser. The file is "
        "closed as soon as all references to the file dissappear. One common "
        "use of this function is with the `ls' or `diff' functions which can "
        "take file objects as arguments. For instance, the command `ls "
        "(file curv2d.pdb)' opens the file, lists the root directory, and "
        "then closes the file. The file is opened for read-write unless "
        "the file has only read permission or the `$rdonly' variable is "
        "non-zero and non-nil.  See also `help open'.");
        
   bif ("help",         V_help,         HOLDFIRST,
        "Show documentation.",
        "Shows documentation for various parts of the browser. When invoked "
        "without arguments it will display a table of contents of `help' "
        "subcommands. With one argument it will display documentation for a "
        "help category (e.g., `help run'), a browser internal variable (e.g., "
        "`help $diff'), a function (e.g., `help diff'), a command-line switch "
        "(e.g., `help --diff'), an operator (e.g., `help \"op=\"'), or the "
        "documentation string associated with the specified symbol.  When "
        "invoked with a string argument it will print all help categories "
        "which contain the specified string (e.g., `help \"diff\"'). When "
        "called with two arguments it assigns the second argument as the "
        "documentation property of the first argument, which must be a symbol "
        "or string.");

   bif("include",       V_include,      0,
       "Include commands from another source.", 
       "Parses and evaluates the browser commands in the file specified by "
       "the argument, which should evaluate to a string.");
   
   bif ("ls",           V_list,         HOLD,
        "List directory contents.",
        "Lists the current working directory (CWD) of the specified file. If "
        "no file is specified then list the CWD of the file represented by "
        "browser internal variable `$1'. Subsequent arguments are the names "
        "of the objects to be listed. If no names are supplied then all "
        "objects of the CWD are listed. Shell wild-cards are allowed in the "
        "names if the C library supports it.  When `ls' is invoked with an "
        "optional file argument and exactly one name which is the name of "
        "a directory, then the contents of that directory are listed.  If the "
        "first argument evaluates to a list of files (e.g., `ls $*') then a "
        "listing will be generated for each of those files.");

   bif ("noprint",      V_noprint,      0,
        "Supress output.",
        "Takes any number of arguments and returns NIL. Since the browser "
        "doesn't print NIL results by default, this function can be used to "
        "suppress printing of some expression result. It is often used in "
        "startup files.");

   bif ("open",         V_open,         HOLDREST | IMP_STRING,
        "Open a SILO file.",
        "Sets the current file to be the file named by the first argument. "
        "The current file is represented by the browser variable `$1'. If two "
        "arguments are given then the second argument should be a symbol "
        "to which will be bound the SILO file named by the first argument. "
        "If some file was previously bound to the new file's symbol then the "
        "old file is closed first. This function is equivalent to "
        "`arg2=(file \"arg1\")'");

   bif ("pointer",      V_pointer,      0,
        "Create a pointer datatype.",
        "Creates a pointer datatype. The first (and only) argument is the "
        "datatype to which this pointer points.");

   bif ("primitive",    V_primitive,    0,
        "Create a primitive datatype.",
        "Creates a primitive datatype. The first (and only) argument is the "
        "name of the primitive type. Primitive types are: int8, short, int, "
        "long, float, double, and string.");
   
   bif ("print",        V_print,        0,
        "Print an expression.",
        "Takes zero or more arguments and prints all that are non-nil, each "
        "on its own line of output, returning nil. All expressions are "
        "normally printed by the browser in its read-eval-print loop, so "
        "calling this command explicitly is seldom necessary.");
   
   bif ("pwd",          V_pwd,          0,
        "Show the current working directory name.",
        "Prints the current working directory (CWD) of the specified file. If "
        "no file is specified then print the CWD of the file represented by "
        "browser variable `$1'.  If the argument is a list of files then the "
        "CWD of each of those files is printed (e.g., `pwd $*'). This command "
        "is identical to printing an expression that evaluates to a file or "
        "list of files (e.g., `$1' or `$*').");
   
   bif ("quit",         V_exit,         0,
        NULL,
        "A synonym for `exit'.");

   bif ("setf",         V_setf,         HOLDFIRST,
        "Bind a function to a symbol.",
        "Given a symbol as the first argument, sets the symbols functional "
        "value to the second argument.");
   
   bif ("struct",       V_struct,       0,
        "Create a compound datatype.",
        "Creates a compound datatype. The first argument should be the name "
        "for the datatype (or nil). The following arguments occur in triples, "
        "one per compound datatype member. Each triple is an integer byte "
        "offset from the beginning of memory of an instance of this type, the "
        "name of the member, and the datatype of the member.");
   
   bif ("typeof",       V_typeof,       0,
        "Obtain the datatype of an object.",
        "Returns the datatype of a SILO or browser object. For SILO database "
        "objects the type which is printed is fully qualified and bound to "
        "actual values. In contract, printing the actual named type shows the "
        "unbound values. For example, if `d' is a SILO DBquadvar object then "
        "`typeof d.dims' might show `[3] int' while `print DBquadvar.dims' "
        "displays `[self.ndims] int'.");

   /*** Operators ***/
   bif ("Assign",       V_assign,       HOLDFIRST,
        "Assignment operator (`=').",
        "The assignment operator is a binary in-fix operator whose left "
        "operand should be the name of a browser symbol or an object (or "
        "subobject) of a SILO file and whose right operand evaluates to "
        "some value. The value of the right operand is assigned to the "
        "left operand. The `=' operator and `Assign' symbol are bound to "
        "the same function.");

   bif ("Dot",          V_dot,          HOLDREST,
        "Restriction operators (`.', `[]').",
        "This is a restriction operator whose function depends on the "
        "type of the left operand.\n"
        "\n"
        "If the left operand evaluates to a file (e.g., `$1') then the "
        "variable or directory whose name is specified by the second argument "
        "(a string or symbol) is loaded from that file and returned. If "
        "the left operand refers to the same file as `$1' and the right "
        "argument need not be enclosed in quotes and is not the name of "
        "a browser variable, then the file symbol and dot can be omitted "
        "(that is, `$1.quadmesh' is equivalent to just `quadmesh').\n"
        "\n"
        "If the left operand evaluates to some SILO data object which has "
        "a structured type then the right operand should a the name of a "
        "field of that compound type. This operator will return the "
        "specified field of the SILO object.  For instance, if `qm' is "
        "of type `DBquadmesh' then the expression `qm.dims' returns the "
        "quadmesh dimension array.\n"
        "\n"
        "If the left operand evaluates to a compound datatype then the "
        "right operand should be the name of one of the fields of that "
        "datatype. This operator will return the datatype of the specified "
        "field from the left operand.\n"
        "\n"
        "If the left operand is an array datatype or a silo object of "
        "array datatype and the right operand is an integer then this "
        "operator returns the specified array element (using C-like "
        "zero-based indexing) Example: `mesh_3d.min_extents[0]'.\n"
        "\n"
        "If the left operand is an array datatype or a silo object of "
        "array datatype and the right operand is a range `MIN:MAX' then "
        "this operator returns a sub-array with elements MIN through "
        "MAX, inclusive. Example: `mesh_3d.min_extents[0:1]'\n"
        "\n"
        "If the left operand is an array datatype or a silo object of "
        "array datatype and the right operands are integers or ranges "
        "then one operand is applied to each array dimension in turn, "
        "automatically skipping over pointers. For instance, if a quadvar "
        "`qv' has a `vals' field of type `*[2]*[36000]float' then the "
        "expression `qv.vals[0,100:199]' will be an object consisting of the "
        "second 100 values of the first variable. (The expression "
        "`qv.vals[0][100:199]' would result in an errr because "
        "`qv.vals[0]' returns an object with the type `[1]*[36000]float' "
        "to which is then applied the `[100:199]', which is invalid because "
        "the array has only one element.\n"
        "\n"
        "If the left operand is a list then this operator is applied to "
        "each member of that list, returning a list of the results.");


   bif ("Pipe",         V_pipe,         HOLD,
        "Redirection operator (`|').",
        "Evaluates the left operand and redirects its output to the shell "
        "command specified by the right operand. The `|' operator and `Pipe' "
        "symbol are bound to the same function, but when invoked as the "
        "`Pipe' function a third argument is required. The third argument "
        "is a popen(3c) mode string.");
   
   bif ("Quote",        V_quote,        HOLD,
        "List quoting operator (`{}').",
        "This operator takes zero or more operands occurring between the "
        "curly brackes (optionally separated by commas) and returns a list "
        "of those unevaluated operands. If only one operand is given then "
        "that operand is returned unevaluated and not in a list. The `{}' "
        "operator and `Quote' symbol are bound to the same function.");

   bif ("Redirect",     V_redirect,     HOLD,
        "Redirection operators (`>', `>>').",
        "Evaluates the left operand and redirects its output to the file "
        "whose name is specified by the right operand.  The `>' and `>>' "
        "operators are bound to the same function as the `Redirect' symbol, "
        "but invoking the function as `Redirect' requires a third argument "
        "which is the fopen(3c) mode string.");

   bif(NULL, NULL, 0,
       "Range operator (`:').",
       "The range operator is used to construct a range object which "
       "represents all integers between the left and right operands, "
       "inclusive.");
}