OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/canvas2d/CanvasRenderingContext2D.h" | 5 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/frame/ImageBitmap.h" | 10 #include "core/frame/ImageBitmap.h" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 672 |
673 context2d()->fillText("Text", 0, 5); | 673 context2d()->fillText("Text", 0, 5); |
674 } | 674 } |
675 | 675 |
676 TEST_F(CanvasRenderingContext2DTest, ImageResourceLifetime) | 676 TEST_F(CanvasRenderingContext2DTest, ImageResourceLifetime) |
677 { | 677 { |
678 NonThrowableExceptionState nonThrowableExceptionState; | 678 NonThrowableExceptionState nonThrowableExceptionState; |
679 Element* canvasElement = document().createElement("canvas", nonThrowableExce
ptionState); | 679 Element* canvasElement = document().createElement("canvas", nonThrowableExce
ptionState); |
680 EXPECT_FALSE(nonThrowableExceptionState.hadException()); | 680 EXPECT_FALSE(nonThrowableExceptionState.hadException()); |
681 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(canvasElement); | 681 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(canvasElement); |
682 canvas->setHeight(40); | 682 canvas->setSize(IntSize(40, 40)); |
683 canvas->setWidth(40); | |
684 ImageBitmap* imageBitmapDerived = nullptr; | 683 ImageBitmap* imageBitmapDerived = nullptr; |
685 { | 684 { |
686 const ImageBitmapOptions defaultOptions; | 685 const ImageBitmapOptions defaultOptions; |
687 Optional<IntRect> cropRect = IntRect(0, 0, canvas->width(), canvas->heig
ht()); | 686 Optional<IntRect> cropRect = IntRect(0, 0, canvas->width(), canvas->heig
ht()); |
688 ImageBitmap* imageBitmapFromCanvas = ImageBitmap::create(canvas, cropRec
t, defaultOptions); | 687 ImageBitmap* imageBitmapFromCanvas = ImageBitmap::create(canvas, cropRec
t, defaultOptions); |
689 cropRect = IntRect(0, 0, 20, 20); | 688 cropRect = IntRect(0, 0, 20, 20); |
690 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas, cropRect
, defaultOptions); | 689 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas, cropRect
, defaultOptions); |
691 } | 690 } |
692 CanvasContextCreationAttributes attributes; | 691 CanvasContextCreationAttributes attributes; |
693 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->getCanvasRenderingContext("2d", attributes)); | 692 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->getCanvasRenderingContext("2d", attributes)); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); | 852 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); |
854 | 853 |
855 context->fillRect(10, 10, 100, 100); | 854 context->fillRect(10, 10, 100, 100); |
856 | 855 |
857 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); | 856 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); |
858 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 857 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
859 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); | 858 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); |
860 } | 859 } |
861 | 860 |
862 } // namespace blink | 861 } // namespace blink |
OLD | NEW |