void CheckGeneratedPalettedImage(Decoder* aDecoder, const IntRect& aRect) { RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef(); IntSize imageSize = currentFrame->GetImageSize(); // This diagram shows how the surface is divided into regions that the code // below tests for the correct content. The output rect is the bounds of the // region labeled 'C'. // // +---------------------------+ // | A | // +---------+--------+--------+ // | B | C | D | // +---------+--------+--------+ // | E | // +---------------------------+ // Check that the output rect itself is all 255's. (Region 'C'.) EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder, aRect, 255)); // Check that the area above the output rect is all 0's. (Region 'A'.) EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder, IntRect(0, 0, imageSize.width, aRect.y), 0)); // Check that the area to the left of the output rect is all 0's. (Region 'B'.) EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder, IntRect(0, aRect.y, aRect.x, aRect.YMost()), 0)); // Check that the area to the right of the output rect is all 0's. (Region 'D'.) const int32_t widthOnRight = imageSize.width - aRect.XMost(); EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder, IntRect(aRect.XMost(), aRect.y, widthOnRight, aRect.YMost()), 0)); // Check that the area below the output rect is transparent. (Region 'E'.) const int32_t heightBelow = imageSize.height - aRect.YMost(); EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder, IntRect(0, aRect.YMost(), imageSize.width, heightBelow), 0)); }
static void DoCollectSizeOfCompositingSurfaces(const RawAccessFrameRef& aSurface, SurfaceMemoryCounterType aType, nsTArray<SurfaceMemoryCounter>& aCounters, MallocSizeOf aMallocSizeOf) { // Concoct a SurfaceKey for this surface. SurfaceKey key = RasterSurfaceKey(aSurface->GetImageSize(), DefaultSurfaceFlags(), PlaybackType::eStatic); // Create a counter for this surface. SurfaceMemoryCounter counter(key, /* aIsLocked = */ true, aType); // Extract the surface's memory usage information. size_t heap = 0, nonHeap = 0; aSurface->AddSizeOfExcludingThis(aMallocSizeOf, heap, nonHeap); counter.Values().SetDecodedHeap(heap); counter.Values().SetDecodedNonHeap(nonHeap); // Record it. aCounters.AppendElement(counter); }