Commit eb1851b6 authored by Aaron Krajeski's avatar Aaron Krajeski Committed by Commit Bot

Refactor OffscreenCanvas SetSize method

In the past we were calling UpdateMemoryUsage with the old size.
Make it clear that the canvas is being reset if the size is not
changing.

Change-Id: Iea8b9d50ce4b01b82611bc8ff665b5cf673f79db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829801
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700836}
parent 3586706b
......@@ -120,25 +120,30 @@ void OffscreenCanvas::setHeight(unsigned height) {
}
void OffscreenCanvas::SetSize(const IntSize& size) {
if (context_) {
if (context_->Is3d()) {
if (size != size_)
context_->Reshape(size.Width(), size.Height());
} else if (context_->Is2d()) {
// Setting size of a canvas also resets it.
if (size == size_) {
if (context_ && context_->Is2d()) {
context_->Reset();
origin_clean_ = true;
}
return;
}
if (size != size_) {
UpdateMemoryUsage();
}
size_ = size;
UpdateMemoryUsage();
current_frame_damage_rect_ = SkIRect::MakeWH(size_.Width(), size_.Height());
if (frame_dispatcher_)
frame_dispatcher_->Reshape(size_);
current_frame_damage_rect_ = SkIRect::MakeWH(size_.Width(), size_.Height());
if (context_)
if (context_) {
if (context_->Is3d()) {
context_->Reshape(size_.Width(), size_.Height());
} else if (context_->Is2d()) {
context_->Reset();
origin_clean_ = true;
}
context_->DidDraw();
}
}
void OffscreenCanvas::RecordTransfer() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment