forked from AuroraMiddleware/gtk
58b9c3a6d4
Instead of relying on cairo_t to perform drawing from our backing image surface to the Core Graphics context, we can convert the cairo_image_surface_t into a CGImageRef without having to copy data if we are certain of the alignment of the image up front. Without this, there are many situations, based on the size of the window that could cause cairo to take a slow path and malloc/copy the data to ensure that alignment. The previous commit titled "macos: align image surface rowstride to 16-bytes" ensures that this invariant is true so that our drawing code can assume we can reference the framebuffer from the cairo_image_surface_t using a CGDataProvider. Since GdkMacosCairoContext and GdkMacosCairoSubview are coordinating, we can also setup the transformation/scale early when drawing the cairo_image_surface_t instead of when copying it to Core Graphics. Furthermore, the CGImageRef is created with an RGB colorspace so that we are not performing colorspace conversion to the output device. We don't get color matching between displays, but we don't expect that anyway, particularly with the software renderer.
37 lines
1.2 KiB
Objective-C
37 lines
1.2 KiB
Objective-C
/* GdkMacosCairoSubview.h
|
|
*
|
|
* Copyright © 2020 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*/
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
#define GDK_IS_MACOS_CAIRO_SUBVIEW(obj) ((obj) && [obj isKindOfClass:[GdkMacosCairoSubview class]])
|
|
|
|
@interface GdkMacosCairoSubview : NSView
|
|
{
|
|
BOOL _isOpaque;
|
|
cairo_region_t *clip;
|
|
CGImageRef image;
|
|
}
|
|
|
|
-(void)setOpaque:(BOOL)opaque;
|
|
-(void)setImage:(CGImageRef)theImage withDamage:(cairo_region_t *)region;
|
|
-(void)setClip:(cairo_region_t*)region;
|
|
|
|
@end
|