| 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->setSize(IntSize(40, 40)); | 682 canvas->setHeight(40); |
| 683 canvas->setWidth(40); |
| 683 ImageBitmap* imageBitmapDerived = nullptr; | 684 ImageBitmap* imageBitmapDerived = nullptr; |
| 684 { | 685 { |
| 685 const ImageBitmapOptions defaultOptions; | 686 const ImageBitmapOptions defaultOptions; |
| 686 Optional<IntRect> cropRect = IntRect(0, 0, canvas->width(), canvas->heig
ht()); | 687 Optional<IntRect> cropRect = IntRect(0, 0, canvas->width(), canvas->heig
ht()); |
| 687 ImageBitmap* imageBitmapFromCanvas = ImageBitmap::create(canvas, cropRec
t, defaultOptions); | 688 ImageBitmap* imageBitmapFromCanvas = ImageBitmap::create(canvas, cropRec
t, defaultOptions); |
| 688 cropRect = IntRect(0, 0, 20, 20); | 689 cropRect = IntRect(0, 0, 20, 20); |
| 689 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas, cropRect
, defaultOptions); | 690 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas, cropRect
, defaultOptions); |
| 690 } | 691 } |
| 691 CanvasContextCreationAttributes attributes; | 692 CanvasContextCreationAttributes attributes; |
| 692 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->getCanvasRenderingContext("2d", attributes)); | 693 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->getCanvasRenderingContext("2d", attributes)); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); | 853 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); |
| 853 | 854 |
| 854 context->fillRect(10, 10, 100, 100); | 855 context->fillRect(10, 10, 100, 100); |
| 855 | 856 |
| 856 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); | 857 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); |
| 857 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 858 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
| 858 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); | 859 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); |
| 859 } | 860 } |
| 860 | 861 |
| 861 } // namespace blink | 862 } // namespace blink |
| OLD | NEW |