Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2833593002: Remove unneeded abstractions and simplify RecordingImageBufferSurface (Closed)
Patch Set: imagebuffersurface-cleanups: morefixcompile Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index ca26c8a456be0367e2de918ef5fcd385ab41efa7..20ef17a093bb37cab029e169d874b0c05b58e835 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -888,24 +888,6 @@ bool HTMLCanvasElement::ShouldAccelerate(AccelerationCriteria criteria) const {
return true;
}
-namespace {
-
-class UnacceleratedSurfaceFactory
- : public RecordingImageBufferFallbackSurfaceFactory {
- public:
- virtual std::unique_ptr<ImageBufferSurface> CreateSurface(
- const IntSize& size,
- OpacityMode opacity_mode,
- const CanvasColorParams& color_params) {
- return WTF::WrapUnique(new UnacceleratedImageBufferSurface(
- size, opacity_mode, kInitializeImagePixels, color_params));
- }
-
- virtual ~UnacceleratedSurfaceFactory() {}
-};
-
-} // namespace
-
bool HTMLCanvasElement::ShouldUseDisplayList() {
// Rasterization of web contents will blend in the output space. Only embed
// the canvas as a display list if it intended to do output space blending as
@@ -928,8 +910,8 @@ HTMLCanvasElement::CreateWebGLImageBufferSurface(OpacityMode opacity_mode) {
// If 3d, but the use of the canvas will be for non-accelerated content
// then make a non-accelerated ImageBuffer. This means copying the internal
// Image will require a pixel readback, but that is unavoidable in this case.
- auto surface = WTF::WrapUnique(new AcceleratedImageBufferSurface(
- size(), opacity_mode, context_->color_params()));
+ auto surface = WTF::MakeUnique<AcceleratedImageBufferSurface>(
+ size(), opacity_mode, context_->color_params());
if (surface->IsValid())
return std::move(surface);
return nullptr;
@@ -956,10 +938,9 @@ HTMLCanvasElement::CreateAcceleratedImageBufferSurface(OpacityMode opacity_mode,
if (context_provider->IsSoftwareRendering())
return nullptr; // Don't use accelerated canvas with swiftshader.
- std::unique_ptr<ImageBufferSurface> surface =
- WTF::WrapUnique(new Canvas2DImageBufferSurface(
- std::move(context_provider), size(), *msaa_sample_count, opacity_mode,
- Canvas2DLayerBridge::kEnableAcceleration, context_->color_params()));
+ auto surface = WTF::MakeUnique<Canvas2DImageBufferSurface>(
+ std::move(context_provider), size(), *msaa_sample_count, opacity_mode,
+ Canvas2DLayerBridge::kEnableAcceleration, context_->color_params());
if (!surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kGPUAccelerated2DCanvasImageBufferCreationFailed);
@@ -968,16 +949,15 @@ HTMLCanvasElement::CreateAcceleratedImageBufferSurface(OpacityMode opacity_mode,
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kGPUAccelerated2DCanvasImageBufferCreated);
- return surface;
+ return std::move(surface);
}
std::unique_ptr<ImageBufferSurface>
HTMLCanvasElement::CreateUnacceleratedImageBufferSurface(
OpacityMode opacity_mode) {
if (ShouldUseDisplayList()) {
- auto surface = WTF::WrapUnique(new RecordingImageBufferSurface(
- size(), WTF::WrapUnique(new UnacceleratedSurfaceFactory), opacity_mode,
- context_->color_params()));
+ auto surface = WTF::MakeUnique<RecordingImageBufferSurface>(
+ size(), opacity_mode, context_->color_params());
if (surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kDisplayList2DCanvasImageBufferCreated);
@@ -987,13 +967,12 @@ HTMLCanvasElement::CreateUnacceleratedImageBufferSurface(
// here.
}
- auto surface_factory = WTF::MakeUnique<UnacceleratedSurfaceFactory>();
- auto surface = surface_factory->CreateSurface(size(), opacity_mode,
- context_->color_params());
+ auto surface = WTF::MakeUnique<UnacceleratedImageBufferSurface>(
+ size(), opacity_mode, kInitializeImagePixels, context_->color_params());
if (surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kUnaccelerated2DCanvasImageBufferCreated);
- return surface;
+ return std::move(surface);
}
CanvasMetrics::CountCanvasContextUsage(
@@ -1479,7 +1458,7 @@ void HTMLCanvasElement::CreateLayer() {
layer_tree_view =
frame->GetPage()->GetChromeClient().GetWebLayerTreeView(frame);
surface_layer_bridge_ =
- WTF::WrapUnique(new CanvasSurfaceLayerBridge(this, layer_tree_view));
+ WTF::MakeUnique<CanvasSurfaceLayerBridge>(this, layer_tree_view);
// Creates a placeholder layer first before Surface is created.
surface_layer_bridge_->CreateSolidColorLayer();
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698