Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Unified Diff: core/win/d3d9/texture_d3d9.cc

Issue 150058: expose bitmap in js. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/win/d3d9/texture_d3d9.h ('k') | plugin/idl/bitmap.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/win/d3d9/texture_d3d9.cc
===================================================================
--- core/win/d3d9/texture_d3d9.cc (revision 20557)
+++ core/win/d3d9/texture_d3d9.cc (working copy)
@@ -231,6 +231,7 @@
enable_render_surfaces),
d3d_texture_(tex) {
DCHECK(tex);
+ backing_bitmap_ = Bitmap::Ref(new Bitmap(service_locator));
}
// Attempts to create a IDirect3DTexture9 with the given specs. If the creation
@@ -263,8 +264,8 @@
resize_to_pot,
enable_render_surfaces);
- texture->backing_bitmap_.SetFrom(bitmap);
- if (texture->backing_bitmap_.image_data()) {
+ texture->backing_bitmap_->SetFrom(bitmap);
+ if (texture->backing_bitmap_->image_data()) {
for (unsigned int i = 0; i < bitmap->num_mipmaps(); ++i) {
if (!texture->UpdateBackedMipLevel(i)) {
DLOG(ERROR) << "Failed to upload bitmap to texture.";
@@ -275,12 +276,12 @@
mip_height = std::max(1U, mip_height >> 1);
}
if (!resize_to_pot)
- texture->backing_bitmap_.FreeData();
+ texture->backing_bitmap_->FreeData();
} else {
if (resize_to_pot) {
- texture->backing_bitmap_.AllocateData();
- memset(texture->backing_bitmap_.image_data(), 0,
- texture->backing_bitmap_.GetTotalSize());
+ texture->backing_bitmap_->AllocateData();
+ memset(texture->backing_bitmap_->image_data(), 0,
+ texture->backing_bitmap_->GetTotalSize());
}
}
@@ -294,11 +295,11 @@
bool Texture2DD3D9::UpdateBackedMipLevel(unsigned int level) {
DCHECK_LT(level, static_cast<unsigned int>(levels()));
- DCHECK(backing_bitmap_.image_data());
- DCHECK_EQ(backing_bitmap_.width(), width());
- DCHECK_EQ(backing_bitmap_.height(), height());
- DCHECK_EQ(backing_bitmap_.format(), format());
- DCHECK_EQ(backing_bitmap_.num_mipmaps(), levels());
+ DCHECK(backing_bitmap_->image_data());
+ DCHECK_EQ(backing_bitmap_->width(), width());
+ DCHECK_EQ(backing_bitmap_->height(), height());
+ DCHECK_EQ(backing_bitmap_->format(), format());
+ DCHECK_EQ(backing_bitmap_->num_mipmaps(), levels());
unsigned int mip_width = std::max(1, width() >> level);
unsigned int mip_height = std::max(1, height() >> level);
@@ -322,7 +323,7 @@
// TODO: check that the returned pitch is what we expect.
const unsigned char *mip_data =
- backing_bitmap_.GetMipData(level, TextureCUBE::FACE_POSITIVE_X);
+ backing_bitmap_->GetMipData(level, TextureCUBE::FACE_POSITIVE_X);
if (resize_to_pot_) {
Bitmap::Scale(mip_width, mip_height, format(), mip_data,
rect_width, rect_height,
@@ -393,8 +394,8 @@
return false;
}
if (resize_to_pot_) {
- DCHECK(backing_bitmap_.image_data());
- *texture_data = backing_bitmap_.GetMipData(level,
+ DCHECK(backing_bitmap_->image_data());
+ *texture_data = backing_bitmap_->GetMipData(level,
TextureCUBE::FACE_POSITIVE_X);
locked_levels_ |= 1 << level;
return true;
@@ -459,7 +460,7 @@
bool resize_to_pot;
unsigned int mip_width, mip_height;
return HR(CreateTexture2DD3D9(renderer_d3d9,
- &backing_bitmap_,
+ backing_bitmap_,
render_surfaces_enabled(),
&resize_to_pot,
&mip_width,
@@ -487,6 +488,7 @@
resize_to_pot,
enable_render_surfaces),
d3d_cube_texture_(tex) {
+ backing_bitmap_ = Bitmap::Ref(new Bitmap(service_locator));
}
// Attempts to create a D3D9 CubeTexture with the given specs. If creation
@@ -519,8 +521,8 @@
resize_to_pot,
enable_render_surfaces);
- texture->backing_bitmap_.SetFrom(bitmap);
- if (texture->backing_bitmap_.image_data()) {
+ texture->backing_bitmap_->SetFrom(bitmap);
+ if (texture->backing_bitmap_->image_data()) {
for (int face = 0; face < 6; ++face) {
unsigned int mip_edge = edge;
for (unsigned int i = 0; i < bitmap->num_mipmaps(); ++i) {
@@ -533,12 +535,12 @@
}
}
if (!resize_to_pot)
- texture->backing_bitmap_.FreeData();
+ texture->backing_bitmap_->FreeData();
} else {
if (resize_to_pot) {
- texture->backing_bitmap_.AllocateData();
- memset(texture->backing_bitmap_.image_data(), 0,
- texture->backing_bitmap_.GetTotalSize());
+ texture->backing_bitmap_->AllocateData();
+ memset(texture->backing_bitmap_->image_data(), 0,
+ texture->backing_bitmap_->GetTotalSize());
}
}
@@ -563,12 +565,12 @@
bool TextureCUBED3D9::UpdateBackedMipLevel(unsigned int level,
TextureCUBE::CubeFace face) {
DCHECK_LT(level, static_cast<unsigned int>(levels()));
- DCHECK(backing_bitmap_.image_data());
- DCHECK(backing_bitmap_.is_cubemap());
- DCHECK_EQ(backing_bitmap_.width(), edge_length());
- DCHECK_EQ(backing_bitmap_.height(), edge_length());
- DCHECK_EQ(backing_bitmap_.format(), format());
- DCHECK_EQ(backing_bitmap_.num_mipmaps(), levels());
+ DCHECK(backing_bitmap_->image_data());
+ DCHECK(backing_bitmap_->is_cubemap());
+ DCHECK_EQ(backing_bitmap_->width(), edge_length());
+ DCHECK_EQ(backing_bitmap_->height(), edge_length());
+ DCHECK_EQ(backing_bitmap_->format(), format());
+ DCHECK_EQ(backing_bitmap_->num_mipmaps(), levels());
unsigned int mip_edge = std::max(1, edge_length() >> level);
unsigned int rect_edge = mip_edge;
@@ -590,7 +592,7 @@
DCHECK(out_rect.pBits);
// TODO: check that the returned pitch is what we expect.
- const unsigned char *mip_data = backing_bitmap_.GetMipData(level, face);
+ const unsigned char *mip_data = backing_bitmap_->GetMipData(level, face);
if (resize_to_pot_) {
Bitmap::Scale(mip_edge, mip_edge, format(), mip_data,
rect_edge, rect_edge,
@@ -664,8 +666,8 @@
return false;
}
if (resize_to_pot_) {
- DCHECK(backing_bitmap_.image_data());
- *texture_data = backing_bitmap_.GetMipData(level, face);
+ DCHECK(backing_bitmap_->image_data());
+ *texture_data = backing_bitmap_->GetMipData(level, face);
locked_levels_[face] |= 1 << level;
return true;
} else {
@@ -731,7 +733,7 @@
bool resize_to_pot;
unsigned int mip_edge;
return HR(CreateTextureCUBED3D9(renderer_d3d9,
- &backing_bitmap_,
+ backing_bitmap_,
render_surfaces_enabled(),
&resize_to_pot,
&mip_edge,
« no previous file with comments | « core/win/d3d9/texture_d3d9.h ('k') | plugin/idl/bitmap.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698