Commit 9f746624 authored by danakj's avatar danakj Committed by Commit Bot

Register SharedBitmapIds through TextureLayer for PepperCompositorHost

Replace usage of SharedBitmapManager with instead registering the
SharedMemory and SharedBitmapId through the TextureLayer that they
will be presented on. This gets the registration to go through the
CompositorFrameSink which is compatable with the VizDisplayCompositor.

R=piman@chromium.org

Bug: 730660
Change-Id: I55f915eb00082ba527a440956e93cbf46acf7ce6
Reviewed-on: https://chromium-review.googlesource.com/1021838
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552407}
parent 5550e13d
......@@ -191,12 +191,10 @@ void PepperCompositorHost::ViewInitiatedPaint() {
void PepperCompositorHost::ImageReleased(
int32_t id,
std::unique_ptr<base::SharedMemory> shared_memory,
std::unique_ptr<viz::SharedBitmap> bitmap,
scoped_refptr<cc::CrossThreadSharedBitmap> shared_bitmap,
cc::SharedBitmapIdRegistration registration,
const gpu::SyncToken& sync_token,
bool is_lost) {
bitmap.reset();
shared_memory.reset();
ResourceReleased(id, sync_token, is_lost);
}
......@@ -314,20 +312,26 @@ void PepperCompositorHost::UpdateLayer(
DCHECK_EQ(rv, PP_TRUE);
DCHECK_EQ(desc.stride, desc.size.width * 4);
DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL);
std::unique_ptr<viz::SharedBitmap> bitmap =
RenderThreadImpl::current()
->shared_bitmap_manager()
->GetBitmapForSharedMemory(image_shm.get());
viz::SharedBitmapId shared_bitmap_id = viz::SharedBitmap::GenerateId();
// TODO(danakj): These bitmaps could be reused for future frames instead
// of malloc/free for each frame.
auto shared_bitmap = base::MakeRefCounted<cc::CrossThreadSharedBitmap>(
shared_bitmap_id, std::move(image_shm), PP_ToGfxSize(desc.size),
viz::RGBA_8888);
cc::SharedBitmapIdRegistration registration =
image_layer->RegisterSharedBitmapId(shared_bitmap_id, shared_bitmap);
auto resource = viz::TransferableResource::MakeSoftware(
bitmap->id(), bitmap->sequence_number(), PP_ToGfxSize(desc.size),
shared_bitmap_id, /*sequence_number=*/0, PP_ToGfxSize(desc.size),
viz::RGBA_8888);
image_layer->SetTransferableResource(
resource,
viz::SingleReleaseCallback::Create(base::BindOnce(
&PepperCompositorHost::ImageReleased, weak_factory_.GetWeakPtr(),
new_layer->common.resource_id, std::move(image_shm),
std::move(bitmap))));
new_layer->common.resource_id, std::move(shared_bitmap),
std::move(registration))));
// TODO(penghuang): get a damage region from the application and
// pass it to SetNeedsDisplayRect().
image_layer->SetNeedsDisplay();
......
......@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "cc/resources/shared_bitmap_id_registrar.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/shared_impl/compositor_layer_data.h"
......@@ -21,6 +22,7 @@ class SharedMemory;
} // namespace
namespace cc {
class CrossThreadSharedBitmap;
class Layer;
} // namespace cc
......@@ -28,10 +30,6 @@ namespace gpu {
struct SyncToken;
} // namespace gpu
namespace viz {
class SharedBitmap;
}
namespace content {
class PepperPluginInstanceImpl;
......@@ -61,8 +59,8 @@ class PepperCompositorHost : public ppapi::host::ResourceHost {
private:
void ImageReleased(int32_t id,
std::unique_ptr<base::SharedMemory> shared_memory,
std::unique_ptr<viz::SharedBitmap> bitmap,
scoped_refptr<cc::CrossThreadSharedBitmap> shared_bitmap,
cc::SharedBitmapIdRegistration registration,
const gpu::SyncToken& sync_token,
bool is_lost);
void ResourceReleased(int32_t 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