~canonical-dx-team/nux/nux.fix-702538

« back to all changes in this revision

Viewing changes to Nux/Painter.cpp

  • Committer: Jay Taoko
  • Date: 2011-01-04 03:57:29 UTC
  • mfrom: (157.1.13 nux-holidays)
  • Revision ID: jay.taoko@canonical.com-20110104035729-0xh3iabo7e7dk371
* Added support to copy a texture from the current render target
* Blur, Color matrix, Exponent shaders
* Gaussian blur
* Bug fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
  }
204
204
 
205
205
  int BasePainter::PaintTextLineStatic (GraphicsEngine &GfxContext,
206
 
                                        IntrusiveSP<FontTexture> Font,
 
206
                                        ObjectPtr<FontTexture> Font,
207
207
                                        const Geometry &g,
208
208
                                        const NString &Str,
209
209
                                        const Color &color,
227
227
    tex_h = (float) texture->GetHeight();
228
228
 
229
229
    TexCoordXForm texxform;
230
 
    GfxContext.QRP_GLSL_1Tex (x, y, tex_w, tex_h, texture->GetDeviceTexture(), texxform, Color::White);
 
230
    GfxContext.QRP_1Tex (x, y, tex_w, tex_h, texture->GetDeviceTexture(), texxform, Color::White);
231
231
  }
232
232
 
233
233
  void BasePainter::Draw2DTextureAligned (GraphicsEngine &GfxContext, BaseTexture *texture, const Geometry &g, TextureAlignmentStyle tex_align) const
284
284
 
285
285
  void BasePainter::Paint2DQuadColor (GraphicsEngine &GfxContext, const Geometry &g, Color c0) const
286
286
  {
287
 
    GfxContext.QRP_GLSL_Color (g.x, g.y, g.GetWidth(), g.GetHeight(), c0);
 
287
    GfxContext.QRP_Color (g.x, g.y, g.GetWidth(), g.GetHeight(), c0);
288
288
  }
289
289
 
290
290
  void BasePainter::Paint2DQuadColor (GraphicsEngine &GfxContext, const Geometry &g, Color c0_top_left, Color c1_bottom_left, Color c2_bottom_right, Color c3_top_right) const
291
291
  {
292
 
    GfxContext.QRP_GLSL_Color (g.x, g.y, g.GetWidth(), g.GetHeight(), c0_top_left, c1_bottom_left, c2_bottom_right, c3_top_right);
 
292
    GfxContext.QRP_Color (g.x, g.y, g.GetWidth(), g.GetHeight(), c0_top_left, c1_bottom_left, c2_bottom_right, c3_top_right);
293
293
  }
294
294
 
295
295
  void BasePainter::Paint2DQuadColor (GraphicsEngine &GfxContext, int x, int y, int width, int height, Color c0) const
296
296
  {
297
 
    GfxContext.QRP_GLSL_Color (x, y, width, height, c0);
 
297
    GfxContext.QRP_Color (x, y, width, height, c0);
298
298
  }
299
299
 
300
300
 
301
301
  void BasePainter::Paint2DQuadColor (GraphicsEngine &GfxContext, int x, int y, int width, int height, Color c0_top_left, Color c1_bottom_left, Color c2_bottom_right, Color c3_top_right) const
302
302
  {
303
 
    GfxContext.QRP_GLSL_Color (x, y, width, height, c0_top_left, c1_bottom_left, c2_bottom_right, c3_top_right);
 
303
    GfxContext.QRP_Color (x, y, width, height, c0_top_left, c1_bottom_left, c2_bottom_right, c3_top_right);
304
304
  }
305
305
 
306
306
  void BasePainter::Paint2DQuadVGradient (GraphicsEngine &GfxContext, const Geometry &g, Color TopColor, Color BottomColor) const
319
319
/////////////////////////////
320
320
  void BasePainter::Paint2DQuadWireframe (GraphicsEngine &GfxContext, const Geometry &g, Color c0) const
321
321
  {
322
 
    GfxContext.QRP_GLSL_QuadWireframe (g.x, g.y, g.GetWidth(), g.GetHeight(), c0, c0, c0, c0);
 
322
    GfxContext.QRP_QuadWireframe (g.x, g.y, g.GetWidth(), g.GetHeight(), c0, c0, c0, c0);
323
323
  }
324
324
 
325
325
// void BasePainter::Paint2DQuadWireframe(GraphicsEngine& GfxContext, const Geometry &g, Color c0_left, Color c1_right) const
326
326
// {
327
 
//     GfxContext.QRP_GLSL_QuadWireframe(g.x, g.y, g.GetWidth(), g.GetHeight(), c0_left, c0_left, c1_right, c1_right);
 
327
//     GfxContext.QRP_QuadWireframe(g.x, g.y, g.GetWidth(), g.GetHeight(), c0_left, c0_left, c1_right, c1_right);
328
328
// }
329
329
 
330
330
  void BasePainter::Paint2DQuadWireframe (GraphicsEngine &GfxContext, const Geometry &g, Color c_top_left, Color c_bottom_left, Color c_bottom_right, Color c_top_right) const
331
331
  {
332
 
    GfxContext.QRP_GLSL_QuadWireframe (g.x, g.y, g.GetWidth(), g.GetHeight(), c_top_left, c_bottom_left, c_bottom_right, c_top_right);
 
332
    GfxContext.QRP_QuadWireframe (g.x, g.y, g.GetWidth(), g.GetHeight(), c_top_left, c_bottom_left, c_bottom_right, c_top_right);
333
333
  }
334
334
 
335
335
  void BasePainter::Paint2DQuadWireframe (GraphicsEngine &GfxContext, int x, int y, int width, int height, Color c0) const
336
336
  {
337
 
    GfxContext.QRP_GLSL_QuadWireframe (x, y, width, height, c0, c0, c0, c0);
 
337
    GfxContext.QRP_QuadWireframe (x, y, width, height, c0, c0, c0, c0);
338
338
  }
339
339
 
340
340
// void BasePainter::Paint2DQuadWireframe(GraphicsEngine& GfxContext, int x, int y, int width, int height, Color c0_left, Color c1_right) const
341
341
// {
342
 
//     GfxContext.QRP_GLSL_QuadWireframe(x, y, width, height, c0_left, c0_left, c1_right, c1_right);
 
342
//     GfxContext.QRP_QuadWireframe(x, y, width, height, c0_left, c0_left, c1_right, c1_right);
343
343
// }
344
344
 
345
345
  void BasePainter::Paint2DQuadWireframe (GraphicsEngine &GfxContext, int x, int y, int width, int height, Color c_top_left, Color c_bottom_left, Color c_bottom_right, Color c_top_right) const
346
346
  {
347
 
    GfxContext.QRP_GLSL_QuadWireframe (x, y, width, height, c_top_left, c_bottom_left, c_bottom_right, c_top_right);
 
347
    GfxContext.QRP_QuadWireframe (x, y, width, height, c_top_left, c_bottom_left, c_bottom_right, c_top_right);
348
348
  }
349
349
 
350
350
//////////////////////
355
355
                                         int x2, int y2,
356
356
                                         Color c0)
357
357
  {
358
 
    GfxContext.QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0);
 
358
    GfxContext.QRP_Triangle (x0, y0, x1, y1, x2, y2, c0);
359
359
  }
360
360
 
361
361
  void BasePainter::Draw2DTriangleColor (GraphicsEngine &GfxContext, int x0, int y0,
363
363
                                         int x2, int y2,
364
364
                                         Color c0, Color c1, Color c2)
365
365
  {
366
 
    GfxContext.QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0, c1, c2);
 
366
    GfxContext.QRP_Triangle (x0, y0, x1, y1, x2, y2, c0, c1, c2);
367
367
  }
368
368
 
369
369
//////////////////////
372
372
  void BasePainter::Draw2DLine (GraphicsEngine &GfxContext, int x0, int y0,
373
373
                                int x1, int y1, Color c0) const
374
374
  {
375
 
    GfxContext.QRP_GLSL_Line (x0, y0, x1, y1, c0);
 
375
    GfxContext.QRP_Line (x0, y0, x1, y1, c0);
376
376
  }
377
377
  void BasePainter::Draw2DLine (GraphicsEngine &GfxContext, int x0, int y0,
378
378
                                int x1, int y1, Color c0, Color c1) const
379
379
  {
380
 
    GfxContext.QRP_GLSL_Line (x0, y0, x1, y1, c0, c1);
 
380
    GfxContext.QRP_Line (x0, y0, x1, y1, c0, c1);
381
381
  }
382
382
 
383
383
////////////////////
456
456
      texxform.v0 = 0;
457
457
      texxform.u1 = border_left;
458
458
      texxform.v1 = border_top;
459
 
      GfxContext.QRP_GLSL_ColorModTexAlpha (r_x, r_y, border_left, border_top, texture->GetDeviceTexture(), texxform, c0);
 
459
      GfxContext.QRP_ColorModTexAlpha (r_x, r_y, border_left, border_top, texture->GetDeviceTexture(), texxform, c0);
460
460
    }
461
461
    else
462
462
    {
463
 
      GfxContext.QRP_GLSL_Color (r_x, r_y, border_left, border_top, c0);
 
463
      GfxContext.QRP_Color (r_x, r_y, border_left, border_top, c0);
464
464
    }
465
465
 
466
466
    // Draw TOP-RIGHT CORNER
470
470
      texxform.v0 = 0;
471
471
      texxform.u1 = tex_w;
472
472
      texxform.v1 = border_top;
473
 
      GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + r_w - border_right, r_y, border_right, border_top, texture->GetDeviceTexture(), texxform, c0);
 
473
      GfxContext.QRP_ColorModTexAlpha (r_x + r_w - border_right, r_y, border_right, border_top, texture->GetDeviceTexture(), texxform, c0);
474
474
    }
475
475
    else
476
476
    {
477
 
      GfxContext.QRP_GLSL_Color (r_x + r_w - border_right, r_y, border_right, border_top, c0);
 
477
      GfxContext.QRP_Color (r_x + r_w - border_right, r_y, border_right, border_top, c0);
478
478
    }
479
479
 
480
480
    // Draw BOTTOM-LEFT CORNER
484
484
      texxform.v0 = tex_h - border_bottom;
485
485
      texxform.u1 = border_left;
486
486
      texxform.v1 = tex_h;
487
 
      GfxContext.QRP_GLSL_ColorModTexAlpha (r_x, r_y + r_h - border_bottom, border_left, border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
487
      GfxContext.QRP_ColorModTexAlpha (r_x, r_y + r_h - border_bottom, border_left, border_bottom, texture->GetDeviceTexture(), texxform, c0);
488
488
    }
489
489
    else
490
490
    {
491
 
      GfxContext.QRP_GLSL_Color (r_x, r_y + r_h - border_bottom, border_left, border_bottom, c0);
 
491
      GfxContext.QRP_Color (r_x, r_y + r_h - border_bottom, border_left, border_bottom, c0);
492
492
    }
493
493
 
494
494
    // Draw BOTTOM-RIGHT CORNER
498
498
      texxform.v0 = tex_h - border_bottom;
499
499
      texxform.u1 = tex_w;
500
500
      texxform.v1 = tex_h;
501
 
      GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
501
      GfxContext.QRP_ColorModTexAlpha (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, texture->GetDeviceTexture(), texxform, c0);
502
502
    }
503
503
    else
504
504
    {
505
 
      GfxContext.QRP_GLSL_Color (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, c0);
 
505
      GfxContext.QRP_Color (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, c0);
506
506
    }
507
507
 
508
508
    texxform.u0 = border_left;
509
509
    texxform.v0 = 0;
510
510
    texxform.u1 = tex_w - border_right;
511
511
    texxform.v1 = border_top;
512
 
    GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + border_left, r_y, r_w - border_left - border_right, border_top, texture->GetDeviceTexture(), texxform, c0);
 
512
    GfxContext.QRP_ColorModTexAlpha (r_x + border_left, r_y, r_w - border_left - border_right, border_top, texture->GetDeviceTexture(), texxform, c0);
513
513
    // Draw BOTTOM BORDER
514
514
    texxform.u0 = border_left;
515
515
    texxform.v0 = tex_h - border_bottom;
516
516
    texxform.u1 = tex_w - border_right;
517
517
    texxform.v1 = tex_h;
518
 
    GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + border_left, r_y + r_h - border_bottom, r_w - border_left - border_right, border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
518
    GfxContext.QRP_ColorModTexAlpha (r_x + border_left, r_y + r_h - border_bottom, r_w - border_left - border_right, border_bottom, texture->GetDeviceTexture(), texxform, c0);
519
519
    // Draw LEFT BORDER
520
520
    texxform.u0 = 0;
521
521
    texxform.v0 = border_top;
522
522
    texxform.u1 = border_left;
523
523
    texxform.v1 = tex_h - border_bottom;
524
 
    GfxContext.QRP_GLSL_ColorModTexAlpha (r_x, r_y + border_top, border_left, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
524
    GfxContext.QRP_ColorModTexAlpha (r_x, r_y + border_top, border_left, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
525
525
    // Draw RIGHT BORDER
526
526
    texxform.u0 = tex_w - border_right;
527
527
    texxform.v0 = border_top;
528
528
    texxform.u1 = tex_w;
529
529
    texxform.v1 = tex_h - border_bottom;
530
 
    GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + r_w - border_right, r_y + border_top, border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
530
    GfxContext.QRP_ColorModTexAlpha (r_x + r_w - border_right, r_y + border_top, border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
531
531
 
532
532
    // Draw CENTER
533
533
    if (draw_borders_only == false)
536
536
      texxform.v0 = border_top;
537
537
      texxform.u1 = tex_w - border_right;
538
538
      texxform.v1 = tex_h - border_bottom;
539
 
      GfxContext.QRP_GLSL_ColorModTexAlpha (r_x + border_left, r_y + border_top, r_w - border_left - border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
 
539
      GfxContext.QRP_ColorModTexAlpha (r_x + border_left, r_y + border_top, r_w - border_left - border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, c0);
540
540
    }
541
541
 
542
542
    GfxContext.GetRenderStates().SetColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
595
595
    texxform.v0 = 0;
596
596
    texxform.u1 = border_left;
597
597
    texxform.v1 = border_top;
598
 
    GfxContext.QRP_GLSL_1Tex (r_x, r_y, border_left, border_top, texture->GetDeviceTexture(), texxform, Color::White);
 
598
    GfxContext.QRP_1Tex (r_x, r_y, border_left, border_top, texture->GetDeviceTexture(), texxform, Color::White);
599
599
    // Draw TOP-RIGHT CORNER
600
600
    texxform.u0 = tex_w - border_right;
601
601
    texxform.v0 = 0;
602
602
    texxform.u1 = tex_w;
603
603
    texxform.v1 = border_top;
604
 
    GfxContext.QRP_GLSL_1Tex (r_x + r_w - border_right, r_y, border_right, border_top, texture->GetDeviceTexture(), texxform, Color::White);
 
604
    GfxContext.QRP_1Tex (r_x + r_w - border_right, r_y, border_right, border_top, texture->GetDeviceTexture(), texxform, Color::White);
605
605
    // Draw BOTTOM-LEFT CORNER
606
606
    texxform.u0 = 0;
607
607
    texxform.v0 = tex_h - border_bottom;
608
608
    texxform.u1 = border_left;
609
609
    texxform.v1 = tex_h;
610
 
    GfxContext.QRP_GLSL_1Tex (r_x, r_y + r_h - border_bottom, border_left, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
610
    GfxContext.QRP_1Tex (r_x, r_y + r_h - border_bottom, border_left, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
611
611
    // Draw BOTTOM-RIGHT CORNER
612
612
    texxform.u0 = tex_w - border_right;
613
613
    texxform.v0 = tex_h - border_bottom;
614
614
    texxform.u1 = tex_w;
615
615
    texxform.v1 = tex_h;
616
 
    GfxContext.QRP_GLSL_1Tex (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
616
    GfxContext.QRP_1Tex (r_x + r_w - border_right, r_y + r_h - border_bottom, border_right, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
617
617
    // Draw TOP BORDER
618
618
    texxform.u0 = border_left;
619
619
    texxform.v0 = 0;
620
620
    texxform.u1 = tex_w - border_right;
621
621
    texxform.v1 = border_top;
622
 
    GfxContext.QRP_GLSL_1Tex (r_x + border_left, r_y, r_w - border_left - border_right, border_top, texture->GetDeviceTexture(), texxform, Color::White);
 
622
    GfxContext.QRP_1Tex (r_x + border_left, r_y, r_w - border_left - border_right, border_top, texture->GetDeviceTexture(), texxform, Color::White);
623
623
    // Draw BOTTOM BORDER
624
624
    texxform.u0 = border_left;
625
625
    texxform.v0 = tex_h - border_bottom;
626
626
    texxform.u1 = tex_w - border_right;
627
627
    texxform.v1 = tex_h;
628
 
    GfxContext.QRP_GLSL_1Tex (r_x + border_left, r_y + r_h - border_bottom, r_w - border_left - border_right, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
628
    GfxContext.QRP_1Tex (r_x + border_left, r_y + r_h - border_bottom, r_w - border_left - border_right, border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
629
629
    // Draw LEFT BORDER
630
630
    texxform.u0 = 0;
631
631
    texxform.v0 = border_top;
632
632
    texxform.u1 = border_left;
633
633
    texxform.v1 = tex_h - border_bottom;
634
 
    GfxContext.QRP_GLSL_1Tex (r_x, r_y + border_top, border_left, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
634
    GfxContext.QRP_1Tex (r_x, r_y + border_top, border_left, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
635
635
    // Draw RIGHT BORDER
636
636
    texxform.u0 = tex_w - border_right;
637
637
    texxform.v0 = border_top;
638
638
    texxform.u1 = tex_w;
639
639
    texxform.v1 = tex_h - border_bottom;
640
 
    GfxContext.QRP_GLSL_1Tex (r_x + r_w - border_right, r_y + border_top, border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
640
    GfxContext.QRP_1Tex (r_x + r_w - border_right, r_y + border_top, border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
641
641
 
642
642
    // Draw CENTER
643
643
    if (draw_borders_only == false)
646
646
      texxform.v0 = border_top;
647
647
      texxform.u1 = tex_w - border_right;
648
648
      texxform.v1 = tex_h - border_bottom;
649
 
      GfxContext.QRP_GLSL_1Tex (r_x + border_left, r_y + border_top, r_w - border_left - border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
 
649
      GfxContext.QRP_1Tex (r_x + border_left, r_y + border_top, r_w - border_left - border_right, r_h - border_top - border_bottom, texture->GetDeviceTexture(), texxform, Color::White);
650
650
    }
651
651
 
652
652
    GfxContext.GetRenderStates().SetBlend (FALSE);
882
882
  }
883
883
 
884
884
  void BasePainter::PushTextureLayer (GraphicsEngine &GfxContext, Geometry geo,
885
 
                                      IntrusiveSP<IOpenGLBaseTexture> DeviceTexture,
 
885
                                      ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
886
886
                                      TexCoordXForm texxform,
887
887
                                      const Color &color,
888
888
                                      bool WriteAlpha,
894
894
  }
895
895
 
896
896
  void BasePainter::PushDrawTextureLayer (GraphicsEngine &GfxContext, Geometry geo,
897
 
                                          IntrusiveSP<IOpenGLBaseTexture> DeviceTexture,
 
897
                                          ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
898
898
                                          TexCoordXForm texxform,
899
899
                                          const Color &color,
900
900
                                          bool WriteAlpha,