Commit 39402396 authored by Justin Novosad's avatar Justin Novosad Committed by Commit Bot

Use IntSize for size in OffscreenCanvasFrameDispatcher

This change is on the path to replacing OffscreenCanvasResourceProvider
with CanvasResourceProvider

BUG=788439

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I34637343dbd7693cbbfe099061b18a8cfd2094b7
Reviewed-on: https://chromium-review.googlesource.com/1052923Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Justin Novosad <junov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557324}
parent 1ddd9067
......@@ -320,8 +320,7 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContext(
frame_dispatcher_ = std::make_unique<OffscreenCanvasFrameDispatcher>(
nullptr, surface_layer_bridge_->GetFrameSinkId().client_id(),
surface_layer_bridge_->GetFrameSinkId().sink_id(),
OffscreenCanvasFrameDispatcher::kInvalidPlaceholderCanvasId,
size_.Width(), size_.Height());
OffscreenCanvasFrameDispatcher::kInvalidPlaceholderCanvasId, size_);
}
SetNeedsCompositingUpdate();
......@@ -764,7 +763,7 @@ void HTMLCanvasElement::SetSurfaceSize(const IntSize& size) {
context_->DidSetSurfaceSize();
}
if (frame_dispatcher_)
frame_dispatcher_->Reshape(size_.Width(), size_.Height());
frame_dispatcher_->Reshape(size_);
}
const AtomicString HTMLCanvasElement::ImageSourceURL() const {
......
......@@ -76,7 +76,7 @@ void OffscreenCanvas::SetSize(const IntSize& size) {
}
size_ = size;
if (frame_dispatcher_) {
frame_dispatcher_->Reshape(size_.Width(), size_.Height());
frame_dispatcher_->Reshape(size_);
}
current_frame_damage_rect_ = SkIRect::MakeWH(size_.Width(), size_.Height());
}
......@@ -222,8 +222,7 @@ OffscreenCanvasFrameDispatcher* OffscreenCanvas::GetOrCreateFrameDispatcher() {
// (either main or worker) to the browser process and remains unchanged
// throughout the lifetime of this OffscreenCanvas.
frame_dispatcher_ = std::make_unique<OffscreenCanvasFrameDispatcher>(
this, client_id_, sink_id_, placeholder_canvas_id_, size_.Width(),
size_.Height());
this, client_id_, sink_id_, placeholder_canvas_id_, size_);
}
return frame_dispatcher_.get();
}
......
......@@ -32,11 +32,9 @@ OffscreenCanvasFrameDispatcher::OffscreenCanvasFrameDispatcher(
uint32_t client_id,
uint32_t sink_id,
int canvas_id,
int width,
int height)
const IntSize& size)
: frame_sink_id_(viz::FrameSinkId(client_id, sink_id)),
width_(width),
height_(height),
size_(size),
change_size_for_next_commit_(false),
needs_begin_frame_(false),
binding_(this),
......@@ -62,8 +60,8 @@ OffscreenCanvasFrameDispatcher::OffscreenCanvasFrameDispatcher(
mojo::MakeRequest(&sink_));
}
offscreen_canvas_resource_provider_ =
std::make_unique<OffscreenCanvasResourceProvider>(width, height,
sink_.get());
std::make_unique<OffscreenCanvasResourceProvider>(
size_.Width(), size_.Height(), sink_.get());
}
OffscreenCanvasFrameDispatcher::~OffscreenCanvasFrameDispatcher() = default;
......@@ -158,7 +156,7 @@ void OffscreenCanvasFrameDispatcher::DispatchFrame(
}
frame.metadata.begin_frame_ack = current_begin_frame_ack_;
const gfx::Rect bounds(width_, height_);
const gfx::Rect bounds(size_.Width(), size_.Height());
const int kRenderPassId = 1;
bool is_clipped = false;
// TODO(crbug.com/705019): optimize for contexts that have {alpha: false}
......@@ -228,7 +226,7 @@ void OffscreenCanvasFrameDispatcher::DispatchFrame(
viz::TextureDrawQuad* quad =
pass->CreateAndAppendDrawQuad<viz::TextureDrawQuad>();
gfx::Size rect_size(width_, height_);
gfx::Size rect_size(size_.Width(), size_.Height());
// TODO(crbug.com/705019): optimize for contexts that have {alpha: false}
const bool kNeedsBlending = true;
......@@ -432,16 +430,15 @@ void OffscreenCanvasFrameDispatcher::ReclaimResource(unsigned resource_id) {
}
bool OffscreenCanvasFrameDispatcher::VerifyImageSize(const IntSize image_size) {
if (image_size.Width() == width_ && image_size.Height() == height_)
if (image_size == size_)
return true;
return false;
}
void OffscreenCanvasFrameDispatcher::Reshape(int width, int height) {
if (width_ != width || height_ != height) {
width_ = width;
height_ = height;
offscreen_canvas_resource_provider_->Reshape(width, height);
void OffscreenCanvasFrameDispatcher::Reshape(const IntSize& size) {
if (size_ != size) {
size_ = size;
offscreen_canvas_resource_provider_->Reshape(size_.Width(), size_.Height());
change_size_for_next_commit_ = true;
}
}
......
......@@ -37,8 +37,7 @@ class PLATFORM_EXPORT OffscreenCanvasFrameDispatcher
uint32_t client_id,
uint32_t sink_id,
int placeholder_canvas_id,
int width,
int height);
const IntSize&);
// OffscreenCanvasFrameDispatcher implementation.
~OffscreenCanvasFrameDispatcher() override;
......@@ -50,7 +49,7 @@ class PLATFORM_EXPORT OffscreenCanvasFrameDispatcher
double commit_start_time,
const SkIRect& damage_rect);
void ReclaimResource(unsigned resource_id);
void Reshape(int width, int height);
void Reshape(const IntSize&);
// viz::mojom::blink::CompositorFrameSinkClient implementation.
void DidReceiveCompositorFrameAck(
......@@ -81,8 +80,7 @@ class PLATFORM_EXPORT OffscreenCanvasFrameDispatcher
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
const viz::FrameSinkId frame_sink_id_;
int width_;
int height_;
IntSize size_;
bool change_size_for_next_commit_;
bool suspend_animation_ = false;
bool needs_begin_frame_ = false;
......
......@@ -19,7 +19,7 @@ class MockOffscreenCanvasFrameDispatcher
: public OffscreenCanvasFrameDispatcher {
public:
MockOffscreenCanvasFrameDispatcher()
: OffscreenCanvasFrameDispatcher(nullptr, 0, 0, 0, 10, 10) {}
: OffscreenCanvasFrameDispatcher(nullptr, 0, 0, 0, {10, 10}) {}
MOCK_METHOD2(PostImageToPlaceholder,
void(scoped_refptr<StaticBitmapImage>, unsigned resource_id));
......
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