summaryrefslogtreecommitdiffstats
path: root/o3d/plugin
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 04:53:24 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 04:53:24 +0000
commit132899b905b0f1794d7e82e28f9fe77ca6a08282 (patch)
tree47af391191ac78d3b4e02533f74e3575970cebcc /o3d/plugin
parent22e037073118aaf90549410b32d66885d39b78a9 (diff)
downloadchromium_src-132899b905b0f1794d7e82e28f9fe77ca6a08282.zip
chromium_src-132899b905b0f1794d7e82e28f9fe77ca6a08282.tar.gz
chromium_src-132899b905b0f1794d7e82e28f9fe77ca6a08282.tar.bz2
A step in exposing Bitmap to JavaScript.
The plan is to make pack.createBitmapFromRawData return an array of bitmaps. 1 bitmap if it's a standard 2d image 6 bitmaps if it's a cubemap N bitmaps if it's a volume map. The bitmaps will have a semantic so you can look at them and tell they were from a volumemap, a cubemap or a 2d image. On the way I'm attempting to clean up the code. Moving stuff out of Bitmap the did not belong there and Refactoring Bitmap so there are less If Format = stuff. Review URL: http://codereview.chromium.org/164034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin')
-rw-r--r--o3d/plugin/cross/async_loading.cc4
-rw-r--r--o3d/plugin/cross/o3d_glue.h1
-rw-r--r--o3d/plugin/idl/bitmap.idl62
-rw-r--r--o3d/plugin/idl/texture.idl54
4 files changed, 85 insertions, 36 deletions
diff --git a/o3d/plugin/cross/async_loading.cc b/o3d/plugin/cross/async_loading.cc
index f38ef5d..dfcbcfe 100644
--- a/o3d/plugin/cross/async_loading.cc
+++ b/o3d/plugin/cross/async_loading.cc
@@ -90,8 +90,8 @@ class LoadTextureURLCallback : public StreamManager::FinishedCallback {
// Unfortunately, TGA and DDS don't have standard MIME type, so we may
// have to rely on the filename, or let the image loader figure it out by
// itself (by trying every possible type).
- Bitmap::ImageFileType image_type =
- Bitmap::GetFileTypeFromMimeType(mime_type.c_str());
+ o3d::image::ImageFileType image_type =
+ o3d::image::GetFileTypeFromMimeType(mime_type.c_str());
texture = Texture::Ref(
request_->pack()->CreateTextureFromFile(
request_->uri(),
diff --git a/o3d/plugin/cross/o3d_glue.h b/o3d/plugin/cross/o3d_glue.h
index c318ea5..6143db2 100644
--- a/o3d/plugin/cross/o3d_glue.h
+++ b/o3d/plugin/cross/o3d_glue.h
@@ -60,6 +60,7 @@
#include "core/cross/evaluation_counter.h"
#include "core/cross/class_manager.h"
#include "core/cross/client_info.h"
+#include "core/cross/cursor.h"
#include "core/cross/features.h"
#include "core/cross/object_manager.h"
#include "core/cross/error.h"
diff --git a/o3d/plugin/idl/bitmap.idl b/o3d/plugin/idl/bitmap.idl
index 066ca5a..a223f43 100644
--- a/o3d/plugin/idl/bitmap.idl
+++ b/o3d/plugin/idl/bitmap.idl
@@ -33,49 +33,29 @@
namespace o3d {
%[
-Bitmap provides an interface for basic image operations on bitmap,
-including scale and crop. The contents of bitmap can be created from
-RawData via pack.createBitmapFromRawData(), and also can be transfered
-to mip of a Texure2D or a specific face of TextureCUBE via methods
-in Texture.
+ Bitmap provides an interface for basic image operations on bitmap,
+ including scale and crop. The contents of bitmap can be created from
+ RawData via pack.createBitmapFromRawData(), and also can be transfered
+ to mip of a Texure2D or a specific face of TextureCUBE via methods
+ in Texture.
%]
[nocpp, include="core/cross/bitmap.h"]
class Bitmap : ParamObject {
%[
- enum ImageFileType {
- \li UNKNOWN, Image type unknown.
- \li TGA, image in TGA format.
- \li JPEG, image in JPEG format.
- \li PNG, image in PNG format.
- \li DDS, image in DDS format.
- };
+ Flips a bitmap vertically in place.
%]
- enum ImageFileType {
- UNKNOWN,
- TGA,
- JPEG,
- PNG,
- DDS
- };
+ void FlipVertically();
%[
- Copy pixels from source bitmap. Scales if the width and height of source
- and dest do not match.
- \param source_img source bitmap which would be drawn.
- \param source_x x-coordinate of the starting pixel in the source image.
- \param source_y y-coordinate of the starting pixel in the source image.
- \param source_width width of the source image to draw.
- \param source_height Height of the source image to draw.
- \param dest_x x-coordinate of the starting pixel in the dest image.
- \param dest_y y-coordinate of the starting pixel in the dest image.
- \param dest_width width of the dest image to draw.
- \param dest_height height of the dest image to draw.
+ Generates mip maps from the source level to lower levels.
+
+ You can currently only use this on XRGB8 and ARGB8 textures.
+
+ \param source_level The level to use as the source of the mips.
+ \param num_levels The number of levels to generate below the source level.
%]
- void DrawImage(Bitmap source_img, int source_x, int source_y,
- int source_width, int source_height,
- int dest_x, int dest_y,
- int dest_width, int dest_height);
+ void GenerateMips(int source_level, int num_levels);
%[
The width of the bitmap (read only).
@@ -87,6 +67,20 @@ class Bitmap : ParamObject {
%]
[getter] int height_;
+ %[
+ The format of the bitmap (read only).
+ %]
+ [getter] Texture::Format format_;
+
+ %[
+ Number mip-maps (read only)
+ %]
+ [getter] int num_mipmaps_;
+
+ %[
+ Whether or not the bitmap is a cubemap.
+ %]
+ [getter] bool is_cubemap_;
}; // Bitmap
} // namespace o3d
diff --git a/o3d/plugin/idl/texture.idl b/o3d/plugin/idl/texture.idl
index 763518e..54b705c 100644
--- a/o3d/plugin/idl/texture.idl
+++ b/o3d/plugin/idl/texture.idl
@@ -107,6 +107,29 @@ namespace o3d {
True of all the alpha values in the texture are 1.0
%]
[getter, getter, setter] bool alpha_is_one;
+
+ %[
+ Generates Mips.
+ \param source_level the mip to use as the source.
+ \param num_levels the number of mips from the source to generate.
+ %]
+ void GenerateMips(int source_level, int num_levels);
+
+ %[
+ Sets the content of the texture to the content of the bitmap. The texture
+ and the bitmap must be the same dimensions and the same format.
+
+ \param bitmap The bitmap to copy data from.
+ %]
+ [userglue]
+ void SetFromBitmap(Bitmap bitmap);
+
+ [verbatim=cpp_glue] %{
+ void userglue_method_SetFromBitmap(o3d::Texture* self,
+ o3d::Bitmap* bitmap) {
+ self->SetFromBitmap(*bitmap);
+ }
+ %}
}; // Texture
%[
@@ -209,10 +232,25 @@ namespace o3d {
\param dest_height height of the dest image.
\param dest_mip on which mip level the sourceImg would be drawn.
%]
+ [userglue]
void DrawImage(Bitmap source_img, int source_x, int source_y,
int source_width, int source_height,
int dest_x, int dest_y,
int dest_width, int dest_height, int dest_mip);
+
+ [verbatim=cpp_glue] %{
+ void userglue_method_DrawImage(
+ o3d::Texture2D* self,
+ o3d::Bitmap* source_img, int source_x, int source_y,
+ int source_width, int source_height,
+ int dest_x, int dest_y,
+ int dest_width, int dest_height, int dest_mip) {
+ self->DrawImage(*source_img, source_x, source_y,
+ source_width, source_height,
+ dest_x, dest_y,
+ dest_width, dest_height, dest_mip);
+ }
+%}
}; // Texture2D
@@ -317,11 +355,27 @@ namespace o3d {
\param face on which face the sourceImg would be drawn.
\param dest_mip on which mip level the sourceImg would be drawn.
%]
+ [userglue]
void DrawImage(Bitmap source_img, int source_x, int source_y,
int source_width, int source_height,
int dest_x, int dest_y,
int dest_width, int dest_height,
CubeFace face, int dest_mip);
+
+ [verbatim=cpp_glue] %{
+ void userglue_method_DrawImage(
+ o3d::TextureCUBE* self,
+ o3d::Bitmap* source_img, int source_x, int source_y,
+ int source_width, int source_height,
+ int dest_x, int dest_y,
+ int dest_width, int dest_height,
+ o3d::TextureCUBE::CubeFace dest_face, int dest_mip) {
+ self->DrawImage(*source_img, source_x, source_y,
+ source_width, source_height,
+ dest_x, dest_y,
+ dest_width, dest_height, dest_face, dest_mip);
+ }
+ %}
}; // TextureCUBE
} // namespace o3d