chromium/third_party/blink/renderer/platform/graphics/offscreen_canvas_placeholder.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/platform/graphics/offscreen_canvas_placeholder.h"

#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_dispatcher.h"
#include "third_party/blink/renderer/platform/graphics/resource_id_traits.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"

namespace {

PlaceholderIdMap;

PlaceholderIdMap& placeholderRegistry() {}

void ReleaseFrameToDispatcher(
    base::WeakPtr<blink::CanvasResourceDispatcher> dispatcher,
    scoped_refptr<blink::CanvasResource> oldImage,
    viz::ResourceId resourceId) {}

void SetSuspendAnimation(
    base::WeakPtr<blink::CanvasResourceDispatcher> dispatcher,
    bool suspend) {}

void UpdateDispatcherFilterQuality(
    base::WeakPtr<blink::CanvasResourceDispatcher> dispatcher,
    cc::PaintFlags::FilterQuality filter) {}

}  // unnamed namespace

namespace blink {

OffscreenCanvasPlaceholder::~OffscreenCanvasPlaceholder() {}

namespace {

// This function gets called when the last outstanding reference to a
// CanvasResource is released.  This callback is only registered on
// resources received via SetOffscreenCanvasResource(). When the resource
// is received, its ref count may be 2 because the CanvasResourceProvider
// that created it may be holding a cached snapshot that will be released when
// copy-on-write kicks in. This is okay even if the resource provider is on a
// different thread because concurrent read access is safe. By the time the
// next frame is received by OffscreenCanvasPlaceholder, the reference held by
// CanvasResourceProvider will have been released (otherwise there wouldn't be
// a new frame). This means that all outstanding references are held on the
// same thread as the OffscreenCanvasPlaceholder at the time when
// 'placeholder_frame_' is assigned a new value.  Therefore, when the last
// reference is released, we need to temporarily keep the object alive and send
// it back to its thread of origin, where it can be safely destroyed or
// recycled.
void FrameLastUnrefCallback(
    base::WeakPtr<CanvasResourceDispatcher> frame_dispatcher,
    scoped_refptr<base::SingleThreadTaskRunner> frame_dispatcher_task_runner,
    viz::ResourceId placeholder_frame_resource_id,
    scoped_refptr<CanvasResource> placeholder_frame) {}

}  // unnamed namespace

void OffscreenCanvasPlaceholder::SetOffscreenCanvasResource(
    scoped_refptr<CanvasResource>&& new_frame,
    viz::ResourceId resource_id) {}

void OffscreenCanvasPlaceholder::SetOffscreenCanvasDispatcher(
    base::WeakPtr<CanvasResourceDispatcher> dispatcher,
    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {}

void OffscreenCanvasPlaceholder::UpdateOffscreenCanvasFilterQuality(
    cc::PaintFlags::FilterQuality filter_quality) {}

void OffscreenCanvasPlaceholder::SetSuspendOffscreenCanvasAnimation(
    bool suspend) {}

OffscreenCanvasPlaceholder*
OffscreenCanvasPlaceholder::GetPlaceholderCanvasById(unsigned placeholder_id) {}

void OffscreenCanvasPlaceholder::RegisterPlaceholderCanvas(
    unsigned placeholder_id) {}

void OffscreenCanvasPlaceholder::UnregisterPlaceholderCanvas() {}

bool OffscreenCanvasPlaceholder::PostSetSuspendAnimationToOffscreenCanvasThread(
    bool suspend) {}

}  // namespace blink