| 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,
|
|
|