void WriteableBitmap::Render (UIElement *element, Transform *transform) { CairoSurface *target; if (!element) return; cairo_surface_t *surface = GetSurface (NULL); if (!surface) { Invalidate (); // it could still be NULL (e.g. directly inheriting UIElement) surface = GetSurface (NULL); if (!surface) return; } target = new CairoSurface (surface); Rect bounds (0, 0, GetPixelWidth (), GetPixelHeight ()); cairo_matrix_t xform; cairo_matrix_init_identity (&xform); if (transform) transform->GetTransform (&xform); element->Paint (target, bounds, &xform); target->unref (); cairo_surface_flush (surface); }
cairo_surface_t * BitmapSource::GetSurface (cairo_t *cr) { if (image_surface == NULL) return NULL; if (native_surface) return native_surface; if (cr == NULL) return image_surface; native_surface = cairo_surface_create_similar (cairo_get_group_target (cr), cairo_surface_get_content (image_surface), GetPixelWidth (), GetPixelHeight ()); cairo_t *context = cairo_create (native_surface); cairo_set_source_surface (context, image_surface, 0, 0); cairo_pattern_set_filter (cairo_get_source (context), CAIRO_FILTER_FAST); cairo_paint (context); cairo_destroy (context); return native_surface; }
void BitmapSource::Invalidate () { if (GetPixelWidth () == 0 || GetPixelHeight () == 0) return; if (native_surface) { cairo_surface_destroy (native_surface); native_surface = NULL; } if (image_surface) cairo_surface_destroy (image_surface); image_surface = cairo_image_surface_create_for_data ((unsigned char *) GetBitmapData (), CAIRO_FORMAT_ARGB32, GetPixelWidth (), GetPixelHeight (), GetPixelWidth () * 4); Emit (BitmapSource::PixelDataChangedEvent); }
gpointer WriteableBitmap::InitializeFromBitmapSource (BitmapSource *source) { cairo_t *cr; if (!source) return NULL; SetPixelHeight (source->GetPixelHeight ()); SetPixelWidth (source->GetPixelWidth ()); image_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, GetPixelWidth (), GetPixelHeight ()); cr = cairo_create (image_surface); cairo_set_source_surface (cr, source->GetImageSurface (), 0, 0); cairo_paint (cr); cairo_destroy (cr); SetBitmapData (cairo_image_surface_get_data (image_surface), false); return GetBitmapData (); }
void WriteableBitmap::Render (UIElement *element, Transform *transform) { cairo_t *cr; Region *region; if (!element) return; cairo_surface_t *surface = GetSurface (NULL); if (!surface) { Invalidate (); // it could still be NULL (e.g. directly inheriting UIElement) surface = GetSurface (NULL); if (!surface) return; } cr = cairo_create (surface); Rect bounds (0, 0, GetPixelWidth (), GetPixelHeight ()); // FIXME is this supposed to clear the surface? cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_matrix_t xform; cairo_matrix_init_identity (&xform); if (transform) transform->GetTransform (&xform); element->Paint (cr, bounds, &xform); cairo_destroy (cr); cairo_surface_flush (surface); }
void WriteableBitmap::Render (UIElement *element, Transform *transform) { MoonSurface *src; Context *ctx; if (!element) return; cairo_surface_t *surface = GetImageSurface (); if (!surface) return; Rect bounds (0, 0, GetPixelWidth (), GetPixelHeight ()); #ifdef USE_GALLIUM struct pipe_resource pt, *texture; GalliumSurface *target; struct pipe_screen *screen = swrast_screen_create (null_sw_create ()); memset (&pt, 0, sizeof (pt)); pt.target = PIPE_TEXTURE_2D; pt.format = PIPE_FORMAT_B8G8R8A8_UNORM; pt.width0 = 1; pt.height0 = 1; pt.depth0 = 1; pt.last_level = 0; pt.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_TRANSFER_READ; texture = (*screen->resource_create) (screen, &pt); target = new GalliumSurface (texture); pipe_resource_reference (&texture, NULL); ctx = new GalliumContext (target); target->unref (); #else CairoSurface *target; target = new CairoSurface (1, 1); ctx = new CairoContext (target); target->unref (); #endif ctx->Push (Context::Group (bounds)); cairo_matrix_t xform; cairo_matrix_init_identity (&xform); if (transform) transform->GetTransform (&xform); FrameworkElement *fe = (FrameworkElement *)element; if (fe->GetFlowDirection () == FlowDirectionRightToLeft) { cairo_matrix_translate (&xform, fe->GetActualWidth (), 0.0); cairo_matrix_scale (&xform, -1, 1); } element->Paint (ctx, bounds, &xform); bounds = ctx->Pop (&src); if (!bounds.IsEmpty ()) { cairo_surface_t *image = src->Cairo (); cairo_t *cr = cairo_create (surface); cairo_set_source_surface (cr, image, 0, 0); cairo_paint (cr); cairo_destroy (cr); cairo_surface_destroy (image); src->unref (); } delete ctx; #ifdef USE_GALLIUM screen->destroy (screen); #endif }
template<class T> DISPLAY_INT HTMLElementDisplay<T>::GetBaseline(void) { return GetPixelHeight(); }
void RenderingEngine::Render(float interpolation) { DrawingContext dc(m_textures, m_render, GetPixelWidth(), GetPixelHeight()); m_scheme.Draw(dc, interpolation); }
float GlfwWindow::GetAspectRatio() const { return (float)GetPixelWidth() / (float)GetPixelHeight(); }