diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:12:50 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:12:50 +0000 |
commit | ed97932b6ec58d01baea6948d5506503247f2986 (patch) | |
tree | 19ae1cfc4de8ce29ba75ab0386d1f56a1bacf57a /o3d/plugin/idl | |
parent | f963b1d5006ed35450befe042bf58810d9d36bea (diff) | |
download | chromium_src-ed97932b6ec58d01baea6948d5506503247f2986.zip chromium_src-ed97932b6ec58d01baea6948d5506503247f2986.tar.gz chromium_src-ed97932b6ec58d01baea6948d5506503247f2986.tar.bz2 |
Changes to Bitmap before exposing to JavaScript
This CL changes Bitmap to no longer be a cubemap.
Instead there is a function, Pack::CreateBitmapsFromRawData
that returns an array of bitmaps.
For a 2D image 1 bitmap is returned
For a cubemap 6 bitmaps are returned
eventually for a volumemap N bitmaps will be returned.
To distinguish between 6 bitmaps that are a cubemap
and 6 bitmaps that are slices of a volumemap there
is a Bitmap::semantic which tells what the bitmap is
intended for.
In a previous CL I had started to break Bitmap into
classes like Bitmap8, BitmapFloat, BitmapDXT1.
These were not intended to be exposed to JavaScript,
only to make the internal code get rid of lots of
if format == or case(format) stuff.
But given that it's working as is and there are more
pressing things I'm not planning to do that right now.
I can delete the classes if you think I should.
Note: This is still not 100% done. I still need to
deal with the flipping issues or at least test.
I probably need to add more tests as well.
I also got rid of any mention of resize_to_pot in
the command buffer version. Client side command
buffer should not have to deal with POT/NPOT issues.
I also moved the pot/npot stuff out of generic code
and into the platform specific code. The generic code
is not supposed to care.
This is slower than the old way but it feels cleaner.
A few issues I'm looking for input on. There's
a function, Bitmap::GenerateMips(source_level, num_levels).
It generates mips as long as they 8Bit textures.
I can easily add half and float but not DXT. Right now
if you call it on DXT in debug it prints a LOG message
but otherwise it does nothing. Should I error for DXT?
On the one hand it would be good to know that it failed
so a user will not be wondering "I called it, why are
there no mips?"
On the otherhand, from JavaScript failing would mean
you'd need to check the format before calling it which
also seems less then ideal.
The other is that currently it doesn't ADD mips, it just
replaces the ones that are there. That means if you load
a 2d image and want mips you have to allocate a new bitmap
with the number of mips you want, copy level 0 from the
old bitmap to the new bitmap and then generate mips
Should I make generate mips effectively do that for you?
Basically, if you call it to generate mips on levels
that don't yet exist in the bitmap it would realloc itself
and then generate them. Is that better?
Also, I started down the path of taking out alpha_is_one.
I'm trying to decide what to do with it. Part of me wants
to take it out completely but since it's already there
maybe I can't.
If I leave it in I was thinking of making it check every
time it's called. First I'd just make it slow. Then later
if we want I could add a dirty flag and only recheck when
it's dirty. That would be a lot of work though. It would
mean wrapping Lock and SetRect and maybe a few other things
so that we could catch any writes to the texture. It might
also mean changing Lock to take read/write flags. I think
those are good changes but again, it's not important right
now. So, the question is what to do now. I can
1) Remove alpha_is_one. That might break something out there
2) Leave it in but just have it always false.
3) Make it check every time it's accessed.
4) Do the dirty flag thing.
Preference? I'm for 2 or 3 I think.
Review URL: http://codereview.chromium.org/164235
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin/idl')
-rw-r--r-- | o3d/plugin/idl/bitmap.idl | 37 | ||||
-rw-r--r-- | o3d/plugin/idl/pack.idl | 3 | ||||
-rw-r--r-- | o3d/plugin/idl/texture.idl | 62 |
3 files changed, 73 insertions, 29 deletions
diff --git a/o3d/plugin/idl/bitmap.idl b/o3d/plugin/idl/bitmap.idl index a223f43..76cca4c 100644 --- a/o3d/plugin/idl/bitmap.idl +++ b/o3d/plugin/idl/bitmap.idl @@ -34,15 +34,40 @@ 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.
+ including scale and crop. A Bitmap can be created from RawData via
+ pack.createBitmapsFromRawData(), and also can be transferred to mip of a
+ Texure2D or a specific face of TextureCUBE via methods in Texture.
%]
[nocpp, include="core/cross/bitmap.h"]
class Bitmap : ParamObject {
%[
+ After loading an array of Bitmaps with pack.createBitmapsFromRawData
+ you can inspect their semantic to see what they were intended for. This is
+ mostly to distinguish between 6 bitmaps that are faces of a cubemap and 6
+ bitmaps that are slices of a 3d texture.
+
+ \li FACE_POSITIVE_X, 1 face of a cubemap
+ \li FACE_NEGATIVE_X, 1 face of a cubemap
+ \li FACE_POSITIVE_Y, 1 face of a cubemap
+ \li FACE_NEGATIVE_Y, 1 face of a cubemap
+ \li FACE_POSITIVE_Z, 1 face of a cubemap
+ \li FACE_NEGATIVE_Z, 1 face of a cubemap
+ \li IMAGE, normal 2d image
+ \li SLICE, a slice of a 3d texture.
+ %]
+ enum Semantic {
+ FACE_POSITIVE_X,
+ FACE_NEGATIVE_X,
+ FACE_POSITIVE_Y,
+ FACE_NEGATIVE_Y,
+ FACE_POSITIVE_Z,
+ FACE_NEGATIVE_Z,
+ IMAGE,
+ SLICE
+ };
+
+ %[
Flips a bitmap vertically in place.
%]
void FlipVertically();
@@ -78,9 +103,9 @@ class Bitmap : ParamObject { [getter] int num_mipmaps_;
%[
- Whether or not the bitmap is a cubemap.
+ The Semantic of the bitmap.
%]
- [getter] bool is_cubemap_;
+ [getter] Semantic semantic_;
}; // Bitmap
} // namespace o3d
diff --git a/o3d/plugin/idl/pack.idl b/o3d/plugin/idl/pack.idl index a6a46aa..6880aed 100644 --- a/o3d/plugin/idl/pack.idl +++ b/o3d/plugin/idl/pack.idl @@ -322,8 +322,7 @@ typedef Bitmap[] BitmapArray; \param raw_data contains the bitmap data in a supported format. \return An Array of Bitmaps object. %] - //BitmapArray CreateBitmapsFromRawData(RawData raw_data); - Bitmap CreateBitmapFromRawData(RawData raw_data); + BitmapArray CreateBitmapsFromRawData(RawData raw_data); }; // Pack } // namespace o3d diff --git a/o3d/plugin/idl/texture.idl b/o3d/plugin/idl/texture.idl index d74a386..dcaf4e7 100644 --- a/o3d/plugin/idl/texture.idl +++ b/o3d/plugin/idl/texture.idl @@ -115,21 +115,6 @@ namespace o3d { %] 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 %[ @@ -238,6 +223,22 @@ namespace o3d { int height); %[ + 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::Texture2D* self, + o3d::Bitmap* bitmap) { + self->SetFromBitmap(*bitmap); + } + %} + + %[ Copy pixels from source bitmap to certain mip level. Scales if the width and height of source and dest do not match. @@ -294,12 +295,13 @@ namespace o3d { The names of each of the six faces of a cube map texture. %] - enum CubeFace { FACE_POSITIVE_X, - FACE_NEGATIVE_X, - FACE_POSITIVE_Y, - FACE_NEGATIVE_Y, - FACE_POSITIVE_Z, - FACE_NEGATIVE_Z }; + enum CubeFace { + FACE_POSITIVE_X, + FACE_NEGATIVE_X, + FACE_POSITIVE_Y, + FACE_NEGATIVE_Y, + FACE_POSITIVE_Z, + FACE_NEGATIVE_Z }; %[ The length of each edge of the cube, in texels. @@ -382,6 +384,24 @@ namespace o3d { int height); %[ + Sets the content of a face of the texture to the content of the bitmap. The + texture and the bitmap must be the same dimensions and the same format. + + \param face The face to set. + \param bitmap The bitmap to copy data from. + %] + [userglue] + void SetFromBitmap(CubeFace face, Bitmap bitmap); + + [verbatim=cpp_glue] %{ + void userglue_method_SetFromBitmap(o3d::TextureCUBE* self, + o3d::TextureCUBE::CubeFace face, + o3d::Bitmap* bitmap) { + self->SetFromBitmap(face, *bitmap); + } + %} + + %[ Copy pixels from source bitmap to certain mip level. Scales if the width and height of source and dest do not match. |