WebSize WebRemoteFrameImpl::contentsSize() const { ASSERT_NOT_REACHED(); return WebSize(); }
void WebMediaPlayerClientImpl::setSize(const IntSize& size) { if (m_webMediaPlayer.get()) m_webMediaPlayer->setSize(WebSize(size.width(), size.height())); }
WebSize WebRemoteFrameImpl::scrollOffset() const { ASSERT_NOT_REACHED(); return WebSize(); }
void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) { if (m_client) m_client->applyScrollAndScale(WebSize(scrollDelta), pageScale); }
WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::handleGestureFling(const WebGestureEvent& gestureEvent) { WebInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(WebPoint(gestureEvent.x, gestureEvent.y), WebInputHandlerClient::ScrollInputTypeGesture); switch (scrollStatus) { case WebInputHandlerClient::ScrollStatusStarted: { if (gestureEvent.data.flingStart.sourceDevice == WebGestureEvent::Touchpad) m_inputHandlerClient->scrollEnd(); m_flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(gestureEvent.data.flingStart.sourceDevice, WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY), WebSize())); TRACE_EVENT_ASYNC_BEGIN0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::started", this); m_flingParameters.delta = WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY); m_flingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y); m_flingParameters.globalPoint = WebPoint(gestureEvent.globalX, gestureEvent.globalY); m_flingParameters.modifiers = gestureEvent.modifiers; m_flingParameters.sourceDevice = gestureEvent.data.flingStart.sourceDevice; m_inputHandlerClient->scheduleAnimation(); return DidHandle; } case WebInputHandlerClient::ScrollStatusOnMainThread: { TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread"); m_flingActiveOnMainThread = true; return DidNotHandle; } case WebInputHandlerClient::ScrollStatusIgnored: { TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::ignored"); if (gestureEvent.data.flingStart.sourceDevice == WebGestureEvent::Touchpad) { // We still pass the curve to the main thread if there's nothing scrollable, in case something // registers a handler before the curve is over. return DidNotHandle; } return DropEvent; } } return DidNotHandle; }
WebSize WebLayerTreeView::viewportSize() const { return WebSize(m_private->viewportSize()); }
void loadFrame(const std::string& fileName) { FrameTestHelpers::loadFrame(mainFrame(), m_baseURL + fileName); webView()->resize(WebSize(800, 600)); webView()->updateAllLifecyclePhases(); }
WebSize WebLayer::bounds() const { return WebSize(m_private->bounds()); }
bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, GLuint texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY) { if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFormat, destType, level)) return false; if (!isSurfaceValid()) return false; RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAcceleration, SnapshotReasonCopyToWebGLTexture); if (!textureImage) return false; if (!m_surface->isAccelerated()) return false; ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above should guarantee this // Get the texture ID, flushing pending operations if needed. const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo(textureImage->getTextureHandle(true)); if (!textureInfo || !textureInfo->fID) return false; std::unique_ptr<WebGraphicsContext3DProvider> provider = wrapUnique(Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); if (!provider) return false; gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); std::unique_ptr<WebExternalTextureMailbox> mailbox = wrapUnique(new WebExternalTextureMailbox); mailbox->textureSize = WebSize(textureImage->width(), textureImage->height()); // Contexts may be in a different share group. We must transfer the texture through a mailbox first sharedGL->GenMailboxCHROMIUM(mailbox->name); sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarget, mailbox->name); const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); sharedGL->Flush(); sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, mailbox->syncToken); mailbox->validSyncToken = true; gl->WaitSyncTokenCHROMIUM(mailbox->syncToken); GLuint sourceTexture = gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox->name); // The canvas is stored in a premultiplied format, so unpremultiply if necessary. // The canvas is stored in an inverted position, so the flip semantics are reversed. gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE); gl->DeleteTextures(1, &sourceTexture); const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); gl->Flush(); GLbyte syncToken[24]; gl->GenSyncTokenCHROMIUM(contextFenceSync, syncToken); sharedGL->WaitSyncTokenCHROMIUM(syncToken); // Undo grContext texture binding changes introduced in this function provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); return true; }
void WebLayerTreeViewImpl::applyScrollDelta(const WebCore::IntSize& delta) { if (m_client) m_client->applyScrollDelta(WebSize(delta)); }
WebSize WebImage::size() const { return WebSize(m_bitmap.width(), m_bitmap.height()); }
bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap) { if (m_destructionInProgress) { // It can be hit in the following sequence. // 1. WebGL draws something. // 2. The compositor begins the frame. // 3. Javascript makes a context lost using WEBGL_lose_context extension. // 4. Here. return false; } ASSERT(!m_isHidden); if (!m_contentsChanged) return false; if (m_newMailboxCallback) (*m_newMailboxCallback)(); // Resolve the multisampled buffer into m_colorBuffer texture. if (m_antiAliasingMode != None) commit(); if (bitmap) { bitmap->setSize(size()); unsigned char* pixels = bitmap->pixels(); bool needPremultiply = m_wantAlphaChannel && !m_premultipliedAlpha; WebGLImageConversion::AlphaOp op = needPremultiply ? WebGLImageConversion::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing; if (pixels) readBackFramebuffer(pixels, size().width(), size().height(), ReadbackSkia, op); } // We must restore the texture binding since creating new textures, // consuming and producing mailboxes changes it. ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_texture2DBinding); // First try to recycle an old buffer. RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); // No buffer available to recycle, create a new one. if (!frontColorBufferMailbox) frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemory(m_size)); if (m_preserveDrawingBuffer == Discard) { std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); attachColorBufferToReadFramebuffer(); if (m_discardFramebufferSupported) { // Explicitly discard framebuffer to save GPU memory bandwidth for tile-based GPU arch. const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT }; m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); } } else { m_gl->CopyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.internalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); } restoreFramebufferBindings(); m_contentsChanged = false; m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferMailbox->mailbox.name); const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); m_gl->Flush(); m_gl->GenSyncTokenCHROMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncToken); frontColorBufferMailbox->mailbox.validSyncToken = true; frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->textureInfo.imageId != 0; frontColorBufferMailbox->mailbox.textureTarget = frontColorBufferMailbox->textureInfo.parameters.target; frontColorBufferMailbox->mailbox.textureSize = WebSize(m_size.width(), m_size.height()); setBufferClearNeeded(true); // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it has live mailboxes ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); frontColorBufferMailbox->m_parentDrawingBuffer = this; *outMailbox = frontColorBufferMailbox->mailbox; m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBufferMailbox->mailbox }; return true; }
WebSize WebLayerTreeViewImplForTesting::getViewportSize() const { return WebSize( m_layerTreeHost->GetLayerTree()->device_viewport_size().width(), m_layerTreeHost->GetLayerTree()->device_viewport_size().height()); }
WebSize WebLayerTreeView::deviceViewportSize() const { return WebSize(m_private->layerTreeHost()->deviceViewportSize()); }