Changeset 71213 in webkit
- Timestamp:
- Nov 2, 2010 9:41:32 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71212 r71213 783 783 (WebInspector.ImageView.prototype.contentTabSelected.onImageLoad): 784 784 785 2010-11-02 Adele Peterson <adele@apple.com> 785 2010-10-31 Noam Rosenthal <noam.rosenthal@nokia.com> 786 787 Reviewed by Kenneth Rohde Christiansen. 788 789 [Texmap] [Qt] Texture mapper initial implementation 790 https://bugs.webkit.org/show_bug.cgi?id=47070 791 792 Some refactor for texmap to enable WebKit2: remove globals, and allow TextureMapper to exist without a GraphicsContext. 793 This will allow rendering the TextureMapperNode tree without an active QPainter, into the current GL context. 794 Most of the changes simply move the globas in TextureMapperGL into members of that class. 795 796 No new tests. Old tests in LayoutTests/compositing cover this. 797 798 * platform/graphics/opengl/TextureMapperGL.cpp: 799 (WebCore::TextureMapperGLData::ShaderInfo::getUniformLocation): 800 (WebCore::TextureMapperGLData::ShaderInfo::createShaderProgram): 801 (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::findOrCreate): 802 (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::deref): 803 (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::DirectlyCompositedImageRepository): 804 (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::~DirectlyCompositedImageRepository): 805 (WebCore::TextureMapperGLData::TextureMapperGLData): 806 (WebCore::TextureMapperGL::TextureMapperGL): 807 (WebCore::TextureMapperGL::drawTexture): 808 (WebCore::BitmapTextureGL::setContentsToImage): 809 (WebCore::BitmapTextureGL::destroy): 810 (WebCore::TextureMapperGL::~TextureMapperGL): 811 (WebCore::TextureMapperGL::makeContextCurrent): 812 (WebCore::TextureMapperGL::obtainCurrentContext): 813 (WebCore::TextureMapperGL::bindSurface): 814 (WebCore::TextureMapperGL::paintToTarget): 815 (WebCore::TextureMapperGL::createTexture): 816 * platform/graphics/opengl/TextureMapperGL.h: 817 (WebCore::TextureMapperGL::data): 818 * platform/graphics/qt/TextureMapperQt.cpp: 819 (WebCore::TextureMapperQt::TextureMapperQt): 820 (WebCore::TextureMapperQt::setGraphicsContext): 821 (WebCore::TextureMapper::create): 822 * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp: 823 (WebCore::TextureMapperNode::paint): 824 (WebCore::TextureMapperNode::uploadTextureFromContent): 825 * platform/graphics/texmap/TextureMapper.h: 826 (WebCore::TextureMapper::setGraphicsContext): 827 (WebCore::TextureMapper::setImageInterpolationQuality): 828 (WebCore::TextureMapper::setTextDrawingMode): 829 (WebCore::TextureMapper::imageInterpolationQuality): 830 (WebCore::TextureMapper::textDrawingMode): 831 (WebCore::TextureMapper::TextureMapper): 832 * platform/graphics/texmap/TextureMapperPlatformLayer.h: 833 (WebCore::TextureMapperContentLayer::paint): 834 835 2010-11-02 Adele Peterson <adele@apple.com> 786 836 787 837 Reviewed by Kent Tamura. … … 83084 83134 Reviewed by Gustavo Noronha Silva. 83085 83135 83086 Bug 83136 Bug 41340 - [GStreamer] Subtle race condition during seeks 83087 83137 https://bugs.webkit.org/show_bug.cgi?id=41340 83088 83138 -
trunk/WebCore/platform/graphics/opengl/TextureMapperGL.cpp
r70933 r71213 31 31 #include <GLES2/gl2.h> 32 32 #elif OS(MAC_OS_X) 33 #include <AGL/agl.h> 33 34 #include <gl.h> 34 35 #else 36 #if OS(UNIX) 37 #include <GL/glx.h> 38 #endif 35 39 #include <GL/gl.h> 36 40 #endif … … 91 95 #endif 92 96 97 static const GLuint gInVertexAttributeIndex = 0; 98 99 struct TextureMapperGLData { 100 static struct ShaderInfo { 101 enum ShaderProgramIndex { 102 SimpleProgram, 103 OpacityAndMaskProgram, 104 TargetProgram, 105 106 ProgramCount 107 }; 108 109 enum ShaderVariableIndex { 110 InMatrixVariable, 111 InSourceMatrixVariable, 112 InMaskMatrixVariable, 113 OpacityVariable, 114 SourceTextureVariable, 115 MaskTextureVariable, 116 117 VariableCount 118 }; 119 120 struct ProgramInfo { 121 GLuint id; 122 GLint vars[VariableCount]; 123 }; 124 125 GLint getUniformLocation(ShaderProgramIndex prog, ShaderVariableIndex var, const char* name) 126 { 127 return programs[prog].vars[var] = glGetUniformLocation(programs[prog].id, name); 128 } 129 130 void createShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource, ShaderProgramIndex index) 131 { 132 GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); 133 GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); 134 GL_CMD(glShaderSource(vertexShader, 1, &vertexShaderSource, 0)) 135 GL_CMD(glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0)) 136 GLuint programID = glCreateProgram(); 137 GL_CMD(glCompileShader(vertexShader)) 138 GL_CMD(glCompileShader(fragmentShader)) 139 GL_CMD(glAttachShader(programID, vertexShader)) 140 GL_CMD(glAttachShader(programID, fragmentShader)) 141 GL_CMD(glBindAttribLocation(programID, gInVertexAttributeIndex, "InVertex")) 142 GL_CMD(glLinkProgram(programID)) 143 programs[index].id = programID; 144 #ifdef PRINT_PROGRAM_INFO_LOG 145 char infoLog[1024]; 146 int len; 147 GL_CMD(glGetProgramInfoLog(programID, 1024, &len, infoLog)); 148 LOG(Graphics, "Compiled program for texture mapper. Log: %s\n", infoLog); 149 #endif 150 } 151 152 ProgramInfo programs[ProgramCount]; 153 154 } shaderInfo; 155 156 struct DirectlyCompositedImageRepository { 157 struct Entry { 158 GLuint texture; 159 int refCount; 160 }; 161 HashMap<NativeImagePtr, Entry> imageToTexture; 162 163 GLuint findOrCreate(NativeImagePtr image, bool& found) 164 { 165 HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image); 166 found = false; 167 if (it != imageToTexture.end()) { 168 it->second.refCount++; 169 found = true; 170 return it->second.texture; 171 } 172 Entry entry; 173 GL_CMD(glGenTextures(1, &entry.texture)); 174 entry.refCount = 1; 175 imageToTexture.add(image, entry); 176 return entry.texture; 177 } 178 179 bool deref(NativeImagePtr image) 180 { 181 HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image); 182 if (it != imageToTexture.end()) { 183 if (it->second.refCount < 2) { 184 imageToTexture.remove(it); 185 return false; 186 } 187 } 188 return true; 189 } 190 191 DirectlyCompositedImageRepository() 192 { 193 } 194 195 ~DirectlyCompositedImageRepository() 196 { 197 for (HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.begin(); it != imageToTexture.end(); ++it) { 198 GLuint texture = it->second.texture; 199 if (texture) 200 GL_CMD(glDeleteTextures(1, &texture)); 201 } 202 203 } 204 } directlyCompositedImages; 205 206 TextureMapperGLData() 207 : currentProgram(TextureMapperGLData::ShaderInfo::TargetProgram) 208 { } 209 210 TransformationMatrix projectionMatrix; 211 int currentProgram; 212 213 #if OS(MAC_OS_X) 214 AGLContext aglContext; 215 #elif OS(UNIX) 216 Drawable glxDrawable; 217 GLXContext glxContext; 218 #endif 219 }; 220 221 TextureMapperGLData::ShaderInfo TextureMapperGLData::shaderInfo; 222 93 223 class BitmapTextureGL : public BitmapTexture { 94 224 public: … … 112 242 IntSize m_actualSize; 113 243 bool m_surfaceNeedsReset; 244 RefPtr<TextureMapperGL> m_textureMapper; 114 245 BitmapTextureGL() 115 246 : m_id(0) … … 124 255 }; 125 256 126 static struct TexmapShaderInfo {127 enum ShaderProgramIndex {128 SimpleProgram,129 OpacityAndMaskProgram,130 TargetProgram,131 NumPrograms132 };133 134 enum ShaderVariableIndex {135 InMatrixVariable,136 InSourceMatrixVariable,137 InMaskMatrixVariable,138 InVertexVariable,139 140 OpacityVariable,141 SourceTextureVariable,142 MaskTextureVariable,143 NumVariables144 };145 146 struct ProgramInfo {147 GLuint id;148 GLint vars[NumVariables];149 };150 151 GLint getUniformLocation(ShaderProgramIndex prog, ShaderVariableIndex var, const char* name)152 {153 return programs[prog].vars[var] = glGetUniformLocation(programs[prog].id, name);154 }155 156 void createShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource, ShaderProgramIndex index)157 {158 GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);159 GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);160 GL_CMD(glShaderSource(vertexShader, 1, &vertexShaderSource, 0))161 GL_CMD(glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0))162 GLuint programID = glCreateProgram();163 GL_CMD(glCompileShader(vertexShader))164 GL_CMD(glCompileShader(fragmentShader))165 GL_CMD(glAttachShader(programID, vertexShader))166 GL_CMD(glAttachShader(programID, fragmentShader))167 GL_CMD(glBindAttribLocation(programID, 0, "InVertex"))168 GL_CMD(glLinkProgram(programID))169 programs[index].id = programID;170 }171 172 ProgramInfo programs[NumPrograms];173 174 } gShaderInfo;175 176 257 #define TEXMAP_GET_SHADER_VAR_LOCATION(prog, var) \ 177 if (gShaderInfo.getUniformLocation(TexmapShaderInfo::prog##Program, TexmapShaderInfo::var##Variable, #var) < 0) \ 178 LOG_ERROR("Couldn't find variable "#var" in program "#prog"\n"); 179 #define TEXMAP_BUILD_SHADER(program) gShaderInfo.createShaderProgram(vertexShaderSource##program, fragmentShaderSource##program, TexmapShaderInfo::program##Program); 180 181 TextureMapperGL::TextureMapperGL(GraphicsContext* context) 182 : TextureMapper(context) 183 , m_currentProgram(TexmapShaderInfo::TargetProgram) 258 if (TextureMapperGLData::shaderInfo.getUniformLocation(TextureMapperGLData::shaderInfo.prog##Program, TextureMapperGLData::shaderInfo.var##Variable, #var) < 0) \ 259 LOG_ERROR("Couldn't find variable "#var" in program "#prog"\n"); 260 261 #define TEXMAP_BUILD_SHADER(program) \ 262 TextureMapperGLData::shaderInfo.createShaderProgram(vertexShaderSource##program, fragmentShaderSource##program, TextureMapperGLData::shaderInfo.program##Program); 263 264 TextureMapperGL::TextureMapperGL() 265 : m_data(new TextureMapperGLData) 184 266 { 185 267 static bool shadersCompiled = false; … … 283 365 const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture); 284 366 285 Tex mapShaderInfo::ShaderProgramIndex program;367 TextureMapperGLData::ShaderInfo::ShaderProgramIndex program; 286 368 if (maskTexture) 287 program = Tex mapShaderInfo::OpacityAndMaskProgram;369 program = TextureMapperGLData::ShaderInfo::OpacityAndMaskProgram; 288 370 else 289 program = Tex mapShaderInfo::SimpleProgram;290 291 const Tex mapShaderInfo::ProgramInfo& programInfo = gShaderInfo.programs[program];292 if ( m_currentProgram != program) {371 program = TextureMapperGLData::ShaderInfo::SimpleProgram; 372 373 const TextureMapperGLData::ShaderInfo::ProgramInfo& programInfo = data().shaderInfo.programs[program]; 374 if (data().currentProgram != program) { 293 375 GL_CMD(glUseProgram(programInfo.id)) 294 GL_CMD(glDisableVertexAttribArray(g ShaderInfo.programs[m_currentProgram].vars[TexmapShaderInfo::InVertexVariable]))295 m_currentProgram = program;296 GL_CMD(glEnableVertexAttribArray( programInfo.vars[TexmapShaderInfo::InVertexVariable]))376 GL_CMD(glDisableVertexAttribArray(gInVertexAttributeIndex)) 377 data().currentProgram = program; 378 GL_CMD(glEnableVertexAttribArray(gInVertexAttributeIndex)) 297 379 } 298 380 … … 306 388 GL_CMD(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, unitRect)) 307 389 308 TransformationMatrix matrix = TransformationMatrix( m_projectionMatrix).multLeft(modelViewMatrix).multLeft(TransformationMatrix(390 TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multLeft(modelViewMatrix).multLeft(TransformationMatrix( 309 391 targetRect.width(), 0, 0, 0, 310 392 0, targetRect.height(), 0, 0, … … 322 404 0, 0, 1, 0, 323 405 0, 0, 0, 1}; 324 GL_CMD(glUniformMatrix4fv(programInfo.vars[Tex mapShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))325 GL_CMD(glUniformMatrix4fv(programInfo.vars[Tex mapShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))326 GL_CMD(glUniform1i(programInfo.vars[Tex mapShaderInfo::SourceTextureVariable], 0))327 GL_CMD(glUniform1f(programInfo.vars[Tex mapShaderInfo::OpacityVariable], opacity))406 GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMatrixVariable], 1, GL_FALSE, m4)) 407 GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src)) 408 GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::SourceTextureVariable], 0)) 409 GL_CMD(glUniform1f(programInfo.vars[TextureMapperGLData::ShaderInfo::OpacityVariable], opacity)) 328 410 329 411 if (maskTexture && maskTexture->isValid()) { … … 335 417 0, 0, 1, 0, 336 418 0, 0, 0, 1}; 337 glUniformMatrix4fv(programInfo.vars[Tex mapShaderInfo::InMaskMatrixVariable], 1, GL_FALSE, m4mask);338 GL_CMD(glUniform1i(programInfo.vars[Tex mapShaderInfo::MaskTextureVariable], 1))419 glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMaskMatrixVariable], 1, GL_FALSE, m4mask); 420 GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::MaskTextureVariable], 1)) 339 421 GL_CMD(glActiveTexture(GL_TEXTURE0)) 340 422 } … … 400 482 } 401 483 402 struct TexmapGLShaderTextures {403 struct Entry {404 GLuint texture;405 int refCount;406 };407 HashMap<NativeImagePtr, Entry> imageToTexture;408 GLuint findOrCreate(NativeImagePtr image, bool& found)409 {410 HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);411 found = false;412 if (it != imageToTexture.end()) {413 it->second.refCount++;414 found = true;415 return it->second.texture;416 }417 Entry entry;418 GL_CMD(glGenTextures(1, &entry.texture));419 entry.refCount = 1;420 imageToTexture.add(image, entry);421 return entry.texture;422 }423 424 bool deref(NativeImagePtr image)425 {426 HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);427 if (it != imageToTexture.end()) {428 if (it->second.refCount < 2) {429 imageToTexture.remove(it);430 return false;431 }432 }433 return true;434 }435 };436 437 static TexmapGLShaderTextures gTextureRepository;438 439 484 void BitmapTextureGL::setContentsToImage(Image* image) 440 485 { … … 449 494 return; 450 495 bool found = false; 451 GLuint newTextureID = gTextureRepository.findOrCreate(nativeImage, found);496 GLuint newTextureID = m_textureMapper->data().directlyCompositedImages.findOrCreate(nativeImage, found); 452 497 if (newTextureID != m_id) { 453 498 destroy(); … … 465 510 void BitmapTextureGL::destroy() 466 511 { 467 if (m_id && (!m_image || ! gTextureRepository.deref(m_image)))512 if (m_id && (!m_image || !m_textureMapper->data().directlyCompositedImages.deref(m_image))) 468 513 GL_CMD(glDeleteTextures(1, &m_id)) 469 514 if (m_fbo) … … 494 539 } 495 540 496 void TextureMapperGL::cleanup() 497 { 541 TextureMapperGL::~TextureMapperGL() 542 { 543 makeContextCurrent(); 544 delete m_data; 545 } 546 547 bool TextureMapperGL::makeContextCurrent() 548 { 549 #if OS(MAC_OS_X) 550 return aglSetCurrentContext(data().aglContext); 551 #elif OS(UNIX) 552 Display* display = XOpenDisplay(0); 553 if (!display) 554 return false; 555 return glXMakeCurrent(display, data().glxDrawable, data().glxContext); 556 #endif 557 } 558 559 void TextureMapperGL::obtainCurrentContext() 560 { 561 #if OS(MAC_OS_X) 562 data().aglContext = aglGetCurrentContext(); 563 #elif OS(UNIX) 564 data().glxDrawable = glXGetCurrentDrawable(); 565 data().glxContext = glXGetCurrentContext(); 566 #endif 498 567 } 499 568 … … 504 573 if (!surface) 505 574 return; 575 506 576 TransformationMatrix matrix = createProjectionMatrix(surface->size(), false); 507 577 matrix.translate(-surface->offset().x(), -surface->offset().y()); … … 521 591 522 592 GL_CMD(glViewport(0, 0, surface->size().width(), surface->size().height())) 523 m_projectionMatrix = matrix;593 data().projectionMatrix = matrix; 524 594 } 525 595 … … 541 611 0, surface.m_actualSize.height(), 0, 0, 542 612 0, 0, 1, 0, 543 surface.offset().x(), surface.offset().y(), 0, 1 544 ) 613 surface.offset().x(), surface.offset().y(), 0, 1) 545 614 ); 546 615 … … 558 627 559 628 // We already blended the alpha in; the result is premultiplied. 560 GL_CMD(glUseProgram( gShaderInfo.programs[TexmapShaderInfo::TargetProgram].id))629 GL_CMD(glUseProgram(data().shaderInfo.programs[TextureMapperGLData::ShaderInfo::TargetProgram].id)) 561 630 GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, 0)) 562 631 GL_CMD(glViewport(0, 0, surfaceSize.width(), surfaceSize.height())) 563 632 GL_CMD(glDisable(GL_STENCIL_TEST)) 564 const Tex mapShaderInfo::ProgramInfo& programInfo = gShaderInfo.programs[TexmapShaderInfo::TargetProgram];565 GL_CMD(glUniform1f(programInfo.vars[Tex mapShaderInfo::OpacityVariable], opacity))633 const TextureMapperGLData::ShaderInfo::ProgramInfo& programInfo = data().shaderInfo.programs[TextureMapperGLData::ShaderInfo::TargetProgram]; 634 GL_CMD(glUniform1f(programInfo.vars[TextureMapperGLData::ShaderInfo::OpacityVariable], opacity)) 566 635 GL_CMD(glActiveTexture(GL_TEXTURE0)) 567 636 GL_CMD(glBindTexture(GL_TEXTURE_2D, surface.m_id)) 568 GL_CMD(glUniform1i(programInfo.vars[Tex mapShaderInfo::SourceTextureVariable], 0))569 GL_CMD(glEnableVertexAttribArray( programInfo.vars[TexmapShaderInfo::InVertexVariable]))570 GL_CMD(glUniformMatrix4fv(programInfo.vars[Tex mapShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))571 GL_CMD(glUniformMatrix4fv(programInfo.vars[Tex mapShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))637 GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::SourceTextureVariable], 0)) 638 GL_CMD(glEnableVertexAttribArray(gInVertexAttributeIndex)) 639 GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMatrixVariable], 1, GL_FALSE, m4)) 640 GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src)) 572 641 GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0)) 573 642 const GLfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1}; … … 578 647 579 648 GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)) 580 GL_CMD(glDisableVertexAttribArray( programInfo.vars[TexmapShaderInfo::InVertexVariable]))649 GL_CMD(glDisableVertexAttribArray(0)) 581 650 GL_CMD(glUseProgram(0)) 582 651 GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0)) 583 m_currentProgram = TexmapShaderInfo::TargetProgram;652 data().currentProgram = TextureMapperGLData::ShaderInfo::TargetProgram; 584 653 } 585 654 586 655 PassRefPtr<BitmapTexture> TextureMapperGL::createTexture() 587 656 { 588 return adoptRef(new BitmapTextureGL()); 657 BitmapTextureGL* texture = new BitmapTextureGL(); 658 texture->m_textureMapper = this; 659 return adoptRef(texture); 589 660 } 590 661 -
trunk/WebCore/platform/graphics/opengl/TextureMapperGL.h
r70452 r71213 30 30 namespace WebCore { 31 31 32 class TextureMapperGLData; 33 32 34 // An OpenGL-ES2 implementation of TextureMapper. 33 35 class TextureMapperGL : public TextureMapper { 34 36 public: 35 TextureMapperGL( GraphicsContext* gc);36 virtual ~TextureMapperGL() {}37 TextureMapperGL(); 38 virtual ~TextureMapperGL(); 37 39 38 40 // reimps from TextureMapper … … 44 46 virtual PassRefPtr<BitmapTexture> createTexture(); 45 47 virtual const char* type() const; 46 virtual void cleanup(); 48 void obtainCurrentContext(); 49 bool makeContextCurrent(); 47 50 48 51 private: 49 TransformationMatrix m_projectionMatrix; 50 int m_currentProgram; 52 inline TextureMapperGLData& data() { return *m_data; } 53 TextureMapperGLData* m_data; 54 friend class BitmapTextureGL; 51 55 }; 52 56 -
trunk/WebCore/platform/graphics/qt/TextureMapperQt.cpp
r69374 r71213 55 55 virtual void bindSurface(BitmapTexture* surface); 56 56 virtual void setClip(const IntRect&); 57 virtual void setGraphicsContext(GraphicsContext*); 57 58 virtual bool allowSurfaceForRoot() const { return false; } 58 TextureMapperQt( GraphicsContext* context);59 TextureMapperQt(); 59 60 virtual const char* type() const { return "TextureMapperQt"; } 60 61 virtual PassRefPtr<BitmapTexture> createTexture(); … … 124 125 } 125 126 126 TextureMapperQt::TextureMapperQt(GraphicsContext* context) 127 : TextureMapper(context) 128 , m_painter(context->platformContext()) 129 , m_currentSurface(0) 130 { 131 TextureMapperQt::initialize(m_painter); 127 TextureMapperQt::TextureMapperQt() 128 : m_currentSurface(0) 129 { 130 } 131 132 void TextureMapperQt::setGraphicsContext(GraphicsContext* context) 133 { 134 m_painter = context->platformContext(); 135 initialize(m_painter); 132 136 } 133 137 … … 182 186 { 183 187 #ifdef QT_OPENGL_LIB 184 if (context->platformContext()->paintEngine()->type() == QPaintEngine::OpenGL2) 185 return adoptRef(new TextureMapperGL(context)); 188 if (context->platformContext()->paintEngine()->type() == QPaintEngine::OpenGL2) { 189 TextureMapperGL* texmapGL = new TextureMapperGL; 190 return adoptRef(texmapGL); 191 } 186 192 #endif 187 return adoptRef(new TextureMapperQt (context));193 return adoptRef(new TextureMapperQt); 188 194 } 189 195 -
trunk/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
r70819 r71213 41 41 BitmapTexture* surface; 42 42 TextureMapper* textureMapper; 43 GraphicsContext* context;44 43 TextureMapperNode* rootLayer; 45 44 float opacity; … … 215 214 216 215 virtual void setPlatformLayerClient(TextureMapperLayerClient*); 217 virtual void paint( GraphicsContext*, const IntSize&, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity);216 virtual void paint(TextureMapper*, const TextureMapperContentLayer::PaintOptions&); 218 217 219 218 static TextureMapperNode* toTextureMapperNode(GraphicsLayer*); … … 399 398 } 400 399 401 void TextureMapperNode::paint( GraphicsContext* context, const IntSize& size, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity)400 void TextureMapperNode::paint(TextureMapper* textureMapper, const TextureMapperContentLayer::PaintOptions& options) 402 401 { 403 402 ASSERT(m_layerType == RootLayer); … … 410 409 #endif 411 410 412 RefPtr<TextureMapper> textureMapper = TextureMapper::create(context);413 414 411 if (textureMapper->type() != m_lastTextureMapperType) 415 412 gTextureMapperCache.m_data.clear(); … … 419 416 opt.opacity = 1; 420 417 opt.rootLayer = this; 421 opt.scissorRect = targetRect; 422 opt.visibleRect = exposedRect; 423 opt.textureMapper = textureMapper.get(); 424 opt.context = textureMapper->graphicsContext(); 418 opt.scissorRect = options.targetRect; 419 opt.visibleRect = options.visibleRect; 420 opt.textureMapper = textureMapper; 425 421 opt.surface = 0; 426 422 paintRecursive(opt); … … 428 424 if (textureMapper->allowSurfaceForRoot() || m_state.hasSurfaceDescendants) { 429 425 textureMapper->bindSurface(0); 430 textureMapper->paintToTarget(*m_surface.get(), size, transform, opacity * m_state.opacity,targetRect);426 textureMapper->paintToTarget(*m_surface.get(), options.viewportSize, options.transform, options.opacity * m_state.opacity, options.targetRect); 431 427 } 432 428 gTextureMapperCache.purge(); … … 693 689 { 694 690 GraphicsContext context(m_texture->beginPaint(dirtyRect)); 695 if (textureMapper && textureMapper->graphicsContext()) { 696 GraphicsContext* originalContext = textureMapper->graphicsContext(); 697 context.setImageInterpolationQuality(originalContext->imageInterpolationQuality()); 698 context.setTextDrawingMode(originalContext->textDrawingMode()); 691 if (textureMapper) { 692 context.setImageInterpolationQuality(textureMapper->imageInterpolationQuality()); 693 context.setTextDrawingMode(textureMapper->textDrawingMode()); 699 694 } 700 695 m_layer->paintGraphicsLayerContents(context, dirtyRect); -
trunk/WebCore/platform/graphics/texmap/TextureMapper.h
r69374 r71213 98 98 } 99 99 100 virtual void setGraphicsContext(GraphicsContext*) { } 100 101 virtual void setClip(const IntRect&) = 0; 101 102 virtual bool allowSurfaceForRoot() const = 0; … … 104 105 virtual void cleanup() {} 105 106 106 GraphicsContext* graphicsContext() const 107 { 108 return m_gc; 109 } 107 void setImageInterpolationQuality(InterpolationQuality quality) { m_interpolationQuality = quality; } 108 void setTextDrawingMode(int mode) { m_textDrawingMode = mode; } 109 110 InterpolationQuality imageInterpolationQuality() const { return m_interpolationQuality; } 111 int textDrawingMode() const { return m_textDrawingMode; } 112 113 void setViewportSize(const IntSize&); 110 114 111 115 protected: 112 TextureMapper(GraphicsContext* gc) : m_gc(gc) {} 113 GraphicsContext* m_gc; 116 TextureMapper() 117 : m_interpolationQuality(InterpolationDefault) 118 , m_textDrawingMode(cTextFill) 119 {} 120 121 private: 122 InterpolationQuality m_interpolationQuality; 123 int m_textDrawingMode; 114 124 }; 115 125 -
trunk/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
r69374 r71213 26 26 class IntRect; 27 27 class IntSize; 28 class TextureMapper; 28 29 class TransformationMatrix; 29 30 … … 51 52 class TextureMapperContentLayer : public TextureMapperPlatformLayer { 52 53 public: 54 struct PaintOptions { 55 IntRect visibleRect; 56 IntRect targetRect; 57 IntSize viewportSize; 58 TransformationMatrix transform; 59 float opacity; 60 }; 61 53 62 virtual void setPlatformLayerClient(TextureMapperLayerClient*) = 0; 54 virtual void paint( GraphicsContext*, const IntSize&, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity) {}63 virtual void paint(TextureMapper*, const PaintOptions&) {} 55 64 virtual IntSize size() const = 0; 56 virtual void cleanupTextureMapper() {}57 65 virtual Type layerType() const { return ContentLayer; } 58 66 }; -
trunk/WebKit/qt/Api/qwebframe.cpp
r70976 r71213 98 98 #endif 99 99 #if USE(TEXTURE_MAPPER) 100 #include "texmap/TextureMapper.h" 100 101 #include "texmap/TextureMapperPlatformLayer.h" 101 102 #endif … … 295 296 painter->restore(); 296 297 } 298 297 299 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 298 // TextureMapper might use raw OpenGL or some other backend that requires native painting. On raster this doesn't have any effect. 299 if (rootGraphicsLayer) { 300 painter->beginNativePainting(); 301 rootGraphicsLayer->paint(context, view->size(), view->frameRect(), IntRect(clip.boundingRect()), TransformationMatrix(), painter->opacity()); 302 painter->endNativePainting(); 303 } 304 300 renderCompositedLayers(context, IntRect(clip.boundingRect())); 305 301 renderRelativeCoords(context, (QWebFrame::RenderLayer)(QWebFrame::ScrollBarLayer | QWebFrame::PanIconLayer), clip); 306 302 #endif 303 } 304 #endif 305 306 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 307 void QWebFramePrivate::renderCompositedLayers(GraphicsContext* context, const IntRect& clip) 308 { 309 if (!rootGraphicsLayer) 310 return; 311 312 if (!textureMapper) 313 textureMapper = TextureMapper::create(context); 314 315 textureMapper->setGraphicsContext(context); 316 textureMapper->setImageInterpolationQuality(context->imageInterpolationQuality()); 317 textureMapper->setTextDrawingMode(context->textDrawingMode()); 318 QPainter* painter = context->platformContext(); 319 FrameView* view = frame->view(); 320 painter->save(); 321 painter->beginNativePainting(); 322 TextureMapperContentLayer::PaintOptions options; 323 options.visibleRect = clip; 324 options.targetRect = view->frameRect(); 325 options.viewportSize = view->size(); 326 options.opacity = painter->opacity(); 327 rootGraphicsLayer->paint(textureMapper.get(), options); 328 painter->endNativePainting(); 329 painter->restore(); 307 330 } 308 331 #endif … … 350 373 } 351 374 painter->restore(); 352 353 375 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 354 if (rootGraphicsLayer) { 355 painter->save(); 356 painter->beginNativePainting(); 357 rootGraphicsLayer->paint(context, view->size(), view->frameRect(), IntRect(clip.boundingRect()), 358 TransformationMatrix(), context->platformContext()->opacity()); 359 painter->endNativePainting(); 360 painter->restore(); 361 } 376 renderCompositedLayers(context, IntRect(clip.boundingRect())); 362 377 #endif 363 378 } -
trunk/WebKit/qt/Api/qwebframe_p.h
r70487 r71213 33 33 #include "Frame.h" 34 34 #include "ViewportArguments.h" 35 36 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 37 #include "texmap/TextureMapper.h" 38 #endif 35 39 36 40 namespace WebCore { … … 95 99 #endif 96 100 101 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 102 void renderCompositedLayers(WebCore::GraphicsContext* context, const WebCore::IntRect& clip); 103 #endif 97 104 QWebFrame *q; 98 105 Qt::ScrollBarPolicy horizontalScrollBarPolicy; … … 107 114 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) 108 115 WebCore::TextureMapperContentLayer* rootGraphicsLayer; 116 RefPtr<WebCore::TextureMapper> textureMapper; 109 117 #endif 110 118 bool zoomTextOnly; -
trunk/WebKit/qt/ChangeLog
r71041 r71213 1 2010-11-02 Noam Rosenthal <noam.rosenthal@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 Some refactor for texmap to enable WebKit2: remove globals, and allow TextureMapper to exist without a GraphicsContext. 6 This will allow rendering the TextureMapperNode tree without an active QPainter, into the current GL context. 7 Most of the changes simply move the globas in TextureMapperGL into members of that class. 8 9 [Texmap] [Qt] Texture mapper initial implementation 10 https://bugs.webkit.org/show_bug.cgi?id=47070 11 12 * Api/qwebframe.cpp: 13 (QWebFramePrivate::renderFromTiledBackingStore): 14 (QWebFramePrivate::renderCompositedLayers): 15 (QWebFramePrivate::renderRelativeCoords): 16 * Api/qwebframe_p.h: 17 1 18 2010-11-01 Brady Eidson <beidson@apple.com> 2 19
Note: See TracChangeset
for help on using the changeset viewer.