OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
3 Copyright (C) 2012 Igalia S.L. | 3 Copyright (C) 2012 Igalia S.L. |
4 Copyright (C) 2012 Adobe Systems Incorporated | 4 Copyright (C) 2012 Adobe Systems Incorporated |
5 | 5 |
6 This library is free software; you can redistribute it and/or | 6 This library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
8 License as published by the Free Software Foundation; either | 8 License as published by the Free Software Foundation; either |
9 version 2 of the License, or (at your option) any later version. | 9 version 2 of the License, or (at your option) any later version. |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include <wtf/HashMap.h> | 33 #include <wtf/HashMap.h> |
34 #include <wtf/OwnArrayPtr.h> | 34 #include <wtf/OwnArrayPtr.h> |
35 #include <wtf/PassOwnArrayPtr.h> | 35 #include <wtf/PassOwnArrayPtr.h> |
36 #include <wtf/PassRefPtr.h> | 36 #include <wtf/PassRefPtr.h> |
37 #include <wtf/RefCounted.h> | 37 #include <wtf/RefCounted.h> |
38 | 38 |
39 #if PLATFORM(QT) | 39 #if PLATFORM(QT) |
40 #include "NativeImageQt.h" | 40 #include "NativeImageQt.h" |
41 #endif | 41 #endif |
42 | 42 |
43 #if USE(CAIRO) | |
44 #include "CairoUtilities.h" | |
45 #include "RefPtrCairo.h" | |
46 #include <cairo.h> | |
47 #include <wtf/text/CString.h> | |
48 #endif | |
49 | |
50 #if ENABLE(CSS_SHADERS) | 43 #if ENABLE(CSS_SHADERS) |
51 #include "CustomFilterCompiledProgram.h" | 44 #include "CustomFilterCompiledProgram.h" |
52 #include "CustomFilterOperation.h" | 45 #include "CustomFilterOperation.h" |
53 #include "CustomFilterProgram.h" | 46 #include "CustomFilterProgram.h" |
54 #include "CustomFilterRenderer.h" | 47 #include "CustomFilterRenderer.h" |
55 #include "CustomFilterValidatedProgram.h" | 48 #include "CustomFilterValidatedProgram.h" |
56 #include "ValidatedCustomFilterOperation.h" | 49 #include "ValidatedCustomFilterOperation.h" |
57 #endif | 50 #endif |
58 | 51 |
59 #if !USE(TEXMAP_OPENGL_ES_2) | 52 #if !USE(TEXMAP_OPENGL_ES_2) |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 painter.fillRect(sourceRect, Color::createUnchecked(color.blue(), color.gree
n(), color.red())); // Since we won't swap R+B when uploading a texture, paint w
ith the swapped R+B color. | 362 painter.fillRect(sourceRect, Color::createUnchecked(color.blue(), color.gree
n(), color.red())); // Since we won't swap R+B when uploading a texture, paint w
ith the swapped R+B color. |
370 painter.setFont(font); | 363 painter.setFont(font); |
371 painter.setPen(Qt::white); | 364 painter.setPen(Qt::white); |
372 painter.drawText(2, height * 0.85, counterString); | 365 painter.drawText(2, height * 0.85, counterString); |
373 | 366 |
374 RefPtr<BitmapTexture> texture = acquireTextureFromPool(size); | 367 RefPtr<BitmapTexture> texture = acquireTextureFromPool(size); |
375 const uchar* bits = image.bits(); | 368 const uchar* bits = image.bits(); |
376 static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits,
sourceRect, IntPoint::zero(), image.bytesPerLine()); | 369 static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits,
sourceRect, IntPoint::zero(), image.bytesPerLine()); |
377 drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges); | 370 drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges); |
378 | 371 |
379 #elif USE(CAIRO) | |
380 CString counterString = String::number(number).ascii(); | |
381 // cairo_text_extents() requires a cairo_t, so dimensions need to be guessti
mated. | |
382 int width = counterString.length() * pointSize * 1.2; | |
383 int height = pointSize * 1.5; | |
384 | |
385 cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w
idth, height); | |
386 cairo_t* cr = cairo_create(surface); | |
387 | |
388 float r, g, b, a; | |
389 color.getRGBA(r, g, b, a); | |
390 cairo_set_source_rgba(cr, b, g, r, a); // Since we won't swap R+B when uploa
ding a texture, paint with the swapped R+B color. | |
391 cairo_rectangle(cr, 0, 0, width, height); | |
392 cairo_fill(cr); | |
393 | |
394 cairo_select_font_face(cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_
WEIGHT_BOLD); | |
395 cairo_set_font_size(cr, pointSize); | |
396 cairo_set_source_rgb(cr, 1, 1, 1); | |
397 cairo_move_to(cr, 2, pointSize); | |
398 cairo_show_text(cr, counterString.data()); | |
399 | |
400 IntSize size(width, height); | |
401 IntRect sourceRect(IntPoint::zero(), size); | |
402 IntRect targetRect(roundedIntPoint(targetPoint), size); | |
403 | |
404 RefPtr<BitmapTexture> texture = acquireTextureFromPool(size); | |
405 const unsigned char* bits = cairo_image_surface_get_data(surface); | |
406 int stride = cairo_image_surface_get_stride(surface); | |
407 static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits,
sourceRect, IntPoint::zero(), stride); | |
408 drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges); | |
409 | |
410 cairo_surface_destroy(surface); | |
411 cairo_destroy(cr); | |
412 | |
413 #else | 372 #else |
414 UNUSED_PARAM(number); | 373 UNUSED_PARAM(number); |
415 UNUSED_PARAM(pointSize); | 374 UNUSED_PARAM(pointSize); |
416 UNUSED_PARAM(targetPoint); | 375 UNUSED_PARAM(targetPoint); |
417 UNUSED_PARAM(modelViewMatrix); | 376 UNUSED_PARAM(modelViewMatrix); |
418 notImplemented(); | 377 notImplemented(); |
419 #endif | 378 #endif |
420 } | 379 } |
421 | 380 |
422 void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect&
targetRect, const TransformationMatrix& matrix, float opacity, unsigned exposed
Edges) | 381 void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect&
targetRect, const TransformationMatrix& matrix, float opacity, unsigned exposed
Edges) |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 if (!frameImage) | 680 if (!frameImage) |
722 return; | 681 return; |
723 | 682 |
724 int bytesPerLine; | 683 int bytesPerLine; |
725 const char* imageData; | 684 const char* imageData; |
726 | 685 |
727 #if PLATFORM(QT) | 686 #if PLATFORM(QT) |
728 QImage qImage = frameImage->toImage(); | 687 QImage qImage = frameImage->toImage(); |
729 imageData = reinterpret_cast<const char*>(qImage.constBits()); | 688 imageData = reinterpret_cast<const char*>(qImage.constBits()); |
730 bytesPerLine = qImage.bytesPerLine(); | 689 bytesPerLine = qImage.bytesPerLine(); |
731 #elif USE(CAIRO) | |
732 cairo_surface_t* surface = frameImage->surface(); | |
733 imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surfa
ce)); | |
734 bytesPerLine = cairo_image_surface_get_stride(surface); | |
735 #endif | 690 #endif |
736 | 691 |
737 updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFl
ag); | 692 updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFl
ag); |
738 } | 693 } |
739 | 694 |
740 #if ENABLE(CSS_FILTERS) | 695 #if ENABLE(CSS_FILTERS) |
741 | 696 |
742 static TextureMapperShaderProgram::Options optionsForFilterType(FilterOperation:
:OperationType type, unsigned pass) | 697 static TextureMapperShaderProgram::Options optionsForFilterType(FilterOperation:
:OperationType type, unsigned pass) |
743 { | 698 { |
744 switch (type) { | 699 switch (type) { |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 BitmapTextureGL* texture = new BitmapTextureGL(this); | 1165 BitmapTextureGL* texture = new BitmapTextureGL(this); |
1211 return adoptRef(texture); | 1166 return adoptRef(texture); |
1212 } | 1167 } |
1213 | 1168 |
1214 PassOwnPtr<TextureMapper> TextureMapper::platformCreateAccelerated() | 1169 PassOwnPtr<TextureMapper> TextureMapper::platformCreateAccelerated() |
1215 { | 1170 { |
1216 return TextureMapperGL::create(); | 1171 return TextureMapperGL::create(); |
1217 } | 1172 } |
1218 | 1173 |
1219 }; | 1174 }; |
OLD | NEW |