Changeset 278657 in webkit
- Timestamp:
- Jun 9, 2021, 5:36:07 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
- 1 copied
- 1 moved
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/gtk/GRefPtrGtk.cpp (modified) (1 diff)
-
WebCore/platform/gtk/GRefPtrGtk.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/SourcesGTK.txt (modified) (1 diff)
-
WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (2 diffs)
-
WebKit/UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp (modified) (1 diff)
-
WebKit/UIProcess/ViewGestureController.h (modified) (3 diffs)
-
WebKit/UIProcess/ViewSnapshotStore.cpp (modified) (2 diffs)
-
WebKit/UIProcess/ViewSnapshotStore.h (modified) (5 diffs)
-
WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (modified) (9 diffs)
-
WebKit/UIProcess/gtk/ViewSnapshotStoreGtk3.cpp (copied) (copied from trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp ) (3 diffs)
-
WebKit/UIProcess/gtk/ViewSnapshotStoreGtk4.cpp (moved) (moved from trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp ) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278655 r278657 1 2021-06-09 Alexander Mikhaylenko <alexm@gnome.org> 2 3 [GTK4] Add support for navigation gestures 4 https://bugs.webkit.org/show_bug.cgi?id=212327 5 6 Reviewed by Michael Catanzaro. 7 8 Support GskRenderNode for GRefPtr. 9 10 * platform/gtk/GRefPtrGtk.cpp: 11 (WTF::refGPtr): 12 (WTF::derefGPtr): 13 * platform/gtk/GRefPtrGtk.h: 14 1 15 2021-06-09 Alicia Boya García <aboya@igalia.com> 2 16 -
trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp
r260752 r278657 77 77 #endif 78 78 79 #if USE(GTK4) 80 template <> GskRenderNode* refGPtr(GskRenderNode* ptr) 81 { 82 if (ptr) 83 gsk_render_node_ref(ptr); 84 return ptr; 79 85 } 86 87 template <> void derefGPtr(GskRenderNode* ptr) 88 { 89 if (ptr) 90 gsk_render_node_unref(ptr); 91 } 92 #endif 93 94 } -
trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h
r260752 r278657 25 25 typedef struct _GtkWidgetPath GtkWidgetPath; 26 26 typedef struct _SecretValue SecretValue; 27 typedef struct _GskRenderNode GskRenderNode; 27 28 28 29 namespace WTF { … … 43 44 #endif 44 45 46 #if USE(GTK4) 47 template <> GskRenderNode* refGPtr(GskRenderNode* ptr); 48 template <> void derefGPtr(GskRenderNode* ptr); 49 #endif 50 45 51 } 46 52 -
trunk/Source/WebKit/ChangeLog
r278651 r278657 1 2021-06-09 Alexander Mikhaylenko <alexm@gnome.org> 2 3 [GTK4] Add support for navigation gestures 4 https://bugs.webkit.org/show_bug.cgi?id=212327 5 6 Reviewed by Michael Catanzaro. 7 8 Make ViewSnapshotStore store GdkTexture instead of Cairo surfaces 9 for GTK4. Split ViewSnapshotStoreGtk.cpp into GTK3 and GTK4 versions 10 since they don't have much in common. 11 12 When taking a view snapshot, render the web view into a texture. 13 14 When starting a navigation gesture, create a render node from 15 either the texture, or a fallback color, then render that instead 16 of using Cairo. 17 18 Implement the same dimming+shadow as in GTK3. This time don't bother 19 with CSS, the approach we used in GTK3 doesn't work anymore, and since 20 elements like scrollbars aren't themeable anyway it's not very important 21 to preserve that. 22 23 * SourcesGTK.txt: 24 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 25 (webkitWebViewBaseTakeViewSnapshot): 26 * UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp: 27 (WebKit::WebAutomationSession::platformGetBase64EncodedPNGData): 28 * UIProcess/ViewGestureController.h: 29 * UIProcess/ViewSnapshotStore.cpp: 30 (WebKit::ViewSnapshotStore::didAddImageToSnapshot): 31 (WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot): 32 * UIProcess/ViewSnapshotStore.h: 33 (WebKit::ViewSnapshot::estimatedImageSizeInBytes const): 34 (WebKit::ViewSnapshot::texture const): 35 (WebKit::ViewSnapshot::imageSizeInBytes const): Renamed to estimatedImageSizeInBytes(). 36 * UIProcess/gtk/ViewGestureControllerGtk.cpp: 37 (WebKit::ViewGestureController::beginSwipeGesture): 38 (WebKit::ViewGestureController::snapshot): 39 (WebKit::ViewGestureController::removeSwipeSnapshot): 40 * UIProcess/gtk/ViewSnapshotStoreGtk3.cpp: Copied from Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp. 41 (WebKit::ViewSnapshot::create): 42 (WebKit::ViewSnapshot::ViewSnapshot): 43 (WebKit::ViewSnapshot::hasImage const): 44 (WebKit::ViewSnapshot::clearImage): 45 (WebKit::ViewSnapshot::estimatedImageSizeInBytes const): 46 (WebKit::ViewSnapshot::size const): 47 * UIProcess/gtk/ViewSnapshotStoreGtk4.cpp: Renamed from Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp. 48 (WebKit::ViewSnapshot::create): 49 (WebKit::ViewSnapshot::ViewSnapshot): 50 (WebKit::ViewSnapshot::hasImage const): 51 (WebKit::ViewSnapshot::clearImage): 52 (WebKit::ViewSnapshot::estimatedImageSizeInBytes const): 53 (WebKit::ViewSnapshot::size const): 54 1 55 2021-06-09 Chris Dumez <cdumez@apple.com> 2 56 -
trunk/Source/WebKit/SourcesGTK.txt
r277172 r278657 260 260 UIProcess/gtk/PointerLockManagerX11.cpp @no-unify 261 261 UIProcess/gtk/TextCheckerGtk.cpp @no-unify 262 UIProcess/gtk/ViewSnapshotStoreGtk.cpp 262 UIProcess/gtk/ViewSnapshotStoreGtk3.cpp @no-unify 263 UIProcess/gtk/ViewSnapshotStoreGtk4.cpp @no-unify 263 264 UIProcess/gtk/ViewGestureControllerGtk.cpp 264 265 UIProcess/gtk/WaylandCompositor.cpp @no-unify -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r278301 r278657 2529 2529 size.scale(deviceScale); 2530 2530 2531 #if !USE(GTK4) 2531 2532 RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_RGB24, size.width(), size.height())); 2532 2533 cairo_surface_set_device_scale(surface.get(), deviceScale, deviceScale); … … 2538 2539 cairo_clip(cr.get()); 2539 2540 } 2540 #if !USE(GTK4)2541 2541 webkitWebViewBaseDraw(GTK_WIDGET(webkitWebViewBase), cr.get()); 2542 #endif2543 2542 2544 2543 return ViewSnapshot::create(WTFMove(surface)); 2544 #else 2545 WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; 2546 auto* renderer = gtk_native_get_renderer(GTK_NATIVE(priv->toplevelOnScreenWindow)); 2547 2548 GRefPtr<GtkSnapshot> snapshot = adoptGRef(gtk_snapshot_new()); 2549 2550 if (clipRect) { 2551 graphene_point_t point = { -static_cast<float>(clipRect->x()), -static_cast<float>(clipRect->y()) }; 2552 graphene_rect_t rect = { 2553 { static_cast<float>(clipRect->x()), static_cast<float>(clipRect->y()) }, 2554 { static_cast<float>(clipRect->width()), static_cast<float>(clipRect->height()) } 2555 }; 2556 2557 gtk_snapshot_translate(snapshot.get(), &point); 2558 gtk_snapshot_push_clip(snapshot.get(), &rect); 2559 } 2560 2561 gtk_snapshot_scale(snapshot.get(), deviceScale, deviceScale); 2562 webkitWebViewBaseSnapshot(GTK_WIDGET(webkitWebViewBase), snapshot.get()); 2563 2564 if (clipRect) 2565 gtk_snapshot_pop(snapshot.get()); 2566 2567 GRefPtr<GskRenderNode> renderNode = adoptGRef(gtk_snapshot_to_node(snapshot.get())); 2568 2569 graphene_rect_t viewport = { 0, 0, static_cast<float>(size.width()), static_cast<float>(size.height()) }; 2570 GdkTexture* texture = gsk_renderer_render_texture(renderer, renderNode.get(), &viewport); 2571 2572 return ViewSnapshot::create(WTFMove(texture)); 2573 #endif 2545 2574 } 2546 2575 -
trunk/Source/WebKit/UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp
r278253 r278657 65 65 std::optional<String> WebAutomationSession::platformGetBase64EncodedPNGData(const ViewSnapshot& snapshot) 66 66 { 67 #if PLATFORM(GTK) 67 #if PLATFORM(GTK) && !USE(GTK4) 68 68 return base64EncodedPNGData(snapshot.surface()); 69 69 #else -
trunk/Source/WebKit/UIProcess/ViewGestureController.h
r277172 r278657 41 41 42 42 #if PLATFORM(GTK) 43 #include <WebCore/CairoUtilities.h>44 43 #include <gtk/gtk.h> 45 44 #include <wtf/glib/GRefPtr.h> 45 46 #if USE(GTK4) 47 #include <WebCore/GRefPtrGtk.h> 48 #else 49 #include <WebCore/CairoUtilities.h> 50 #endif 46 51 #endif 47 52 … … 437 442 SwipeProgressTracker m_swipeProgressTracker; 438 443 444 #if USE(GTK4) 445 GRefPtr<GskRenderNode> m_currentSwipeSnapshotPattern; 446 #else 439 447 RefPtr<cairo_pattern_t> m_currentSwipeSnapshotPattern; 440 448 RefPtr<cairo_pattern_t> m_swipeDimmingPattern; … … 442 450 RefPtr<cairo_pattern_t> m_swipeBorderPattern; 443 451 RefPtr<cairo_pattern_t> m_swipeOutlinePattern; 452 444 453 int m_swipeShadowSize; 445 454 int m_swipeBorderSize; 446 455 int m_swipeOutlineSize; 447 456 GRefPtr<GtkCssProvider> m_cssProvider; 457 #endif 448 458 449 459 bool m_isSimulatedSwipe { false }; -
trunk/Source/WebKit/UIProcess/ViewSnapshotStore.cpp
r278185 r278657 59 59 bool isNewEntry = m_snapshotsWithImages.add(&snapshot).isNewEntry; 60 60 ASSERT_UNUSED(isNewEntry, isNewEntry); 61 m_snapshotCacheSize += snapshot. imageSizeInBytes();61 m_snapshotCacheSize += snapshot.estimatedImageSizeInBytes(); 62 62 } 63 63 … … 66 66 bool removed = m_snapshotsWithImages.remove(&snapshot); 67 67 ASSERT_UNUSED(removed, removed); 68 m_snapshotCacheSize -= snapshot. imageSizeInBytes();68 m_snapshotCacheSize -= snapshot.estimatedImageSizeInBytes(); 69 69 } 70 70 -
trunk/Source/WebKit/UIProcess/ViewSnapshotStore.h
r269824 r278657 37 37 38 38 #if PLATFORM(GTK) 39 #if USE(GTK4) 40 #include <gtk/gtk.h> 41 #else 39 42 #include <WebCore/RefPtrCairo.h> 43 #endif 40 44 #endif 41 45 … … 51 55 #endif 52 56 #if PLATFORM(GTK) 57 #if USE(GTK4) 58 static Ref<ViewSnapshot> create(GRefPtr<GdkTexture>&&); 59 #else 53 60 static Ref<ViewSnapshot> create(RefPtr<cairo_surface_t>&&); 61 #endif 54 62 #endif 55 63 … … 79 87 WebCore::IOSurface* surface() const { return m_surface.get(); } 80 88 81 size_t imageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; }89 size_t estimatedImageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; } 82 90 WebCore::IntSize size() const { return m_surface ? m_surface->size() : WebCore::IntSize(); } 83 91 … … 88 96 89 97 #if PLATFORM(GTK) 98 #if USE(GTK4) 99 GdkTexture* texture() const { return m_texture.get(); } 100 #else 90 101 cairo_surface_t* surface() const { return m_surface.get(); } 102 #endif 91 103 92 size_t imageSizeInBytes() const;104 size_t estimatedImageSizeInBytes() const; 93 105 WebCore::IntSize size() const; 94 106 #endif … … 102 114 103 115 #if PLATFORM(GTK) 116 #if USE(GTK4) 117 explicit ViewSnapshot(GRefPtr<GdkTexture>&&); 118 119 GRefPtr<GdkTexture> m_texture; 120 #else 104 121 explicit ViewSnapshot(RefPtr<cairo_surface_t>&&); 105 122 106 123 RefPtr<cairo_surface_t> m_surface; 124 #endif 107 125 #endif 108 126 -
trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp
r277172 r278657 49 49 static const double swipeCancelVelocityThreshold = 0.4; 50 50 51 #if USE(GTK4) 52 static const float swipeOverlayShadowOpacity = 0.06; 53 static const float swipeOverlayBorderOpacity = 0.05; 54 static const float swipeOverlayOutlineOpacity = 0.05; 55 static const float swipeOverlayDimmingOpacity = 0.12; 56 static const float swipeOverlayShadowWidth = 57; 57 static const GskColorStop swipeOverlayShadowStops[] = { 58 { 0, { 0, 0, 0, 0.08 } }, 59 { 0.125, { 0, 0, 0, 0.053 } }, 60 { 0.428, { 0, 0, 0, 0.026 } }, 61 { 0.714, { 0, 0, 0, 0.01 } }, 62 { 1, { 0, 0, 0, 0 } } 63 }; 64 #endif 65 51 66 static bool isEventStop(PlatformGtkScrollData* event) 52 67 { … … 310 325 return width; 311 326 } 327 312 328 #endif 313 329 … … 319 335 320 336 willBeginGesture(ViewGestureType::Swipe); 337 338 FloatSize viewSize(m_webPageProxy.viewSize()); 339 340 #if USE(GTK4) 341 graphene_rect_t bounds = { 0, 0, viewSize.width(), viewSize.height() }; 342 #endif 321 343 322 344 if (auto* snapshot = targetItem->snapshot()) { 323 345 m_currentSwipeSnapshot = snapshot; 324 346 325 FloatSize viewSize(m_webPageProxy.viewSize());326 347 if (snapshot->hasImage() && shouldUseSnapshotForSize(*snapshot, viewSize, 0)) 348 #if USE(GTK4) 349 m_currentSwipeSnapshotPattern = gsk_texture_node_new(snapshot->texture(), &bounds); 350 #else 327 351 m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_for_surface(snapshot->surface())); 352 #endif 328 353 329 354 Color color = snapshot->backgroundColor(); … … 332 357 if (!m_currentSwipeSnapshotPattern) { 333 358 auto [red, green, blue, alpha] = color.toSRGBALossy<float>(); 359 #if USE(GTK4) 360 GdkRGBA rgba = { red, green, blue, alpha }; 361 m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&rgba, &bounds)); 362 #else 334 363 m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgba(red, green, blue, alpha)); 364 #endif 335 365 } 336 366 } 337 367 } 338 368 339 #if !USE(GTK4)340 369 if (!m_currentSwipeSnapshotPattern) { 341 370 GdkRGBA color; 342 371 auto* context = gtk_widget_get_style_context(m_webPageProxy.viewWidget()); 343 372 if (gtk_style_context_lookup_color(context, "theme_base_color", &color)) 373 #if USE(GTK4) 374 m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&color, &bounds)); 375 #else 344 376 m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgba(color.red, color.green, color.blue, color.alpha)); 345 } 346 347 if (!m_currentSwipeSnapshotPattern) 377 #endif 378 } 379 380 if (!m_currentSwipeSnapshotPattern) { 381 #if USE(GTK4) 382 GdkRGBA color = { 1, 1, 1, 1 }; 383 m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&color, &bounds)); 384 #else 348 385 m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgb(1, 1, 1)); 349 386 #endif 387 } 388 389 #if !USE(GTK4) 350 390 auto size = m_webPageProxy.drawingArea()->size(); 351 391 … … 405 445 double scale = m_webPageProxy.deviceScaleFactor(); 406 446 407 doubleswipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale;408 409 doubledimmingProgress = swipingLeft ? 1 - progress : -progress;447 float swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale; 448 449 float dimmingProgress = swipingLeft ? 1 - progress : -progress; 410 450 if (isRTL) { 411 451 dimmingProgress = 1 - dimmingProgress; … … 413 453 } 414 454 455 float remainingSwipeDistance = dimmingProgress * width; 456 457 float shadowOpacity = 1; 458 if (remainingSwipeDistance < swipeOverlayShadowWidth) 459 shadowOpacity = remainingSwipeDistance / swipeOverlayShadowWidth; 460 415 461 gtk_snapshot_save(snapshot); 416 462 417 graphene_point_t translation = { static_cast<float>(swipingLayerOffset), 0 }; 463 graphene_rect_t clip = { 0, 0, static_cast<float>(size.width()), static_cast<float>(size.height()) }; 464 gtk_snapshot_push_clip(snapshot, &clip); 465 466 graphene_point_t translation = { swipingLayerOffset, 0 }; 418 467 if (!swipingBack) { 419 468 gtk_snapshot_append_node(snapshot, pageRenderNode); … … 421 470 } 422 471 423 graphene_rect_t rect = { 0, 0, (float)width, (float)height }; 424 auto* cr = gtk_snapshot_append_cairo(snapshot, &rect); 425 cairo_set_source(cr, m_currentSwipeSnapshotPattern.get()); 426 cairo_rectangle(cr, 0, 0, width, height); 427 cairo_fill(cr); 472 gtk_snapshot_append_node(snapshot, m_currentSwipeSnapshotPattern.get()); 428 473 429 474 if (swipingBack) { … … 432 477 } 433 478 479 if (!progress) { 480 gtk_snapshot_pop(snapshot); 481 gtk_snapshot_restore(snapshot); 482 return; 483 } 484 485 if (isRTL) { 486 translation = { static_cast<float>(width), 0 }; 487 gtk_snapshot_translate(snapshot, &translation); 488 } else 489 gtk_snapshot_scale(snapshot, -1, 1); 490 491 GdkRGBA dimming = { 0, 0, 0, swipeOverlayDimmingOpacity * dimmingProgress }; 492 GdkRGBA border = { 0, 0, 0, swipeOverlayBorderOpacity }; 493 GdkRGBA outline = { 1, 1, 1, swipeOverlayOutlineOpacity }; 494 495 graphene_rect_t dimmingRect = { 0, 0, static_cast<float>(width), static_cast<float>(height) }; 496 graphene_rect_t borderRect = { 0, 0, 1, static_cast<float>(height) }; 497 graphene_rect_t outlineRect = { -1, 0, 1, static_cast<float>(height) }; 498 graphene_rect_t shadowRect = { 0, 0, swipeOverlayShadowWidth, static_cast<float>(height) }; 499 graphene_point_t shadowStart = { 0, 0 }; 500 graphene_point_t shadowEnd = { swipeOverlayShadowWidth, 0 }; 501 502 gtk_snapshot_append_color(snapshot, &dimming, &dimmingRect); 503 gtk_snapshot_append_color(snapshot, &border, &borderRect); 504 gtk_snapshot_append_color(snapshot, &outline, &outlineRect); 505 gtk_snapshot_push_opacity(snapshot, shadowOpacity); 506 gtk_snapshot_append_linear_gradient(snapshot, &shadowRect, &shadowStart, &shadowEnd, 507 swipeOverlayShadowStops, G_N_ELEMENTS(swipeOverlayShadowStops)); 508 gtk_snapshot_pop(snapshot); 509 510 gtk_snapshot_pop(snapshot); 434 511 gtk_snapshot_restore(snapshot); 435 512 } … … 537 614 538 615 m_currentSwipeSnapshotPattern = nullptr; 616 #if !USE(GTK4) 539 617 m_swipeDimmingPattern = nullptr; 540 618 m_swipeShadowPattern = nullptr; 541 619 m_swipeBorderPattern = nullptr; 542 620 m_swipeOutlinePattern = nullptr; 621 #endif 543 622 544 623 m_currentSwipeSnapshot = nullptr; -
trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk3.cpp
r278656 r278657 26 26 #include "config.h" 27 27 #include "ViewSnapshotStore.h" 28 29 #if !USE(GTK4) 28 30 29 31 #include <WebCore/CairoUtilities.h> … … 59 61 } 60 62 61 size_t ViewSnapshot:: imageSizeInBytes() const63 size_t ViewSnapshot::estimatedImageSizeInBytes() const 62 64 { 63 65 if (!m_surface) … … 84 86 85 87 } // namespace WebKit 88 89 #endif -
trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk4.cpp
r278656 r278657 12 12 * 13 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,dd 15 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS … … 27 27 #include "ViewSnapshotStore.h" 28 28 29 #i nclude <WebCore/CairoUtilities.h>29 #if USE(GTK4) 30 30 31 31 namespace WebKit { 32 32 using namespace WebCore; 33 33 34 Ref<ViewSnapshot> ViewSnapshot::create( RefPtr<cairo_surface_t>&& surface)34 Ref<ViewSnapshot> ViewSnapshot::create(GRefPtr<GdkTexture>&& texture) 35 35 { 36 return adoptRef(*new ViewSnapshot(WTFMove( surface)));36 return adoptRef(*new ViewSnapshot(WTFMove(texture))); 37 37 } 38 38 39 ViewSnapshot::ViewSnapshot( RefPtr<cairo_surface_t>&& surface)40 : m_ surface(WTFMove(surface))39 ViewSnapshot::ViewSnapshot(GRefPtr<GdkTexture>&& texture) 40 : m_texture(WTFMove(texture)) 41 41 { 42 42 if (hasImage()) … … 46 46 bool ViewSnapshot::hasImage() const 47 47 { 48 return !!m_surface;48 return m_texture; 49 49 } 50 50 … … 56 56 ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this); 57 57 58 m_ surface = nullptr;58 m_texture = nullptr; 59 59 } 60 60 61 size_t ViewSnapshot:: imageSizeInBytes() const61 size_t ViewSnapshot::estimatedImageSizeInBytes() const 62 62 { 63 if (!m_ surface)63 if (!m_texture) 64 64 return 0; 65 65 66 cairo_surface_t* surface = m_surface.get(); 67 int stride = cairo_image_surface_get_stride(surface); 68 int height = cairo_image_surface_get_width(surface); 66 int width = gdk_texture_get_width(m_texture.get()); 67 int height = gdk_texture_get_height(m_texture.get()); 69 68 70 return stride * height; 69 // Unfortunately we don't have a way to get size of a texture in 70 // bytes, so we'll have to make something up. Let's assume that 71 // pixel == 4 bytes. 72 return width * height * 4; 71 73 } 72 74 73 75 WebCore::IntSize ViewSnapshot::size() const 74 76 { 75 if (!m_ surface)77 if (!m_texture) 76 78 return { }; 77 79 78 cairo_surface_t* surface = m_surface.get(); 79 int width = cairo_image_surface_get_width(surface); 80 int height = cairo_image_surface_get_height(surface); 80 int width = gdk_texture_get_width(m_texture.get()); 81 int height = gdk_texture_get_height(m_texture.get()); 81 82 82 83 return { width, height }; … … 84 85 85 86 } // namespace WebKit 87 88 #endif
Note:
See TracChangeset
for help on using the changeset viewer.