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

Unified Diff: ui/gfx/surface/accelerated_surface_mac.cc

Issue 7191025: Fixed warning from Core Graphics related to zero-width or zero-height (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 | « ui/gfx/surface/accelerated_surface_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/surface/accelerated_surface_mac.cc
===================================================================
--- ui/gfx/surface/accelerated_surface_mac.cc (revision 89274)
+++ ui/gfx/surface/accelerated_surface_mac.cc (working copy)
@@ -94,7 +94,8 @@
glCopyTexSubImage2D(target, 0,
0, 0,
0, 0,
- surface_size_.width(), surface_size_.height());
+ real_surface_size_.width(),
+ real_surface_size_.height());
glBindTexture(target, current_texture);
// This flush is absolutely essential -- it guarantees that the
// rendering results are seen by the other process.
@@ -111,8 +112,8 @@
// Note that glReadPixels does an implicit glFlush().
glReadPixels(0,
0,
- surface_size_.width(),
- surface_size_.height(),
+ real_surface_size_.width(),
+ real_surface_size_.height(),
GL_BGRA, // This pixel format should have no conversion.
GL_UNSIGNED_INT_8_8_8_8_REV,
pixel_memory);
@@ -194,6 +195,10 @@
return fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT;
}
+gfx::Size AcceleratedSurface::ClampToValidDimensions(const gfx::Size& size) {
+ return gfx::Size(std::max(size.width(), 1), std::max(size.height(), 1));
+}
+
bool AcceleratedSurface::MakeCurrent() {
if (!gl_context_.get())
return false;
@@ -230,11 +235,13 @@
if (!MakeCurrent())
return 0;
+ gfx::Size clamped_size = ClampToValidDimensions(size);
+
// GL_TEXTURE_RECTANGLE_ARB is the best supported render target on
// Mac OS X and is required for IOSurface interoperability.
GLenum target = GL_TEXTURE_RECTANGLE_ARB;
if (allocate_fbo_) {
- AllocateRenderBuffers(target, size);
+ AllocateRenderBuffers(target, clamped_size);
} else if (!texture_) {
// Generate the texture object.
glGenTextures(1, &texture_);
@@ -253,9 +260,11 @@
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
AddIntegerValue(properties,
- io_surface_support->GetKIOSurfaceWidth(), size.width());
+ io_surface_support->GetKIOSurfaceWidth(),
+ clamped_size.width());
AddIntegerValue(properties,
- io_surface_support->GetKIOSurfaceHeight(), size.height());
+ io_surface_support->GetKIOSurfaceHeight(),
+ clamped_size.height());
AddIntegerValue(properties,
io_surface_support->GetKIOSurfaceBytesPerElement(), 4);
AddBooleanValue(properties,
@@ -271,8 +280,8 @@
static_cast<CGLContextObj>(gl_context_->GetHandle()),
target,
GL_RGBA,
- size.width(),
- size.height(),
+ clamped_size.width(),
+ clamped_size.height(),
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
io_surface_.get(),
@@ -282,6 +291,7 @@
SetupFrameBufferObject(target);
}
surface_size_ = size;
+ real_surface_size_ = clamped_size;
// Now send back an identifier for the IOSurface. We originally
// intended to send back a mach port from IOSurfaceCreateMachPort
@@ -306,6 +316,8 @@
return TransportDIB::DefaultHandleValue();
}
surface_size_ = size;
+ gfx::Size clamped_size = ClampToValidDimensions(size);
+ real_surface_size_ = clamped_size;
// Release the old TransportDIB in the browser.
if (dib_free_callback_.get() && transport_dib_.get()) {
@@ -314,7 +326,8 @@
transport_dib_.reset();
// Ask the renderer to create a TransportDIB.
- size_t dib_size = size.width() * 4 * size.height(); // 4 bytes per pixel.
+ size_t dib_size =
+ clamped_size.width() * 4 * clamped_size.height(); // 4 bytes per pixel.
TransportDIB::Handle dib_handle;
if (dib_alloc_callback_.get()) {
dib_alloc_callback_->Run(dib_size, &dib_handle);
@@ -336,12 +349,12 @@
// Set up the render buffers and reserve enough space on the card for the
// framebuffer texture.
GLenum target = GL_TEXTURE_RECTANGLE_ARB;
- AllocateRenderBuffers(target, size);
+ AllocateRenderBuffers(target, clamped_size);
glTexImage2D(target,
0, // mipmap level 0
GL_RGBA8, // internal pixel format
- size.width(),
- size.height(),
+ clamped_size.width(),
+ clamped_size.height(),
0, // 0 border
GL_BGRA, // Used for consistency
GL_UNSIGNED_INT_8_8_8_8_REV,
« no previous file with comments | « ui/gfx/surface/accelerated_surface_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698