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

Unified Diff: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.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
Index: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
index 4b0bb496dfb5b3bac165e2584fca293908c1dbad..11f0991e71ffd104181d55b2a950126cf1596c52 100644
--- a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
+++ b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
@@ -5,11 +5,13 @@
#include "platform/graphics/RecordingImageBufferSurface.h"
#include <memory>
+
#include "platform/Histogram.h"
#include "platform/graphics/CanvasMetrics.h"
#include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageBuffer.h"
+#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "platform/graphics/paint/PaintRecorder.h"
#include "platform/wtf/PassRefPtr.h"
#include "platform/wtf/PtrUtil.h"
@@ -18,8 +20,6 @@ namespace blink {
RecordingImageBufferSurface::RecordingImageBufferSurface(
const IntSize& size,
- std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory>
- fallback_factory,
OpacityMode opacity_mode,
const CanvasColorParams& color_params)
: ImageBufferSurface(size, opacity_mode, color_params),
@@ -29,8 +29,7 @@ RecordingImageBufferSurface::RecordingImageBufferSurface(
frame_was_cleared_(true),
did_record_draw_commands_in_current_frame_(false),
current_frame_has_expensive_op_(false),
- previous_frame_has_expensive_op_(false),
- fallback_factory_(std::move(fallback_factory)) {
+ previous_frame_has_expensive_op_(false) {
InitializeCurrentFrame();
}
@@ -68,10 +67,9 @@ bool RecordingImageBufferSurface::WritePixels(const SkImageInfo& orig_info,
int x,
int y) {
if (!fallback_surface_) {
- if (x <= 0 && y <= 0 && x + orig_info.width() >= size().Width() &&
- y + orig_info.height() >= size().Height()) {
+ IntRect write_rect(x, y, orig_info.width(), orig_info.height());
+ if (write_rect.Contains(IntRect(IntPoint(), size())))
WillOverwriteCanvas();
- }
FallBackToRasterCanvas(kFallbackReasonWritePixels);
}
return fallback_surface_->WritePixels(orig_info, pixels, row_bytes, x, y);
@@ -79,7 +77,6 @@ bool RecordingImageBufferSurface::WritePixels(const SkImageInfo& orig_info,
void RecordingImageBufferSurface::FallBackToRasterCanvas(
FallbackReason reason) {
- DCHECK(fallback_factory_);
CHECK(reason != kFallbackReasonUnknown);
if (fallback_surface_) {
@@ -93,8 +90,8 @@ void RecordingImageBufferSurface::FallBackToRasterCanvas(
kFallbackReasonCount));
canvas_fallback_histogram.Count(reason);
- fallback_surface_ = fallback_factory_->CreateSurface(size(), GetOpacityMode(),
- color_params());
+ fallback_surface_ = WTF::WrapUnique(new UnacceleratedImageBufferSurface(
+ size(), GetOpacityMode(), kInitializeImagePixels, color_params()));
fallback_surface_->SetImageBuffer(image_buffer_);
if (previous_frame_) {
@@ -230,8 +227,6 @@ sk_sp<PaintRecord> RecordingImageBufferSurface::GetRecord() {
FallbackReason fallback_reason = kFallbackReasonUnknown;
bool can_use_record = FinalizeFrameInternal(&fallback_reason);
- DCHECK(can_use_record || fallback_factory_);
-
if (can_use_record) {
return previous_frame_;
}
@@ -320,9 +315,8 @@ bool RecordingImageBufferSurface::FinalizeFrameInternal(
return false;
}
- if (fallback_factory_ &&
- current_frame_->getRecordingCanvas()->getSaveCount() - 1 >
- ExpensiveCanvasHeuristicParameters::kExpensiveRecordingStackDepth) {
+ if (current_frame_->getRecordingCanvas()->getSaveCount() - 1 >
+ ExpensiveCanvasHeuristicParameters::kExpensiveRecordingStackDepth) {
// (getSaveCount() decremented to account for the intial recording canvas
// save frame.)
*fallback_reason = kFallbackReasonRunawayStateStack;

Powered by Google App Engine
This is Rietveld 408576698