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

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

Issue 2833593002: Remove unneeded abstractions and simplify RecordingImageBufferSurface (Closed)
Patch Set: imagebuffersurface-cleanups: . 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
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..4432cac5628797bc6a3021c4cf6e4a23c5b2fb10 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);
@@ -975,9 +956,8 @@ 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,9 +967,8 @@ 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);
@@ -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();
}

Powered by Google App Engine
This is Rietveld 408576698