summaryrefslogtreecommitdiffstats
path: root/o3d/core
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 19:56:24 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 19:56:24 +0000
commitccf02ac9bd67d4d49ad8264ae7fc6098e361ff4b (patch)
treefc6e4a0552431c7297798fad46f57fb76c35a3b3 /o3d/core
parentdfe9d1d2de7fd8d244599b79a22898cce8df7c81 (diff)
downloadchromium_src-ccf02ac9bd67d4d49ad8264ae7fc6098e361ff4b.zip
chromium_src-ccf02ac9bd67d4d49ad8264ae7fc6098e361ff4b.tar.gz
chromium_src-ccf02ac9bd67d4d49ad8264ae7fc6098e361ff4b.tar.bz2
Made all line endings consistently LF and added svn:eol-style=LF property to files with these names / extensions.
c cc h mm txt idl py js html css gyp gypi xml shader json htm README DEPS git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core')
-rw-r--r--o3d/core/cross/bitmap.h808
-rw-r--r--o3d/core/cross/client_info.h270
-rw-r--r--o3d/core/cross/gl/gl_headers.h86
-rw-r--r--o3d/core/cross/image_utils.h576
-rw-r--r--o3d/core/cross/pointer_utils.h116
-rw-r--r--o3d/core/win/d3d9/software_renderer_d3d9.h2
6 files changed, 929 insertions, 929 deletions
diff --git a/o3d/core/cross/bitmap.h b/o3d/core/cross/bitmap.h
index 9b375bd..96e9b7b 100644
--- a/o3d/core/cross/bitmap.h
+++ b/o3d/core/cross/bitmap.h
@@ -1,404 +1,404 @@
-/*
- * Copyright 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-// This file contains the declaration of Bitmap helper class that can load
-// raw 24- and 32-bit bitmaps from popular image formats. The Bitmap class
-// also interprets the file format to record the correct OpenGL buffer format.
-//
-// Trying to keep this class independent from the OpenGL API in case they
-// need retargeting later on.
-
-#ifndef O3D_CORE_CROSS_BITMAP_H_
-#define O3D_CORE_CROSS_BITMAP_H_
-
-#include <stdlib.h>
-#include <vector>
-#include "base/cross/bits.h"
-#include "core/cross/types.h"
-#include "core/cross/texture_base.h"
-#include "core/cross/image_utils.h"
-
-class FilePath;
-
-namespace o3d {
-
-class MemoryReadStream;
-class RawData;
-class Pack;
-
-// Bitmap provides an API for basic image operations on bitmap images,
-// including scale and crop. Bitmaps can be created from a RawData object via
-// LoadFromRawData(), and also can be transfered to mips of a Texure2D or a
-// specific face of TextureCUBE via methods in Texture.
-
-class Bitmap : public ParamObject {
- public:
- typedef SmartPointer<Bitmap> Ref;
- typedef std::vector<Bitmap::Ref> BitmapRefArray;
-
- explicit Bitmap(ServiceLocator* service_locator);
- virtual ~Bitmap() {}
-
- enum Semantic {
- FACE_POSITIVE_X, // NOTE: These must match TextureCUBE::CubeFace
- FACE_NEGATIVE_X,
- FACE_POSITIVE_Y,
- FACE_NEGATIVE_Y,
- FACE_POSITIVE_Z,
- FACE_NEGATIVE_Z,
- IMAGE, // normal 2d image
- SLICE, // a slice of a 3d texture.
- };
-
- // Returns the pitch of the bitmap for a certain level.
- int GetMipPitch(int level) const {
- return image::ComputeMipPitch(format(), level, width());
- }
-
- // Creates a copy of a bitmap, copying the pixels as well.
- // Parameters:
- // source: the source bitmap.
- void CopyDeepFrom(const Bitmap &source) {
- Allocate(source.format_, source.width_, source.height_,
- source.num_mipmaps_, source.semantic_);
- memcpy(image_data(), source.image_data(), GetTotalSize());
- }
-
- // Sets the bitmap parameters from another bitmap, stealing the pixel buffer
- // from the source bitmap.
- // Parameters:
- // source: the source bitmap.
- void SetFrom(Bitmap *source);
-
- // Allocates an uninitialized bitmap with specified parameters.
- // Parameters:
- // format: the format of the pixels.
- // width: the width of the base image.
- // height: the height of the base image.
- // num_mipmaps: the number of mip-maps.
- void Allocate(Texture::Format format,
- unsigned int width,
- unsigned int height,
- unsigned int num_mipmaps,
- Semantic semantic);
-
- // Allocates a bitmap with initialized parameters.
- // data is zero-initialized
- void AllocateData() {
- image_data_.reset(new uint8[GetTotalSize()]);
- memset(image_data_.get(), 0, GetTotalSize());
- }
-
- // Frees the data owned by the bitmap.
- void FreeData() {
- image_data_.reset(NULL);
- }
-
- // Sets a rectangular region of this bitmap.
- // If the bitmap is a DXT format, the only acceptable values
- // for left, top, width and height are 0, 0, bitmap->width, bitmap->height
- //
- // Parameters:
- // level: The mipmap level to modify
- // dst_left: The left edge of the rectangular area to modify.
- // dst_top: The top edge of the rectangular area to modify.
- // width: The width of the rectangular area to modify.
- // height: The of the rectangular area to modify.
- // src_data: The source pixels.
- // src_pitch: If the format is uncompressed this is the number of bytes
- // per row of pixels. If compressed this value is unused.
- void SetRect(int level,
- unsigned dst_left,
- unsigned dst_top,
- unsigned width,
- unsigned height,
- const void* src_data,
- int src_pitch);
-
- // Gets the image data for a given mip-map level.
- // Parameters:
- // level: mip level to get.
- uint8 *GetMipData(unsigned int level) const;
-
- // Gets the address of a particular pixel.
- // Parameters:
- // level: mip level to get.
- uint8 *GetPixelData(unsigned int level, unsigned int x, unsigned int y) const;
-
- // Gets the size of mip.
- size_t GetMipSize(unsigned int level) const;
-
- uint8 *image_data() const { return image_data_.get(); }
- Texture::Format format() const { return format_; }
- unsigned int width() const { return width_; }
- unsigned int height() const { return height_; }
- unsigned int num_mipmaps() const { return num_mipmaps_; }
- Semantic semantic() const {
- return semantic_;
- }
-
- // Returns whether or not the dimensions of the bitmap are power-of-two.
- bool IsPOT() const {
- return image::IsPOT(width_, height_);
- }
-
- // Loads a bitmap from a file.
- // Parameters:
- // filename: the name of the file to load.
- // file_type: the type of file to load. If UNKNOWN, the file type will be
- // determined from the filename extension, and if it is not a
- // known extension, all the loaders will be tried.
- // bitmaps: An array to hold references to the loaded bitmaps.
- static bool LoadFromFile(ServiceLocator* service_locator,
- const FilePath &filepath,
- image::ImageFileType file_type,
- BitmapRefArray* bitmaps);
-
- // Loads a bitmap from a RawData object.
- // Parameters:
- // raw_data: contains the bitmap data in one of the known formats
- // file_type: the format of the bitmap data. If UNKNOWN, the file type
- // will be determined from the extension from raw_data's uri
- // and if it is not a known extension, all the loaders will
- // be tried.
- // bitmaps: An array to hold references to the loaded bitmaps.
- static bool LoadFromRawData(RawData *raw_data,
- image::ImageFileType file_type,
- BitmapRefArray* bitmaps);
-
- // Flips a bitmap vertically in place.
- // This is needed instead of just using DrawImage because flipping DXT formats
- // using generic algorithms would be lossy and extremely slow to reconvert
- // from a flippable format back to a DXT format.
- void FlipVertically();
-
- // Returns the contents of the bitmap as a data URL
- // Returns:
- // A data url that represents the content of the bitmap.
- String ToDataURL();
-
- // Checks that the alpha channel for the entire bitmap is 1.0
- bool CheckAlphaIsOne() const;
-
- // Copy pixels from source bitmap. Scales if the width and height of source
- // and dest do not match.
- // Parameters:
- // source_img: source bitmap which would be drawn.
- // source_level: level to draw.
- // source_x: x-coordinate of the starting pixel in the source image.
- // source_x: y-coordinate of the starting pixel in the source image.
- // source_width: width of the source image to draw.
- // source_height: Height of the source image to draw.
- // dest_level: level to target.
- // dest_x: x-coordinate of the starting pixel in the dest image.
- // dest_y: y-coordinate of the starting pixel in the dest image.
- // dest_width: width of the dest image to draw.
- // dest_height: height of the dest image to draw.
- void DrawImage(const Bitmap& source_img, int source_level,
- int source_x, int source_y,
- int source_width, int source_height,
- int dest_level,
- int dest_x, int dest_y,
- int dest_width, int dest_height);
-
- // Gets the size of the buffer containing a mip-map chain, given a number of
- // mip-map levels.
- size_t GetMipChainSize(unsigned int num_mipmaps) const {
- return image::ComputeMipChainSize(width(), height(), format(), num_mipmaps);
- }
-
- // Generates Mips from the source_level for num_levels
- void GenerateMips(int source_level, int num_levels);
-
- private:
- friend class IClassManager;
- static ObjectBase::Ref Create(ServiceLocator* service_locator);
-
- // Sets the contents of a Bitmap replacing any previous contents.
- // Parameters:
- // format: Format of the bitmap.
- // num_mipmaps: The number of mipmaps.
- // width: width in pixels.
- // height: height in pixels.
- // semantic: the semantic of the bitmap
- // image_data: The image data. The bitmap will take ownership of this data.
- void SetContents(Texture::Format format,
- unsigned int num_mipmaps,
- unsigned int width,
- unsigned int height,
- Semantic semantic,
- scoped_array<uint8>* image_data);
-
- // Loads bitmaps from a MemoryReadStream.
- // Parameters:
- // stream: a stream for the bitmap data in one of the known formats
- // filename: a filename (or uri) of the original bitmap data
- // (may be an empty string)
- // file_type: the format of the bitmap data. If UNKNOWN, the file type
- // will be determined from the extension of |filename|
- // and if it is not a known extension, all the loaders
- // will be tried.
- // bitmaps: An array to hold references to the loaded bitmaps.
- static bool LoadFromStream(ServiceLocator* service_locator,
- MemoryReadStream *stream,
- const String &filename,
- image::ImageFileType file_type,
- BitmapRefArray* bitmaps);
-
- static bool LoadFromPNGStream(ServiceLocator* service_locator,
- MemoryReadStream *stream,
- const String &filename,
- BitmapRefArray* bitmaps);
-
- static bool LoadFromTGAStream(ServiceLocator* service_locator,
- MemoryReadStream *stream,
- const String &filename,
- BitmapRefArray* bitmaps);
-
- static bool LoadFromDDSStream(ServiceLocator* service_locator,
- MemoryReadStream *stream,
- const String &filename,
- BitmapRefArray* bitmaps);
-
- static bool LoadFromJPEGStream(ServiceLocator* service_locator,
- MemoryReadStream *stream,
- const String &filename,
- BitmapRefArray* bitmaps);
-
- bool GenerateMipmaps(unsigned int base_width,
- unsigned int base_height,
- Texture::Format format,
- unsigned int num_mipmaps,
- uint8 *data);
-
- // Gets the total size of the bitmap data, counting all faces and mip levels.
- size_t GetTotalSize() const {
- return GetMipChainSize(image::ComputeMipMapCount(width_, height_));
- }
-
- static size_t ComputeMaxSize(
- unsigned width, unsigned height, Texture::Format format);
-
- // pointer to the raw bitmap data
- // NOTE: image_data_ is either NULL or it has space for the maximum number
- // of mips for the current size bitmap, even if they are not used.
- scoped_array<uint8> image_data_;
- // format of the texture this is meant to represent.
- Texture::Format format_;
- // width of the bitmap in pixels.
- int width_;
- // height of the bitmap in pixels.
- int height_;
- // number of valid mipmap levels in this bitmap.
- unsigned int num_mipmaps_;
- // The purpose of the bitmap
- Semantic semantic_;
-
- O3D_DECL_CLASS(Bitmap, ParamObject);
- DISALLOW_COPY_AND_ASSIGN(Bitmap);
-};
-
-typedef Bitmap::BitmapRefArray BitmapRefArray;
-
-class BitmapUncompressed : public Bitmap {
- public:
- explicit BitmapUncompressed(ServiceLocator* service_locator);
-};
-
-template <typename T>
-class TypedBitmapUncompressed : public BitmapUncompressed {
- public:
- typedef T ComponentType;
- explicit TypedBitmapUncompressed(ServiceLocator* service_locator)
- : BitmapUncompressed(service_locator) {
- }
-};
-
-class Bitmap8 : public TypedBitmapUncompressed<uint8> {
- public:
- explicit Bitmap8(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Bitmap8);
-};
-
-class Bitmap16F : public TypedBitmapUncompressed<uint16> {
- public:
- explicit Bitmap16F(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Bitmap16F);
-};
-
-class Bitmap32F : public TypedBitmapUncompressed<float> {
- public:
- explicit Bitmap32F(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Bitmap32F);
-};
-
-class BitmapCompressed : public Bitmap {
- public:
- explicit BitmapCompressed(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BitmapCompressed);
-};
-
-class BitmapDXT1 : public BitmapCompressed {
- public:
- explicit BitmapDXT1(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BitmapDXT1);
-};
-
-class BitmapDXT3 : public BitmapCompressed {
- public:
- explicit BitmapDXT3(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BitmapDXT3);
-};
-
-class BitmapDXT5 : public BitmapCompressed {
- public:
- explicit BitmapDXT5(ServiceLocator* service_locator);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BitmapDXT5);
-};
-
-} // namespace o3d
-
-#endif // O3D_CORE_CROSS_BITMAP_H_
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file contains the declaration of Bitmap helper class that can load
+// raw 24- and 32-bit bitmaps from popular image formats. The Bitmap class
+// also interprets the file format to record the correct OpenGL buffer format.
+//
+// Trying to keep this class independent from the OpenGL API in case they
+// need retargeting later on.
+
+#ifndef O3D_CORE_CROSS_BITMAP_H_
+#define O3D_CORE_CROSS_BITMAP_H_
+
+#include <stdlib.h>
+#include <vector>
+#include "base/cross/bits.h"
+#include "core/cross/types.h"
+#include "core/cross/texture_base.h"
+#include "core/cross/image_utils.h"
+
+class FilePath;
+
+namespace o3d {
+
+class MemoryReadStream;
+class RawData;
+class Pack;
+
+// Bitmap provides an API for basic image operations on bitmap images,
+// including scale and crop. Bitmaps can be created from a RawData object via
+// LoadFromRawData(), and also can be transfered to mips of a Texure2D or a
+// specific face of TextureCUBE via methods in Texture.
+
+class Bitmap : public ParamObject {
+ public:
+ typedef SmartPointer<Bitmap> Ref;
+ typedef std::vector<Bitmap::Ref> BitmapRefArray;
+
+ explicit Bitmap(ServiceLocator* service_locator);
+ virtual ~Bitmap() {}
+
+ enum Semantic {
+ FACE_POSITIVE_X, // NOTE: These must match TextureCUBE::CubeFace
+ FACE_NEGATIVE_X,
+ FACE_POSITIVE_Y,
+ FACE_NEGATIVE_Y,
+ FACE_POSITIVE_Z,
+ FACE_NEGATIVE_Z,
+ IMAGE, // normal 2d image
+ SLICE, // a slice of a 3d texture.
+ };
+
+ // Returns the pitch of the bitmap for a certain level.
+ int GetMipPitch(int level) const {
+ return image::ComputeMipPitch(format(), level, width());
+ }
+
+ // Creates a copy of a bitmap, copying the pixels as well.
+ // Parameters:
+ // source: the source bitmap.
+ void CopyDeepFrom(const Bitmap &source) {
+ Allocate(source.format_, source.width_, source.height_,
+ source.num_mipmaps_, source.semantic_);
+ memcpy(image_data(), source.image_data(), GetTotalSize());
+ }
+
+ // Sets the bitmap parameters from another bitmap, stealing the pixel buffer
+ // from the source bitmap.
+ // Parameters:
+ // source: the source bitmap.
+ void SetFrom(Bitmap *source);
+
+ // Allocates an uninitialized bitmap with specified parameters.
+ // Parameters:
+ // format: the format of the pixels.
+ // width: the width of the base image.
+ // height: the height of the base image.
+ // num_mipmaps: the number of mip-maps.
+ void Allocate(Texture::Format format,
+ unsigned int width,
+ unsigned int height,
+ unsigned int num_mipmaps,
+ Semantic semantic);
+
+ // Allocates a bitmap with initialized parameters.
+ // data is zero-initialized
+ void AllocateData() {
+ image_data_.reset(new uint8[GetTotalSize()]);
+ memset(image_data_.get(), 0, GetTotalSize());
+ }
+
+ // Frees the data owned by the bitmap.
+ void FreeData() {
+ image_data_.reset(NULL);
+ }
+
+ // Sets a rectangular region of this bitmap.
+ // If the bitmap is a DXT format, the only acceptable values
+ // for left, top, width and height are 0, 0, bitmap->width, bitmap->height
+ //
+ // Parameters:
+ // level: The mipmap level to modify
+ // dst_left: The left edge of the rectangular area to modify.
+ // dst_top: The top edge of the rectangular area to modify.
+ // width: The width of the rectangular area to modify.
+ // height: The of the rectangular area to modify.
+ // src_data: The source pixels.
+ // src_pitch: If the format is uncompressed this is the number of bytes
+ // per row of pixels. If compressed this value is unused.
+ void SetRect(int level,
+ unsigned dst_left,
+ unsigned dst_top,
+ unsigned width,
+ unsigned height,
+ const void* src_data,
+ int src_pitch);
+
+ // Gets the image data for a given mip-map level.
+ // Parameters:
+ // level: mip level to get.
+ uint8 *GetMipData(unsigned int level) const;
+
+ // Gets the address of a particular pixel.
+ // Parameters:
+ // level: mip level to get.
+ uint8 *GetPixelData(unsigned int level, unsigned int x, unsigned int y) const;
+
+ // Gets the size of mip.
+ size_t GetMipSize(unsigned int level) const;
+
+ uint8 *image_data() const { return image_data_.get(); }
+ Texture::Format format() const { return format_; }
+ unsigned int width() const { return width_; }
+ unsigned int height() const { return height_; }
+ unsigned int num_mipmaps() const { return num_mipmaps_; }
+ Semantic semantic() const {
+ return semantic_;
+ }
+
+ // Returns whether or not the dimensions of the bitmap are power-of-two.
+ bool IsPOT() const {
+ return image::IsPOT(width_, height_);
+ }
+
+ // Loads a bitmap from a file.
+ // Parameters:
+ // filename: the name of the file to load.
+ // file_type: the type of file to load. If UNKNOWN, the file type will be
+ // determined from the filename extension, and if it is not a
+ // known extension, all the loaders will be tried.
+ // bitmaps: An array to hold references to the loaded bitmaps.
+ static bool LoadFromFile(ServiceLocator* service_locator,
+ const FilePath &filepath,
+ image::ImageFileType file_type,
+ BitmapRefArray* bitmaps);
+
+ // Loads a bitmap from a RawData object.
+ // Parameters:
+ // raw_data: contains the bitmap data in one of the known formats
+ // file_type: the format of the bitmap data. If UNKNOWN, the file type
+ // will be determined from the extension from raw_data's uri
+ // and if it is not a known extension, all the loaders will
+ // be tried.
+ // bitmaps: An array to hold references to the loaded bitmaps.
+ static bool LoadFromRawData(RawData *raw_data,
+ image::ImageFileType file_type,
+ BitmapRefArray* bitmaps);
+
+ // Flips a bitmap vertically in place.
+ // This is needed instead of just using DrawImage because flipping DXT formats
+ // using generic algorithms would be lossy and extremely slow to reconvert
+ // from a flippable format back to a DXT format.
+ void FlipVertically();
+
+ // Returns the contents of the bitmap as a data URL
+ // Returns:
+ // A data url that represents the content of the bitmap.
+ String ToDataURL();
+
+ // Checks that the alpha channel for the entire bitmap is 1.0
+ bool CheckAlphaIsOne() const;
+
+ // Copy pixels from source bitmap. Scales if the width and height of source
+ // and dest do not match.
+ // Parameters:
+ // source_img: source bitmap which would be drawn.
+ // source_level: level to draw.
+ // source_x: x-coordinate of the starting pixel in the source image.
+ // source_x: y-coordinate of the starting pixel in the source image.
+ // source_width: width of the source image to draw.
+ // source_height: Height of the source image to draw.
+ // dest_level: level to target.
+ // dest_x: x-coordinate of the starting pixel in the dest image.
+ // dest_y: y-coordinate of the starting pixel in the dest image.
+ // dest_width: width of the dest image to draw.
+ // dest_height: height of the dest image to draw.
+ void DrawImage(const Bitmap& source_img, int source_level,
+ int source_x, int source_y,
+ int source_width, int source_height,
+ int dest_level,
+ int dest_x, int dest_y,
+ int dest_width, int dest_height);
+
+ // Gets the size of the buffer containing a mip-map chain, given a number of
+ // mip-map levels.
+ size_t GetMipChainSize(unsigned int num_mipmaps) const {
+ return image::ComputeMipChainSize(width(), height(), format(), num_mipmaps);
+ }
+
+ // Generates Mips from the source_level for num_levels
+ void GenerateMips(int source_level, int num_levels);
+
+ private:
+ friend class IClassManager;
+ static ObjectBase::Ref Create(ServiceLocator* service_locator);
+
+ // Sets the contents of a Bitmap replacing any previous contents.
+ // Parameters:
+ // format: Format of the bitmap.
+ // num_mipmaps: The number of mipmaps.
+ // width: width in pixels.
+ // height: height in pixels.
+ // semantic: the semantic of the bitmap
+ // image_data: The image data. The bitmap will take ownership of this data.
+ void SetContents(Texture::Format format,
+ unsigned int num_mipmaps,
+ unsigned int width,
+ unsigned int height,
+ Semantic semantic,
+ scoped_array<uint8>* image_data);
+
+ // Loads bitmaps from a MemoryReadStream.
+ // Parameters:
+ // stream: a stream for the bitmap data in one of the known formats
+ // filename: a filename (or uri) of the original bitmap data
+ // (may be an empty string)
+ // file_type: the format of the bitmap data. If UNKNOWN, the file type
+ // will be determined from the extension of |filename|
+ // and if it is not a known extension, all the loaders
+ // will be tried.
+ // bitmaps: An array to hold references to the loaded bitmaps.
+ static bool LoadFromStream(ServiceLocator* service_locator,
+ MemoryReadStream *stream,
+ const String &filename,
+ image::ImageFileType file_type,
+ BitmapRefArray* bitmaps);
+
+ static bool LoadFromPNGStream(ServiceLocator* service_locator,
+ MemoryReadStream *stream,
+ const String &filename,
+ BitmapRefArray* bitmaps);
+
+ static bool LoadFromTGAStream(ServiceLocator* service_locator,
+ MemoryReadStream *stream,
+ const String &filename,
+ BitmapRefArray* bitmaps);
+
+ static bool LoadFromDDSStream(ServiceLocator* service_locator,
+ MemoryReadStream *stream,
+ const String &filename,
+ BitmapRefArray* bitmaps);
+
+ static bool LoadFromJPEGStream(ServiceLocator* service_locator,
+ MemoryReadStream *stream,
+ const String &filename,
+ BitmapRefArray* bitmaps);
+
+ bool GenerateMipmaps(unsigned int base_width,
+ unsigned int base_height,
+ Texture::Format format,
+ unsigned int num_mipmaps,
+ uint8 *data);
+
+ // Gets the total size of the bitmap data, counting all faces and mip levels.
+ size_t GetTotalSize() const {
+ return GetMipChainSize(image::ComputeMipMapCount(width_, height_));
+ }
+
+ static size_t ComputeMaxSize(
+ unsigned width, unsigned height, Texture::Format format);
+
+ // pointer to the raw bitmap data
+ // NOTE: image_data_ is either NULL or it has space for the maximum number
+ // of mips for the current size bitmap, even if they are not used.
+ scoped_array<uint8> image_data_;
+ // format of the texture this is meant to represent.
+ Texture::Format format_;
+ // width of the bitmap in pixels.
+ int width_;
+ // height of the bitmap in pixels.
+ int height_;
+ // number of valid mipmap levels in this bitmap.
+ unsigned int num_mipmaps_;
+ // The purpose of the bitmap
+ Semantic semantic_;
+
+ O3D_DECL_CLASS(Bitmap, ParamObject);
+ DISALLOW_COPY_AND_ASSIGN(Bitmap);
+};
+
+typedef Bitmap::BitmapRefArray BitmapRefArray;
+
+class BitmapUncompressed : public Bitmap {
+ public:
+ explicit BitmapUncompressed(ServiceLocator* service_locator);
+};
+
+template <typename T>
+class TypedBitmapUncompressed : public BitmapUncompressed {
+ public:
+ typedef T ComponentType;
+ explicit TypedBitmapUncompressed(ServiceLocator* service_locator)
+ : BitmapUncompressed(service_locator) {
+ }
+};
+
+class Bitmap8 : public TypedBitmapUncompressed<uint8> {
+ public:
+ explicit Bitmap8(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Bitmap8);
+};
+
+class Bitmap16F : public TypedBitmapUncompressed<uint16> {
+ public:
+ explicit Bitmap16F(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Bitmap16F);
+};
+
+class Bitmap32F : public TypedBitmapUncompressed<float> {
+ public:
+ explicit Bitmap32F(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Bitmap32F);
+};
+
+class BitmapCompressed : public Bitmap {
+ public:
+ explicit BitmapCompressed(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BitmapCompressed);
+};
+
+class BitmapDXT1 : public BitmapCompressed {
+ public:
+ explicit BitmapDXT1(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BitmapDXT1);
+};
+
+class BitmapDXT3 : public BitmapCompressed {
+ public:
+ explicit BitmapDXT3(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BitmapDXT3);
+};
+
+class BitmapDXT5 : public BitmapCompressed {
+ public:
+ explicit BitmapDXT5(ServiceLocator* service_locator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BitmapDXT5);
+};
+
+} // namespace o3d
+
+#endif // O3D_CORE_CROSS_BITMAP_H_
diff --git a/o3d/core/cross/client_info.h b/o3d/core/cross/client_info.h
index 40cda3c..2d2c9b7 100644
--- a/o3d/core/cross/client_info.h
+++ b/o3d/core/cross/client_info.h
@@ -1,135 +1,135 @@
-/*
- * Copyright 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-// This file defines the ClientInfo class.
-
-#ifndef O3D_CORE_CROSS_CLIENT_INFO_H_
-#define O3D_CORE_CROSS_CLIENT_INFO_H_
-
-#include "core/cross/types.h"
-#include "core/cross/service_locator.h"
-#include "core/cross/service_implementation.h"
-
-namespace o3d {
-
-// This class is used to report infomation about the client.
-class ClientInfo {
- public:
- ClientInfo();
-
- // The number of objects the client is currently tracking.
- int num_objects() const {
- return num_objects_;
- }
-
- // The amount of texture memory used.
- int texture_memory_used() const {
- return texture_memory_used_;
- };
-
- // The amount of texture memory used.
- int buffer_memory_used() const {
- return buffer_memory_used_;
- }
-
- // Whether or not we are using the software renderer.
- bool software_renderer() const {
- return software_renderer_;
- }
-
- // Whether or not the underlying GPU supports non power of 2 textures.
- // NOTE: O3D always supports non power of 2 textures from a public API
- // point of view and massages the data underneath to make this work.
- // The point of this flag is mostly that if you are doing any kind of
- // dynamic texture updating, like video, then you might want to use a
- // power of two texture so O3D doesn't have to do extra work of converting
- // your NPOT texture into a POT texture behind the scenes.
- bool non_power_of_two_textures() const {
- return non_power_of_two_textures_;
- }
-
- // Gets the O3D version.
- const String& version() const {
- return version_;
- }
-
- private:
- friend class ClientInfoManager;
-
- int num_objects_;
- int texture_memory_used_;
- int buffer_memory_used_;
- bool software_renderer_;
- bool non_power_of_two_textures_;
- String version_;
-};
-
-// A class to manage the client info so other classes can easily look it up.
-class ClientInfoManager {
- public:
- static const InterfaceId kInterfaceId;
-
- explicit ClientInfoManager(ServiceLocator* service_locator);
-
- const ClientInfo& client_info();
-
- // Adds or subtracts from the amount of texture memory used.
- void AdjustTextureMemoryUsed(int amount) {
- client_info_.texture_memory_used_ += amount;
- DCHECK(client_info_.texture_memory_used_ >= 0);
- }
-
- // Adds or subtracts from the amount of texture memory used.
- void AdjustBufferMemoryUsed(int amount) {
- client_info_.buffer_memory_used_ += amount;
- DCHECK(client_info_.buffer_memory_used_ >= 0);
- }
-
- void SetSoftwareRenderer(bool used) {
- client_info_.software_renderer_ = used;
- }
-
- void SetNonPowerOfTwoTextures(bool npot) {
- client_info_.non_power_of_two_textures_ = npot;
- }
-
-private:
- ServiceImplementation<ClientInfoManager> service_;
-
- ClientInfo client_info_;
-
- DISALLOW_COPY_AND_ASSIGN(ClientInfoManager);
-};
-
-} // namespace o3d
-
-#endif // O3D_CORE_CROSS_CLIENT_INFO_H_
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file defines the ClientInfo class.
+
+#ifndef O3D_CORE_CROSS_CLIENT_INFO_H_
+#define O3D_CORE_CROSS_CLIENT_INFO_H_
+
+#include "core/cross/types.h"
+#include "core/cross/service_locator.h"
+#include "core/cross/service_implementation.h"
+
+namespace o3d {
+
+// This class is used to report infomation about the client.
+class ClientInfo {
+ public:
+ ClientInfo();
+
+ // The number of objects the client is currently tracking.
+ int num_objects() const {
+ return num_objects_;
+ }
+
+ // The amount of texture memory used.
+ int texture_memory_used() const {
+ return texture_memory_used_;
+ };
+
+ // The amount of texture memory used.
+ int buffer_memory_used() const {
+ return buffer_memory_used_;
+ }
+
+ // Whether or not we are using the software renderer.
+ bool software_renderer() const {
+ return software_renderer_;
+ }
+
+ // Whether or not the underlying GPU supports non power of 2 textures.
+ // NOTE: O3D always supports non power of 2 textures from a public API
+ // point of view and massages the data underneath to make this work.
+ // The point of this flag is mostly that if you are doing any kind of
+ // dynamic texture updating, like video, then you might want to use a
+ // power of two texture so O3D doesn't have to do extra work of converting
+ // your NPOT texture into a POT texture behind the scenes.
+ bool non_power_of_two_textures() const {
+ return non_power_of_two_textures_;
+ }
+
+ // Gets the O3D version.
+ const String& version() const {
+ return version_;
+ }
+
+ private:
+ friend class ClientInfoManager;
+
+ int num_objects_;
+ int texture_memory_used_;
+ int buffer_memory_used_;
+ bool software_renderer_;
+ bool non_power_of_two_textures_;
+ String version_;
+};
+
+// A class to manage the client info so other classes can easily look it up.
+class ClientInfoManager {
+ public:
+ static const InterfaceId kInterfaceId;
+
+ explicit ClientInfoManager(ServiceLocator* service_locator);
+
+ const ClientInfo& client_info();
+
+ // Adds or subtracts from the amount of texture memory used.
+ void AdjustTextureMemoryUsed(int amount) {
+ client_info_.texture_memory_used_ += amount;
+ DCHECK(client_info_.texture_memory_used_ >= 0);
+ }
+
+ // Adds or subtracts from the amount of texture memory used.
+ void AdjustBufferMemoryUsed(int amount) {
+ client_info_.buffer_memory_used_ += amount;
+ DCHECK(client_info_.buffer_memory_used_ >= 0);
+ }
+
+ void SetSoftwareRenderer(bool used) {
+ client_info_.software_renderer_ = used;
+ }
+
+ void SetNonPowerOfTwoTextures(bool npot) {
+ client_info_.non_power_of_two_textures_ = npot;
+ }
+
+private:
+ ServiceImplementation<ClientInfoManager> service_;
+
+ ClientInfo client_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClientInfoManager);
+};
+
+} // namespace o3d
+
+#endif // O3D_CORE_CROSS_CLIENT_INFO_H_
diff --git a/o3d/core/cross/gl/gl_headers.h b/o3d/core/cross/gl/gl_headers.h
index e800997..4716c54 100644
--- a/o3d/core/cross/gl/gl_headers.h
+++ b/o3d/core/cross/gl/gl_headers.h
@@ -1,43 +1,43 @@
-/*
- * Copyright 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef O3D_CORE_CROSS_GL_GL_HEADERS_H_
-#define O3D_CORE_CROSS_GL_GL_HEADERS_H_
-
-#include <GL/glew.h>
-#if defined(OS_WIN)
-#include <GL/wglew.h>
-#endif
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-#endif // O3D_CORE_CROSS_GL_GL_HEADERS_H_
-
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef O3D_CORE_CROSS_GL_GL_HEADERS_H_
+#define O3D_CORE_CROSS_GL_GL_HEADERS_H_
+
+#include <GL/glew.h>
+#if defined(OS_WIN)
+#include <GL/wglew.h>
+#endif
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
+
+#endif // O3D_CORE_CROSS_GL_GL_HEADERS_H_
+
diff --git a/o3d/core/cross/image_utils.h b/o3d/core/cross/image_utils.h
index ef3e75b..c9ee2d4 100644
--- a/o3d/core/cross/image_utils.h
+++ b/o3d/core/cross/image_utils.h
@@ -1,288 +1,288 @@
-/*
- * Copyright 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This file contains the declaration of functions to help with images.
-
-#ifndef O3D_CORE_CROSS_IMAGE_UTILS_H_
-#define O3D_CORE_CROSS_IMAGE_UTILS_H_
-
-#include "base/cross/bits.h"
-#include "core/cross/types.h"
-#include "core/cross/texture_base.h"
-
-namespace o3d {
-namespace image {
-
-// We will fail to load images that are bigger than 4kx4k to avoid security
-// risks. GPUs don't usually support bigger sizes anyway.
-// The biggest bitmap buffer size with these dimensions is:
-// 4k x 4k x 4xsizeof(float) x6 x4/3 (x6 for cube maps, x4/3 for mipmaps)
-// That makes 2GB, representable in an unsigned int, so we will avoid wraps.
-const unsigned int kMaxImageDimension = 4096u;
-
-enum ImageFileType {
- UNKNOWN,
- TGA,
- JPEG,
- PNG,
- DDS,
-};
-
-unsigned int GetNumComponentsForFormat(Texture::Format format);
-
-inline bool IsPOT(unsigned width, unsigned height) {
- return ((width & (width - 1)) == 0) && ((height & (height - 1)) == 0);
-}
-
-inline bool CheckImageDimensions(unsigned int width, unsigned int height) {
- return width <= kMaxImageDimension && height <= kMaxImageDimension;
-}
-
-// Returns whether or not we can make mips.
-bool CanMakeMips(Texture::Format format);
-
-// Gets the number of mip-maps required for a full chain starting at
-// width x height.
-inline unsigned int ComputeMipMapCount(
- unsigned int width, unsigned int height) {
- return 1 + base::bits::Log2Floor(std::max(width, height));
-}
-
-// Gets the smallest power-of-two value that is at least as high as
-// dimension. This is the POT dimension used in ScaleUpToPOT.
-inline unsigned int ComputePOTSize(unsigned int dimension) {
- return 1 << base::bits::Log2Ceiling(dimension);
-}
-
-// Computes one dimension of a mip.
-inline unsigned ComputeMipDimension(int level, unsigned dimension) {
- unsigned v = dimension >> level;
- return v > 0 ? v : 1u;
-}
-
-// Computes the size of the buffer containing a mip-map chain, given its base
-// width, height, format and number of mip-map levels.
-size_t ComputeMipChainSize(unsigned int base_width,
- unsigned int base_height,
- Texture::Format format,
- unsigned int num_mipmaps);
-
-inline int ComputePitch(Texture::Format format, unsigned width) {
- if (Texture::IsCompressedFormat(format)) {
- unsigned blocks_across = (width + 3u) / 4u;
- unsigned bytes_per_block = format == Texture::DXT1 ? 8u : 16u;
- return bytes_per_block * blocks_across;
- } else {
- return static_cast<int>(ComputeMipChainSize(width, 1u, format, 1u));
- }
-}
-
-// Computes the pitch for a bitmap.
-// NOTE: For textures you must get the pitch from the OS.
-inline int ComputeMipPitch(Texture::Format format,
- int level,
- unsigned width) {
- return ComputePitch(format, ComputeMipDimension(level, width));
-}
-
-// Computes the number of bytes of a bitmap pixel buffer.
-size_t ComputeBufferSize(unsigned int width,
- unsigned int height,
- Texture::Format format);
-
-// Crop part of an image from src, scale it to an arbitrary size
-// and paste in dest image. Utility function for all DrawImage
-// function in bitmap and textures. Scale operation is based on
-// Lanczos resampling.
-// Note: this doesn't work for DXTC.
-//
-// Parameters:
-// format: The format of the images.
-// src: source image which would be copied from.
-// src_pitch: The number of bytes per row in the src image.
-// src_x: x-coordinate of the starting pixel in the src image.
-// src_y: y-coordinate of the starting pixel in the src image.
-// src_width: width of the part in src image to be croped.
-// src_height: height of the part in src image to be croped.
-// dest: dest image which would be copied to.
-// dest_pitch: The number of bytes per row in the dest image.
-// dest_x: x-coordinate of the starting pixel in the dest image.
-// dest_y: y-coordinate of the starting pixel in the dest image.
-// dest_width: width of the part in dest image to be pasted to.
-// dest_height: height of the part in dest image to be pasted to.
-// components: number of components per pixel.
-void LanczosScale(Texture::Format format,
- const void* src, int src_pitch,
- int src_x, int src_y,
- int src_width, int src_height,
- void* dest, int dest_pitch,
- int dest_x, int dest_y,
- int dest_width, int dest_height,
- int components);
-
-// Detects the type of image file based on the filename.
-ImageFileType GetFileTypeFromFilename(const char *filename);
-//
-// Detects the type of image file based on the mime-type.
-ImageFileType GetFileTypeFromMimeType(const char *mime_type);
-
-// Adds filler alpha byte (0xff) after every pixel. Assumes buffer was
-// allocated with enough storage)
-// can convert RGB -> RGBA, BGR -> BGRA, etc.
-void XYZToXYZA(uint8 *image_data, int pixel_count);
-
-// Swaps Red and Blue components in the image.
-void RGBAToBGRA(uint8 *image_data, int pixel_count);
-
-// Generates a mip-map for 1 level.
-// NOTE: this doesn't work for DXTC images.
-//
-// Parameters:
-// src_width: the width of the source image.
-// src_height: the height of the source image.
-// format: the format of the data.
-// src_data: the data containing the src image.
-// src_pitch: If the format is uncompressed this is the number of bytes
-// per row of pixels. If compressed this value is unused.
-// dst_data: memory for a mip one level smaller then the source.
-// dst_pitch: If the format is uncompressed this is the number of bytes
-// per row of pixels. If compressed this value is unused.
-bool GenerateMipmap(unsigned int src_width,
- unsigned int src_height,
- Texture::Format format,
- const void *src_data,
- int src_pitch,
- void *dst_data,
- int dst_pitch);
-
-// Scales an image up to power-of-two textures, using point filtering.
-// NOTE: this doesn't work for DXTC images.
-//
-// Parameters:
-// width: the non-power-of-two width of the original image.
-// height: the non-power-of-two height of the original image.
-// format: the format of the data.
-// src: the data containing the source data of the original image.
-// dst: a buffer with enough space for the power-of-two version. Pixels are
-// written from the end to the beginning so dst can be the same buffer
-// as src.
-// dst_pitch: Number of bytes across 1 row of pixels.
-bool ScaleUpToPOT(unsigned int width,
- unsigned int height,
- Texture::Format format,
- const void *src,
- void *dst,
- int dst_pitch);
-
-// Scales an image to an arbitrary size, using point filtering.
-// NOTE: this doesn't work for DXTC images.
-//
-// Parameters:
-// src_width: the width of the original image.
-// src_height: the height of the original image.
-// format: the format of the data.
-// src: the data containing the source data of the original image.
-// dst_width: the width of the target image.
-// dst_height: the height of the target image.
-// dst: a buffer with enough space for the target version. Pixels are
-// written from the end to the beginning so dst can be the same buffer
-// as src if the transformation is an upscaling.
-// dst_pitch: Number of bytes across 1 row of pixels.
-bool Scale(unsigned int src_width,
- unsigned int src_height,
- Texture::Format format,
- const void *src,
- unsigned int dst_width,
- unsigned int dst_height,
- void *dst,
- int dst_pitch);
-
-// adjust start points and boundaries when using DrawImage data
-// in bitmap and textures.
-// Parameters:
-// src_x: x-coordinate of the starting pixel in the source image.
-// src_y: y-coordinate of the starting pixel in the source image.
-// src_width: width of the source image to draw.
-// src_height: height of the source image to draw.
-// src_bmp_level: which mip in source.
-// src_bmp_width: original width of source bitmap.
-// src_bmp_height: original height of source bitmap.
-// dest_x: x-coordinate of the starting pixel in the dest image.
-// dest_y: y-coordinate of the starting pixel in the dest image.
-// dest_width: width of the dest image to draw.
-// dest_height: height of the dest image to draw.
-// dest_bmp_level: which mip in dest.
-// dest_bmp_width: original width of dest bitmap.
-// dest_bmp_height: original height of dest bitmap.
-// Returns:
-// false if src or dest rectangle is out of boundaries.
-bool AdjustDrawImageBoundary(int* src_x, int* src_y,
- int* src_width, int* src_height,
- int src_level,
- int src_bmp_width, int src_bmp_height,
- int* dest_x, int* dest_y,
- int* dest_width, int* dest_height,
- int dest_level,
- int dest_bmp_width, int dest_bmp_height);
-
-// Checks whether or not we can call SetRect and adjust the inputs
-// accordingly so SetRect will work.
-//
-// Assumes that both the source and destination rectangles are within the
-// bounds of their respective images.
-//
-// Parameters:
-// src_y: A pointer to an int holding the Y position of the source
-// rect. Will be adjusted if SetRect can be called.
-// src_width: The width of the source rect.
-// src_height: The height of the source rect.
-// src_pitch: A pointer to an int holding the pitch of the source. Will be
-// adjusted if SetRect can be called.
-// dst_y: A pointer to an int holding the Y position of the dest rect. Will be
-// adjusted if SetRect can be called.
-// dst_width: The width of the dest rect.
-// dst_height: A pointer to an int holding the height of the dest rect. Will
-// adjusted if SetRect can be called.
-// Returns:
-// True if SetRect can be called.
-bool AdjustForSetRect(int* src_y,
- int src_width,
- int src_height,
- int* src_pitch,
- int* dst_y,
- int dst_width,
- int* dst_height);
-
-} // namespace image
-} // namespace o3d
-
-#endif // O3D_CORE_CROSS_IMAGE_UTILS_H_
-
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file contains the declaration of functions to help with images.
+
+#ifndef O3D_CORE_CROSS_IMAGE_UTILS_H_
+#define O3D_CORE_CROSS_IMAGE_UTILS_H_
+
+#include "base/cross/bits.h"
+#include "core/cross/types.h"
+#include "core/cross/texture_base.h"
+
+namespace o3d {
+namespace image {
+
+// We will fail to load images that are bigger than 4kx4k to avoid security
+// risks. GPUs don't usually support bigger sizes anyway.
+// The biggest bitmap buffer size with these dimensions is:
+// 4k x 4k x 4xsizeof(float) x6 x4/3 (x6 for cube maps, x4/3 for mipmaps)
+// That makes 2GB, representable in an unsigned int, so we will avoid wraps.
+const unsigned int kMaxImageDimension = 4096u;
+
+enum ImageFileType {
+ UNKNOWN,
+ TGA,
+ JPEG,
+ PNG,
+ DDS,
+};
+
+unsigned int GetNumComponentsForFormat(Texture::Format format);
+
+inline bool IsPOT(unsigned width, unsigned height) {
+ return ((width & (width - 1)) == 0) && ((height & (height - 1)) == 0);
+}
+
+inline bool CheckImageDimensions(unsigned int width, unsigned int height) {
+ return width <= kMaxImageDimension && height <= kMaxImageDimension;
+}
+
+// Returns whether or not we can make mips.
+bool CanMakeMips(Texture::Format format);
+
+// Gets the number of mip-maps required for a full chain starting at
+// width x height.
+inline unsigned int ComputeMipMapCount(
+ unsigned int width, unsigned int height) {
+ return 1 + base::bits::Log2Floor(std::max(width, height));
+}
+
+// Gets the smallest power-of-two value that is at least as high as
+// dimension. This is the POT dimension used in ScaleUpToPOT.
+inline unsigned int ComputePOTSize(unsigned int dimension) {
+ return 1 << base::bits::Log2Ceiling(dimension);
+}
+
+// Computes one dimension of a mip.
+inline unsigned ComputeMipDimension(int level, unsigned dimension) {
+ unsigned v = dimension >> level;
+ return v > 0 ? v : 1u;
+}
+
+// Computes the size of the buffer containing a mip-map chain, given its base
+// width, height, format and number of mip-map levels.
+size_t ComputeMipChainSize(unsigned int base_width,
+ unsigned int base_height,
+ Texture::Format format,
+ unsigned int num_mipmaps);
+
+inline int ComputePitch(Texture::Format format, unsigned width) {
+ if (Texture::IsCompressedFormat(format)) {
+ unsigned blocks_across = (width + 3u) / 4u;
+ unsigned bytes_per_block = format == Texture::DXT1 ? 8u : 16u;
+ return bytes_per_block * blocks_across;
+ } else {
+ return static_cast<int>(ComputeMipChainSize(width, 1u, format, 1u));
+ }
+}
+
+// Computes the pitch for a bitmap.
+// NOTE: For textures you must get the pitch from the OS.
+inline int ComputeMipPitch(Texture::Format format,
+ int level,
+ unsigned width) {
+ return ComputePitch(format, ComputeMipDimension(level, width));
+}
+
+// Computes the number of bytes of a bitmap pixel buffer.
+size_t ComputeBufferSize(unsigned int width,
+ unsigned int height,
+ Texture::Format format);
+
+// Crop part of an image from src, scale it to an arbitrary size
+// and paste in dest image. Utility function for all DrawImage
+// function in bitmap and textures. Scale operation is based on
+// Lanczos resampling.
+// Note: this doesn't work for DXTC.
+//
+// Parameters:
+// format: The format of the images.
+// src: source image which would be copied from.
+// src_pitch: The number of bytes per row in the src image.
+// src_x: x-coordinate of the starting pixel in the src image.
+// src_y: y-coordinate of the starting pixel in the src image.
+// src_width: width of the part in src image to be croped.
+// src_height: height of the part in src image to be croped.
+// dest: dest image which would be copied to.
+// dest_pitch: The number of bytes per row in the dest image.
+// dest_x: x-coordinate of the starting pixel in the dest image.
+// dest_y: y-coordinate of the starting pixel in the dest image.
+// dest_width: width of the part in dest image to be pasted to.
+// dest_height: height of the part in dest image to be pasted to.
+// components: number of components per pixel.
+void LanczosScale(Texture::Format format,
+ const void* src, int src_pitch,
+ int src_x, int src_y,
+ int src_width, int src_height,
+ void* dest, int dest_pitch,
+ int dest_x, int dest_y,
+ int dest_width, int dest_height,
+ int components);
+
+// Detects the type of image file based on the filename.
+ImageFileType GetFileTypeFromFilename(const char *filename);
+//
+// Detects the type of image file based on the mime-type.
+ImageFileType GetFileTypeFromMimeType(const char *mime_type);
+
+// Adds filler alpha byte (0xff) after every pixel. Assumes buffer was
+// allocated with enough storage)
+// can convert RGB -> RGBA, BGR -> BGRA, etc.
+void XYZToXYZA(uint8 *image_data, int pixel_count);
+
+// Swaps Red and Blue components in the image.
+void RGBAToBGRA(uint8 *image_data, int pixel_count);
+
+// Generates a mip-map for 1 level.
+// NOTE: this doesn't work for DXTC images.
+//
+// Parameters:
+// src_width: the width of the source image.
+// src_height: the height of the source image.
+// format: the format of the data.
+// src_data: the data containing the src image.
+// src_pitch: If the format is uncompressed this is the number of bytes
+// per row of pixels. If compressed this value is unused.
+// dst_data: memory for a mip one level smaller then the source.
+// dst_pitch: If the format is uncompressed this is the number of bytes
+// per row of pixels. If compressed this value is unused.
+bool GenerateMipmap(unsigned int src_width,
+ unsigned int src_height,
+ Texture::Format format,
+ const void *src_data,
+ int src_pitch,
+ void *dst_data,
+ int dst_pitch);
+
+// Scales an image up to power-of-two textures, using point filtering.
+// NOTE: this doesn't work for DXTC images.
+//
+// Parameters:
+// width: the non-power-of-two width of the original image.
+// height: the non-power-of-two height of the original image.
+// format: the format of the data.
+// src: the data containing the source data of the original image.
+// dst: a buffer with enough space for the power-of-two version. Pixels are
+// written from the end to the beginning so dst can be the same buffer
+// as src.
+// dst_pitch: Number of bytes across 1 row of pixels.
+bool ScaleUpToPOT(unsigned int width,
+ unsigned int height,
+ Texture::Format format,
+ const void *src,
+ void *dst,
+ int dst_pitch);
+
+// Scales an image to an arbitrary size, using point filtering.
+// NOTE: this doesn't work for DXTC images.
+//
+// Parameters:
+// src_width: the width of the original image.
+// src_height: the height of the original image.
+// format: the format of the data.
+// src: the data containing the source data of the original image.
+// dst_width: the width of the target image.
+// dst_height: the height of the target image.
+// dst: a buffer with enough space for the target version. Pixels are
+// written from the end to the beginning so dst can be the same buffer
+// as src if the transformation is an upscaling.
+// dst_pitch: Number of bytes across 1 row of pixels.
+bool Scale(unsigned int src_width,
+ unsigned int src_height,
+ Texture::Format format,
+ const void *src,
+ unsigned int dst_width,
+ unsigned int dst_height,
+ void *dst,
+ int dst_pitch);
+
+// adjust start points and boundaries when using DrawImage data
+// in bitmap and textures.
+// Parameters:
+// src_x: x-coordinate of the starting pixel in the source image.
+// src_y: y-coordinate of the starting pixel in the source image.
+// src_width: width of the source image to draw.
+// src_height: height of the source image to draw.
+// src_bmp_level: which mip in source.
+// src_bmp_width: original width of source bitmap.
+// src_bmp_height: original height of source bitmap.
+// dest_x: x-coordinate of the starting pixel in the dest image.
+// dest_y: y-coordinate of the starting pixel in the dest image.
+// dest_width: width of the dest image to draw.
+// dest_height: height of the dest image to draw.
+// dest_bmp_level: which mip in dest.
+// dest_bmp_width: original width of dest bitmap.
+// dest_bmp_height: original height of dest bitmap.
+// Returns:
+// false if src or dest rectangle is out of boundaries.
+bool AdjustDrawImageBoundary(int* src_x, int* src_y,
+ int* src_width, int* src_height,
+ int src_level,
+ int src_bmp_width, int src_bmp_height,
+ int* dest_x, int* dest_y,
+ int* dest_width, int* dest_height,
+ int dest_level,
+ int dest_bmp_width, int dest_bmp_height);
+
+// Checks whether or not we can call SetRect and adjust the inputs
+// accordingly so SetRect will work.
+//
+// Assumes that both the source and destination rectangles are within the
+// bounds of their respective images.
+//
+// Parameters:
+// src_y: A pointer to an int holding the Y position of the source
+// rect. Will be adjusted if SetRect can be called.
+// src_width: The width of the source rect.
+// src_height: The height of the source rect.
+// src_pitch: A pointer to an int holding the pitch of the source. Will be
+// adjusted if SetRect can be called.
+// dst_y: A pointer to an int holding the Y position of the dest rect. Will be
+// adjusted if SetRect can be called.
+// dst_width: The width of the dest rect.
+// dst_height: A pointer to an int holding the height of the dest rect. Will
+// adjusted if SetRect can be called.
+// Returns:
+// True if SetRect can be called.
+bool AdjustForSetRect(int* src_y,
+ int src_width,
+ int src_height,
+ int* src_pitch,
+ int* dst_y,
+ int dst_width,
+ int* dst_height);
+
+} // namespace image
+} // namespace o3d
+
+#endif // O3D_CORE_CROSS_IMAGE_UTILS_H_
+
diff --git a/o3d/core/cross/pointer_utils.h b/o3d/core/cross/pointer_utils.h
index e246deb..b94bff9 100644
--- a/o3d/core/cross/pointer_utils.h
+++ b/o3d/core/cross/pointer_utils.h
@@ -1,58 +1,58 @@
-/*
- * Copyright 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This file contains the declaration for a few templated function to help with
-// pointers.
-
-#ifndef O3D_CORE_CROSS_POINTER_UTILS_H_
-#define O3D_CORE_CROSS_POINTER_UTILS_H_
-
-#include "core/cross/types.h"
-
-namespace o3d {
-
-// Adds an arbitrary byte offset to a typed pointer.
-template <typename T>
-T AddPointerOffset(T pointer, int offset) {
- return reinterpret_cast<T>(
- const_cast<uint8*>(reinterpret_cast<const uint8*>(pointer) + offset));
-}
-
-// Creates a typed pointer from a void pointer and an offset.
-template <typename T>
-T PointerFromVoidPointer(const void* pointer, int offset) {
- return reinterpret_cast<T>(
- const_cast<uint8*>(reinterpret_cast<const uint8*>(pointer) + offset));
-}
-
-} // namespace o3d
-
-#endif // O3D_CORE_CROSS_POINTER_UTILS_H_
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file contains the declaration for a few templated function to help with
+// pointers.
+
+#ifndef O3D_CORE_CROSS_POINTER_UTILS_H_
+#define O3D_CORE_CROSS_POINTER_UTILS_H_
+
+#include "core/cross/types.h"
+
+namespace o3d {
+
+// Adds an arbitrary byte offset to a typed pointer.
+template <typename T>
+T AddPointerOffset(T pointer, int offset) {
+ return reinterpret_cast<T>(
+ const_cast<uint8*>(reinterpret_cast<const uint8*>(pointer) + offset));
+}
+
+// Creates a typed pointer from a void pointer and an offset.
+template <typename T>
+T PointerFromVoidPointer(const void* pointer, int offset) {
+ return reinterpret_cast<T>(
+ const_cast<uint8*>(reinterpret_cast<const uint8*>(pointer) + offset));
+}
+
+} // namespace o3d
+
+#endif // O3D_CORE_CROSS_POINTER_UTILS_H_
diff --git a/o3d/core/win/d3d9/software_renderer_d3d9.h b/o3d/core/win/d3d9/software_renderer_d3d9.h
index fcfa8ef..5c7cdfc 100644
--- a/o3d/core/win/d3d9/software_renderer_d3d9.h
+++ b/o3d/core/win/d3d9/software_renderer_d3d9.h
@@ -38,7 +38,7 @@ namespace o3d {
// Not implemented.
inline bool SetupSoftwareRenderer(IDirect3D9* d3d) {
- return false;
+ return false;
}
} // namespace o3d