Remove PPB_Compositor
It's incompatible with shared images / Vulkan, and it usage is extremely low (not available on stable except for ARC, which doesn't use it any more). Bug: 918951 Change-Id: Ia01d2b276456536394fecffb39d5ea6c90cfe0de Reviewed-on: https://chromium-review.googlesource.com/c/1396611 Commit-Queue: Antoine Labour <piman@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Ben Smith <binji@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/master@{#621778}
This commit is contained in:

committed by
Commit Bot

parent
812090c2c8
commit
c0c56e43d0
BUILD.gn
chrome
content
native_client_sdk/src/libraries
ppapi
BUILD.gn
api
c
cpp
examples
host
native_client
src
untrusted
pnacl_irt_shim
proxy
BUILD.gncompositor_layer_resource.cccompositor_layer_resource.hcompositor_resource.cccompositor_resource.hinterface_list.ccppapi_messages.hppapi_param_traits.hppb_instance_proxy.ccresource_creation_proxy.ccresource_creation_proxy.h
shared_impl
tests
thunk
tools/metrics/histograms
1
BUILD.gn
1
BUILD.gn
@ -115,7 +115,6 @@ group("gn_all") {
|
||||
"//ppapi/examples/2d",
|
||||
"//ppapi/examples/audio",
|
||||
"//ppapi/examples/audio_input",
|
||||
"//ppapi/examples/compositor",
|
||||
"//ppapi/examples/crxfs",
|
||||
"//ppapi/examples/enumerate_devices",
|
||||
"//ppapi/examples/file_chooser",
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "ppapi/c/ppb_audio_buffer.h"
|
||||
#include "ppapi/c/ppb_audio_config.h"
|
||||
#include "ppapi/c/ppb_audio_encoder.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_console.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_file_io.h"
|
||||
|
@ -229,11 +229,6 @@ const char* const kPredefinedAllowedCameraDeviceOrigins[] = {
|
||||
"6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
|
||||
"4EB74897CB187C7633357C2FE832E0AD6A44883A"
|
||||
};
|
||||
|
||||
const char* const kPredefinedAllowedCompositorOrigins[] = {
|
||||
"6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
|
||||
"4EB74897CB187C7633357C2FE832E0AD6A44883A"
|
||||
};
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
@ -350,8 +345,6 @@ ChromeContentRendererClient::ChromeContentRendererClient()
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
for (const char* origin : kPredefinedAllowedCameraDeviceOrigins)
|
||||
allowed_camera_device_origins_.insert(origin);
|
||||
for (const char* origin : kPredefinedAllowedCompositorOrigins)
|
||||
allowed_compositor_origins_.insert(origin);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1422,22 +1415,6 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChromeContentRendererClient::IsPluginAllowedToUseCompositorAPI(
|
||||
const GURL& url) {
|
||||
#if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnablePepperTesting))
|
||||
return true;
|
||||
if (IsExtensionOrSharedModuleWhitelisted(url, allowed_compositor_origins_))
|
||||
return true;
|
||||
|
||||
version_info::Channel channel = chrome::GetChannel();
|
||||
return channel <= version_info::Channel::DEV;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
content::BrowserPluginDelegate*
|
||||
ChromeContentRendererClient::CreateBrowserPluginDelegate(
|
||||
content::RenderFrame* render_frame,
|
||||
|
@ -165,7 +165,6 @@ class ChromeContentRendererClient
|
||||
bool IsKeySystemsUpdateNeeded() override;
|
||||
bool IsPluginAllowedToUseDevChannelAPIs() override;
|
||||
bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
|
||||
bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
|
||||
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
|
||||
content::RenderFrame* render_frame,
|
||||
const content::WebPluginInfo& info,
|
||||
@ -296,7 +295,6 @@ class ChromeContentRendererClient
|
||||
#endif
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
std::set<std::string> allowed_camera_device_origins_;
|
||||
std::set<std::string> allowed_compositor_origins_;
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -201,10 +201,6 @@ bool ContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentRendererClient::IsPluginAllowedToUseCompositorAPI(const GURL& url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() {
|
||||
return false;
|
||||
}
|
||||
|
@ -295,9 +295,6 @@ class CONTENT_EXPORT ContentRendererClient {
|
||||
// Returns true if the page at |url| can use Pepper CameraDevice APIs.
|
||||
virtual bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url);
|
||||
|
||||
// Returns true if the page at |url| can use Pepper Compositor APIs.
|
||||
virtual bool IsPluginAllowedToUseCompositorAPI(const GURL& url);
|
||||
|
||||
// Returns true if dev channel APIs are available for plugins.
|
||||
virtual bool IsPluginAllowedToUseDevChannelAPIs();
|
||||
|
||||
|
@ -856,8 +856,6 @@ target(link_target_type, "renderer") {
|
||||
"pepper/pepper_browser_connection.h",
|
||||
"pepper/pepper_camera_device_host.cc",
|
||||
"pepper/pepper_camera_device_host.h",
|
||||
"pepper/pepper_compositor_host.cc",
|
||||
"pepper/pepper_compositor_host.h",
|
||||
"pepper/pepper_device_enumeration_host_helper.cc",
|
||||
"pepper/pepper_device_enumeration_host_helper.h",
|
||||
"pepper/pepper_file_chooser_host.cc",
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "content/renderer/pepper/pepper_audio_input_host.h"
|
||||
#include "content/renderer/pepper/pepper_audio_output_host.h"
|
||||
#include "content/renderer/pepper/pepper_camera_device_host.h"
|
||||
#include "content/renderer/pepper/pepper_compositor_host.h"
|
||||
#include "content/renderer/pepper/pepper_file_chooser_host.h"
|
||||
#include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
|
||||
#include "content/renderer/pepper/pepper_file_system_host.h"
|
||||
@ -67,19 +66,6 @@ static bool CanUseCameraDeviceAPI(RendererPpapiHost* host,
|
||||
document_url);
|
||||
}
|
||||
|
||||
bool CanUseCompositorAPI(RendererPpapiHost* host, PP_Instance instance) {
|
||||
blink::WebPluginContainer* container =
|
||||
host->GetContainerForInstance(instance);
|
||||
if (!container)
|
||||
return false;
|
||||
|
||||
GURL document_url = container->GetDocument().Url();
|
||||
ContentRendererClient* content_renderer_client =
|
||||
GetContentClient()->renderer();
|
||||
return content_renderer_client->IsPluginAllowedToUseCompositorAPI(
|
||||
document_url);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ContentRendererPepperHostFactory::ContentRendererPepperHostFactory(
|
||||
@ -107,11 +93,6 @@ ContentRendererPepperHostFactory::CreateResourceHost(
|
||||
|
||||
// Public interfaces.
|
||||
switch (message.type()) {
|
||||
case PpapiHostMsg_Compositor_Create::ID: {
|
||||
if (!CanUseCompositorAPI(host_, instance))
|
||||
return nullptr;
|
||||
return std::make_unique<PepperCompositorHost>(host_, instance, resource);
|
||||
}
|
||||
case PpapiHostMsg_FileRef_CreateForFileAPI::ID: {
|
||||
PP_Resource file_system;
|
||||
std::string internal_path;
|
||||
|
@ -1,425 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/pepper/pepper_compositor_host.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/shared_memory.h"
|
||||
#include "cc/layers/layer.h"
|
||||
#include "cc/layers/solid_color_layer.h"
|
||||
#include "cc/layers/texture_layer.h"
|
||||
#include "cc/trees/layer_tree_host.h"
|
||||
#include "content/public/renderer/renderer_ppapi_host.h"
|
||||
#include "content/renderer/pepper/gfx_conversion.h"
|
||||
#include "content/renderer/pepper/host_globals.h"
|
||||
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
|
||||
#include "content/renderer/pepper/ppb_image_data_impl.h"
|
||||
#include "content/renderer/render_thread_impl.h"
|
||||
#include "gpu/command_buffer/common/mailbox.h"
|
||||
#include "gpu/command_buffer/common/sync_token.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/host/dispatch_host_message.h"
|
||||
#include "ppapi/host/ppapi_host.h"
|
||||
#include "ppapi/proxy/ppapi_messages.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppb_image_data_api.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
#include "ui/gfx/geometry/size_conversions.h"
|
||||
#include "ui/gfx/transform.h"
|
||||
|
||||
using ppapi::host::HostMessageContext;
|
||||
using ppapi::thunk::EnterResourceNoLock;
|
||||
using ppapi::thunk::PPB_ImageData_API;
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
bool CheckPPFloatRect(const PP_FloatRect& rect, float width, float height) {
|
||||
const float kEpsilon = std::numeric_limits<float>::epsilon();
|
||||
return (rect.point.x >= -kEpsilon &&
|
||||
rect.point.y >= -kEpsilon &&
|
||||
rect.point.x + rect.size.width <= width + kEpsilon &&
|
||||
rect.point.y + rect.size.height <= height + kEpsilon);
|
||||
}
|
||||
|
||||
int32_t VerifyCommittedLayer(const ppapi::CompositorLayerData* old_layer,
|
||||
const ppapi::CompositorLayerData* new_layer,
|
||||
std::unique_ptr<base::SharedMemory>* image_shm) {
|
||||
if (!new_layer->is_valid())
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
if (new_layer->color) {
|
||||
// Make sure the old layer is a color layer too.
|
||||
if (old_layer && !old_layer->color)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
if (new_layer->texture) {
|
||||
if (old_layer) {
|
||||
// Make sure the old layer is a texture layer too.
|
||||
if (!old_layer->texture)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
// The mailbox should be same, if the resource_id is not changed.
|
||||
if (new_layer->common.resource_id == old_layer->common.resource_id) {
|
||||
if (new_layer->texture->mailbox != old_layer->texture->mailbox)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
return PP_OK;
|
||||
}
|
||||
}
|
||||
if (!new_layer->texture->mailbox.Verify())
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
// Make sure the source rect is not beyond the dimensions of the
|
||||
// texture.
|
||||
if (!CheckPPFloatRect(new_layer->texture->source_rect, 1.0f, 1.0f))
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
if (new_layer->image) {
|
||||
if (old_layer) {
|
||||
// Make sure the old layer is an image layer too.
|
||||
if (!old_layer->image)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
// The image data resource should be same, if the resource_id is not
|
||||
// changed.
|
||||
if (new_layer->common.resource_id == old_layer->common.resource_id) {
|
||||
if (new_layer->image->resource != old_layer->image->resource)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
return PP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
EnterResourceNoLock<PPB_ImageData_API> enter(new_layer->image->resource,
|
||||
true);
|
||||
if (enter.failed())
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
// TODO(penghuang): support all kinds of image.
|
||||
PP_ImageDataDesc desc;
|
||||
if (enter.object()->Describe(&desc) != PP_TRUE ||
|
||||
desc.stride != desc.size.width * 4 ||
|
||||
desc.format != PP_IMAGEDATAFORMAT_RGBA_PREMUL) {
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
// Make sure the source rect is not beyond the dimensions of the
|
||||
// image.
|
||||
if (!CheckPPFloatRect(new_layer->image->source_rect,
|
||||
desc.size.width, desc.size.height)) {
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
base::SharedMemory* shm;
|
||||
uint32_t byte_count;
|
||||
if (enter.object()->GetSharedMemory(&shm, &byte_count) != PP_OK)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
base::SharedMemoryHandle shm_handle =
|
||||
base::SharedMemory::DuplicateHandle(shm->handle());
|
||||
if (!base::SharedMemory::IsHandleValid(shm_handle))
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
image_shm->reset(new base::SharedMemory(shm_handle, true));
|
||||
if (!(*image_shm)->Map(desc.stride * desc.size.height)) {
|
||||
image_shm->reset();
|
||||
return PP_ERROR_NOMEMORY;
|
||||
}
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PepperCompositorHost::LayerData::LayerData(
|
||||
const scoped_refptr<cc::Layer>& cc,
|
||||
const ppapi::CompositorLayerData& pp) : cc_layer(cc), pp_layer(pp) {}
|
||||
|
||||
PepperCompositorHost::LayerData::LayerData(const LayerData& other) = default;
|
||||
|
||||
PepperCompositorHost::LayerData::~LayerData() {}
|
||||
|
||||
PepperCompositorHost::PepperCompositorHost(RendererPpapiHost* host,
|
||||
PP_Instance instance,
|
||||
PP_Resource resource)
|
||||
: ResourceHost(host->GetPpapiHost(), instance, resource),
|
||||
bound_instance_(nullptr),
|
||||
weak_factory_(this) {
|
||||
layer_ = cc::Layer::Create();
|
||||
// TODO(penghuang): SetMasksToBounds() can be expensive if the layer is
|
||||
// transformed. Possibly better could be to explicitly clip the child layers
|
||||
// (by modifying their bounds).
|
||||
layer_->SetMasksToBounds(true);
|
||||
layer_->SetIsDrawable(true);
|
||||
}
|
||||
|
||||
PepperCompositorHost::~PepperCompositorHost() {
|
||||
// Unbind from the instance when destroyed if we're still bound.
|
||||
if (bound_instance_)
|
||||
bound_instance_->BindGraphics(bound_instance_->pp_instance(), 0);
|
||||
}
|
||||
|
||||
bool PepperCompositorHost::BindToInstance(
|
||||
PepperPluginInstanceImpl* new_instance) {
|
||||
if (new_instance && new_instance->pp_instance() != pp_instance())
|
||||
return false; // Can't bind other instance's contexts.
|
||||
if (bound_instance_ == new_instance)
|
||||
return true; // Rebinding the same device, nothing to do.
|
||||
if (bound_instance_ && new_instance)
|
||||
return false; // Can't change a bound device.
|
||||
bound_instance_ = new_instance;
|
||||
if (!bound_instance_)
|
||||
SendCommitLayersReplyIfNecessary();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PepperCompositorHost::ViewInitiatedPaint() {
|
||||
SendCommitLayersReplyIfNecessary();
|
||||
}
|
||||
|
||||
void PepperCompositorHost::ImageReleased(
|
||||
int32_t id,
|
||||
scoped_refptr<cc::CrossThreadSharedBitmap> shared_bitmap,
|
||||
cc::SharedBitmapIdRegistration registration,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost) {
|
||||
ResourceReleased(id, sync_token, is_lost);
|
||||
}
|
||||
|
||||
void PepperCompositorHost::ResourceReleased(int32_t id,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost) {
|
||||
host()->SendUnsolicitedReply(
|
||||
pp_resource(),
|
||||
PpapiPluginMsg_Compositor_ReleaseResource(id, sync_token, is_lost));
|
||||
}
|
||||
|
||||
void PepperCompositorHost::SendCommitLayersReplyIfNecessary() {
|
||||
if (!commit_layers_reply_context_.is_valid())
|
||||
return;
|
||||
host()->SendReply(commit_layers_reply_context_,
|
||||
PpapiPluginMsg_Compositor_CommitLayersReply());
|
||||
commit_layers_reply_context_ = ppapi::host::ReplyMessageContext();
|
||||
}
|
||||
|
||||
void PepperCompositorHost::UpdateLayer(
|
||||
const scoped_refptr<cc::Layer>& layer,
|
||||
const ppapi::CompositorLayerData* old_layer,
|
||||
const ppapi::CompositorLayerData* new_layer,
|
||||
std::unique_ptr<base::SharedMemory> image_shm) {
|
||||
// Always update properties on cc::Layer, because cc::Layer
|
||||
// will ignore any setting with unchanged value.
|
||||
gfx::SizeF size(PP_ToGfxSize(new_layer->common.size));
|
||||
gfx::RectF clip_rect(PP_ToGfxRect(new_layer->common.clip_rect));
|
||||
|
||||
// Pepper API uses DIP, so we must scale the layer's coordinates to
|
||||
// viewport in use-zoom-for-dsf.
|
||||
float dip_to_viewport_scale = 1 / viewport_to_dip_scale_;
|
||||
size.Scale(dip_to_viewport_scale);
|
||||
clip_rect.Scale(dip_to_viewport_scale);
|
||||
|
||||
layer->SetIsDrawable(true);
|
||||
layer->SetBlendMode(SkBlendMode::kSrcOver);
|
||||
layer->SetOpacity(new_layer->common.opacity);
|
||||
|
||||
layer->SetBounds(gfx::ToRoundedSize(size));
|
||||
layer->SetTransformOrigin(
|
||||
gfx::Point3F(size.width() / 2, size.height() / 2, 0.0f));
|
||||
gfx::Transform transform(gfx::Transform::kSkipInitialization);
|
||||
transform.matrix().setColMajorf(new_layer->common.transform.matrix);
|
||||
layer->SetTransform(transform);
|
||||
|
||||
// Consider a (0,0,0,0) rect as no clip rect.
|
||||
if (new_layer->common.clip_rect.point.x != 0 ||
|
||||
new_layer->common.clip_rect.point.y != 0 ||
|
||||
new_layer->common.clip_rect.size.width != 0 ||
|
||||
new_layer->common.clip_rect.size.height != 0) {
|
||||
scoped_refptr<cc::Layer> clip_parent = layer->parent();
|
||||
if (clip_parent.get() == layer_.get()) {
|
||||
// Create a clip parent layer, if it does not exist.
|
||||
clip_parent = cc::Layer::Create();
|
||||
clip_parent->SetMasksToBounds(true);
|
||||
clip_parent->SetIsDrawable(true);
|
||||
layer_->ReplaceChild(layer.get(), clip_parent);
|
||||
clip_parent->AddChild(layer);
|
||||
}
|
||||
auto position = clip_rect.origin();
|
||||
clip_parent->SetPosition(position);
|
||||
clip_parent->SetBounds(gfx::ToRoundedSize(clip_rect.size()));
|
||||
layer->SetPosition(gfx::PointF(-position.x(), -position.y()));
|
||||
} else if (layer->parent() != layer_.get()) {
|
||||
// Remove the clip parent layer.
|
||||
layer_->ReplaceChild(layer->parent(), layer);
|
||||
layer->SetPosition(gfx::PointF());
|
||||
}
|
||||
|
||||
if (new_layer->color) {
|
||||
layer->SetBackgroundColor(SkColorSetARGB(
|
||||
new_layer->color->alpha * 255, new_layer->color->red * 255,
|
||||
new_layer->color->green * 255, new_layer->color->blue * 255));
|
||||
return;
|
||||
}
|
||||
|
||||
if (new_layer->texture) {
|
||||
scoped_refptr<cc::TextureLayer> texture_layer(
|
||||
static_cast<cc::TextureLayer*>(layer.get()));
|
||||
if (!old_layer ||
|
||||
new_layer->common.resource_id != old_layer->common.resource_id) {
|
||||
auto resource = viz::TransferableResource::MakeGL(
|
||||
new_layer->texture->mailbox, GL_LINEAR, new_layer->texture->target,
|
||||
new_layer->texture->sync_token);
|
||||
texture_layer->SetTransferableResource(
|
||||
resource,
|
||||
viz::SingleReleaseCallback::Create(base::BindOnce(
|
||||
&PepperCompositorHost::ResourceReleased,
|
||||
weak_factory_.GetWeakPtr(), new_layer->common.resource_id)));
|
||||
// TODO(penghuang): get a damage region from the application and
|
||||
// pass it to SetNeedsDisplayRect().
|
||||
texture_layer->SetNeedsDisplay();
|
||||
}
|
||||
texture_layer->SetPremultipliedAlpha(new_layer->texture->premult_alpha);
|
||||
gfx::RectF rect = PP_ToGfxRectF(new_layer->texture->source_rect);
|
||||
texture_layer->SetUV(rect.origin(), rect.bottom_right());
|
||||
return;
|
||||
}
|
||||
|
||||
if (new_layer->image) {
|
||||
if (!old_layer ||
|
||||
new_layer->common.resource_id != old_layer->common.resource_id) {
|
||||
scoped_refptr<cc::TextureLayer> image_layer(
|
||||
static_cast<cc::TextureLayer*>(layer.get()));
|
||||
EnterResourceNoLock<PPB_ImageData_API> enter(new_layer->image->resource,
|
||||
true);
|
||||
DCHECK(enter.succeeded());
|
||||
|
||||
// TODO(penghuang): support all kinds of image.
|
||||
PP_ImageDataDesc desc;
|
||||
PP_Bool rv = enter.object()->Describe(&desc);
|
||||
DCHECK_EQ(rv, PP_TRUE);
|
||||
DCHECK_EQ(desc.stride, desc.size.width * 4);
|
||||
DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL);
|
||||
|
||||
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(
|
||||
shared_bitmap_id, 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(shared_bitmap),
|
||||
std::move(registration))));
|
||||
// TODO(penghuang): get a damage region from the application and
|
||||
// pass it to SetNeedsDisplayRect().
|
||||
image_layer->SetNeedsDisplay();
|
||||
|
||||
// ImageData is always premultiplied alpha.
|
||||
image_layer->SetPremultipliedAlpha(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Should not be reached.
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
int32_t PepperCompositorHost::OnResourceMessageReceived(
|
||||
const IPC::Message& msg,
|
||||
HostMessageContext* context) {
|
||||
PPAPI_BEGIN_MESSAGE_MAP(PepperCompositorHost, msg)
|
||||
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
|
||||
PpapiHostMsg_Compositor_CommitLayers, OnHostMsgCommitLayers)
|
||||
PPAPI_END_MESSAGE_MAP()
|
||||
return ppapi::host::ResourceHost::OnResourceMessageReceived(msg, context);
|
||||
}
|
||||
|
||||
bool PepperCompositorHost::IsCompositorHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t PepperCompositorHost::OnHostMsgCommitLayers(
|
||||
HostMessageContext* context,
|
||||
const std::vector<ppapi::CompositorLayerData>& layers,
|
||||
bool reset) {
|
||||
if (commit_layers_reply_context_.is_valid())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
std::unique_ptr<std::unique_ptr<base::SharedMemory>[]> image_shms;
|
||||
if (layers.size() > 0) {
|
||||
image_shms.reset(new std::unique_ptr<base::SharedMemory>[layers.size()]);
|
||||
if (!image_shms)
|
||||
return PP_ERROR_NOMEMORY;
|
||||
// Verfiy the layers first, if an error happens, we will return the error to
|
||||
// plugin and keep current layers set by the previous CommitLayers()
|
||||
// unchanged.
|
||||
for (size_t i = 0; i < layers.size(); ++i) {
|
||||
const ppapi::CompositorLayerData* old_layer = nullptr;
|
||||
if (!reset && i < layers_.size())
|
||||
old_layer = &layers_[i].pp_layer;
|
||||
int32_t rv = VerifyCommittedLayer(old_layer, &layers[i], &image_shms[i]);
|
||||
if (rv != PP_OK)
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// ResetLayers() has been called, we need rebuild layer stack.
|
||||
if (reset) {
|
||||
layer_->RemoveAllChildren();
|
||||
layers_.clear();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < layers.size(); ++i) {
|
||||
const ppapi::CompositorLayerData* pp_layer = &layers[i];
|
||||
LayerData* data = i >= layers_.size() ? nullptr : &layers_[i];
|
||||
DCHECK(!data || data->cc_layer.get());
|
||||
scoped_refptr<cc::Layer> cc_layer = data ? data->cc_layer : nullptr;
|
||||
ppapi::CompositorLayerData* old_layer = data ? &data->pp_layer : nullptr;
|
||||
|
||||
if (!cc_layer.get()) {
|
||||
if (pp_layer->color)
|
||||
cc_layer = cc::SolidColorLayer::Create();
|
||||
else if (pp_layer->texture || pp_layer->image)
|
||||
cc_layer = cc::TextureLayer::CreateForMailbox(nullptr);
|
||||
layer_->AddChild(cc_layer);
|
||||
}
|
||||
|
||||
UpdateLayer(cc_layer, old_layer, pp_layer, std::move(image_shms[i]));
|
||||
|
||||
if (old_layer)
|
||||
*old_layer = *pp_layer;
|
||||
else
|
||||
layers_.push_back(LayerData(cc_layer, *pp_layer));
|
||||
}
|
||||
|
||||
// We need to force a commit for each CommitLayers() call, even if no layers
|
||||
// changed since the last call to CommitLayers(). This is so
|
||||
// WiewInitiatedPaint() will always be called.
|
||||
if (layer_->layer_tree_host())
|
||||
layer_->layer_tree_host()->SetNeedsCommit();
|
||||
|
||||
// If the host is not bound to the instance, return PP_OK immediately.
|
||||
if (!bound_instance_)
|
||||
return PP_OK;
|
||||
|
||||
commit_layers_reply_context_ = context->MakeReplyMessageContext();
|
||||
return PP_OK_COMPLETIONPENDING;
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,122 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_HOST_H_
|
||||
#define CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_HOST_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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"
|
||||
|
||||
namespace base {
|
||||
class SharedMemory;
|
||||
} // namespace
|
||||
|
||||
namespace cc {
|
||||
class CrossThreadSharedBitmap;
|
||||
class Layer;
|
||||
} // namespace cc
|
||||
|
||||
namespace gpu {
|
||||
struct SyncToken;
|
||||
} // namespace gpu
|
||||
|
||||
namespace content {
|
||||
|
||||
class PepperPluginInstanceImpl;
|
||||
class RendererPpapiHost;
|
||||
|
||||
class PepperCompositorHost : public ppapi::host::ResourceHost {
|
||||
public:
|
||||
PepperCompositorHost(RendererPpapiHost* host,
|
||||
PP_Instance instance,
|
||||
PP_Resource resource);
|
||||
~PepperCompositorHost() override;
|
||||
|
||||
// Associates this device with the given plugin instance. You can pass NULL
|
||||
// to clear the existing device. Returns true on success. In this case, a
|
||||
// repaint of the page will also be scheduled. Failure means that the device
|
||||
// is already bound to a different instance, and nothing will happen.
|
||||
bool BindToInstance(PepperPluginInstanceImpl* new_instance);
|
||||
|
||||
const scoped_refptr<cc::Layer> layer() { return layer_; };
|
||||
|
||||
void ViewInitiatedPaint();
|
||||
|
||||
void set_viewport_to_dip_scale(float viewport_to_dip_scale) {
|
||||
DCHECK_LT(0, viewport_to_dip_scale_);
|
||||
viewport_to_dip_scale_ = viewport_to_dip_scale;
|
||||
}
|
||||
|
||||
private:
|
||||
void ImageReleased(int32_t id,
|
||||
scoped_refptr<cc::CrossThreadSharedBitmap> shared_bitmap,
|
||||
cc::SharedBitmapIdRegistration registration,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost);
|
||||
void ResourceReleased(int32_t id,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost);
|
||||
void SendCommitLayersReplyIfNecessary();
|
||||
void UpdateLayer(const scoped_refptr<cc::Layer>& layer,
|
||||
const ppapi::CompositorLayerData* old_layer,
|
||||
const ppapi::CompositorLayerData* new_layer,
|
||||
std::unique_ptr<base::SharedMemory> image_shm);
|
||||
|
||||
// ResourceMessageHandler overrides:
|
||||
int32_t OnResourceMessageReceived(
|
||||
const IPC::Message& msg,
|
||||
ppapi::host::HostMessageContext* context) override;
|
||||
|
||||
// ppapi::host::ResourceHost overrides:
|
||||
bool IsCompositorHost() override;
|
||||
|
||||
// Message handlers:
|
||||
int32_t OnHostMsgCommitLayers(
|
||||
ppapi::host::HostMessageContext* context,
|
||||
const std::vector<ppapi::CompositorLayerData>& layers,
|
||||
bool reset);
|
||||
|
||||
// Non-owning pointer to the plugin instance this context is currently bound
|
||||
// to, if any. If the context is currently unbound, this will be NULL.
|
||||
PepperPluginInstanceImpl* bound_instance_;
|
||||
|
||||
// The toplevel cc::Layer. It is the parent of other cc::Layers.
|
||||
scoped_refptr<cc::Layer> layer_;
|
||||
|
||||
// A list of layers. It is used for updating layers' properties in
|
||||
// subsequent CommitLayers() calls.
|
||||
struct LayerData {
|
||||
LayerData(const scoped_refptr<cc::Layer>& cc,
|
||||
const ppapi::CompositorLayerData& pp);
|
||||
LayerData(const LayerData& other);
|
||||
~LayerData();
|
||||
|
||||
scoped_refptr<cc::Layer> cc_layer;
|
||||
ppapi::CompositorLayerData pp_layer;
|
||||
};
|
||||
std::vector<LayerData> layers_;
|
||||
|
||||
ppapi::host::ReplyMessageContext commit_layers_reply_context_;
|
||||
|
||||
// The scale between the viewport and dip. This differs in
|
||||
// use-zoom-for-dsf mode where the content is scaled by zooming.
|
||||
float viewport_to_dip_scale_ = 1.0f;
|
||||
|
||||
base::WeakPtrFactory<PepperCompositorHost> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PepperCompositorHost);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_HOST_H_
|
@ -36,7 +36,6 @@
|
||||
#include "content/renderer/pepper/message_channel.h"
|
||||
#include "content/renderer/pepper/pepper_audio_controller.h"
|
||||
#include "content/renderer/pepper/pepper_browser_connection.h"
|
||||
#include "content/renderer/pepper/pepper_compositor_host.h"
|
||||
#include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
|
||||
#include "content/renderer/pepper/pepper_graphics_2d_host.h"
|
||||
#include "content/renderer/pepper/pepper_in_process_router.h"
|
||||
@ -516,7 +515,6 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
|
||||
viewport_to_dip_scale_(1.0f),
|
||||
sent_initial_did_change_view_(false),
|
||||
bound_graphics_2d_platform_(nullptr),
|
||||
bound_compositor_(nullptr),
|
||||
has_webkit_focus_(false),
|
||||
has_content_area_focus_(false),
|
||||
find_identifier_(-1),
|
||||
@ -747,13 +745,11 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) {
|
||||
container_->InvalidateRect(rect);
|
||||
}
|
||||
|
||||
cc::Layer* layer =
|
||||
texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
|
||||
if (layer) {
|
||||
if (texture_layer_) {
|
||||
if (rect.IsEmpty()) {
|
||||
layer->SetNeedsDisplay();
|
||||
texture_layer_->SetNeedsDisplay();
|
||||
} else {
|
||||
layer->SetNeedsDisplayRect(rect);
|
||||
texture_layer_->SetNeedsDisplayRect(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -761,9 +757,7 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) {
|
||||
void PepperPluginInstanceImpl::ScrollRect(int dx,
|
||||
int dy,
|
||||
const gfx::Rect& rect) {
|
||||
cc::Layer* layer =
|
||||
texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
|
||||
if (layer) {
|
||||
if (texture_layer_) {
|
||||
InvalidateRect(rect);
|
||||
} else if (fullscreen_container_) {
|
||||
fullscreen_container_->ScrollRect(dx, dy, rect);
|
||||
@ -1398,8 +1392,6 @@ void PepperPluginInstanceImpl::ViewInitiatedPaint() {
|
||||
bound_graphics_2d_platform_->ViewInitiatedPaint();
|
||||
else if (bound_graphics_3d_.get())
|
||||
bound_graphics_3d_->ViewInitiatedPaint();
|
||||
else if (bound_compositor_)
|
||||
bound_compositor_->ViewInitiatedPaint();
|
||||
}
|
||||
|
||||
void PepperPluginInstanceImpl::SetSelectedText(
|
||||
@ -1854,9 +1846,6 @@ void PepperPluginInstanceImpl::SendDidChangeView() {
|
||||
if (module()->is_crashed())
|
||||
return;
|
||||
|
||||
if (bound_compositor_)
|
||||
bound_compositor_->set_viewport_to_dip_scale(viewport_to_dip_scale_);
|
||||
|
||||
if (bound_graphics_2d_platform_)
|
||||
bound_graphics_2d_platform_->set_viewport_to_dip_scale(
|
||||
viewport_to_dip_scale_);
|
||||
@ -2204,36 +2193,29 @@ void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
|
||||
bool want_3d_layer = !!bound_graphics_3d_.get();
|
||||
bool want_2d_layer = !!bound_graphics_2d_platform_;
|
||||
bool want_texture_layer = want_3d_layer || want_2d_layer;
|
||||
bool want_compositor_layer = !!bound_compositor_;
|
||||
|
||||
if (throttler_ && throttler_->IsHiddenForPlaceholder()) {
|
||||
want_3d_layer = false;
|
||||
want_2d_layer = false;
|
||||
want_texture_layer = false;
|
||||
want_compositor_layer = false;
|
||||
}
|
||||
|
||||
if (!force_creation && (want_texture_layer == !!texture_layer_) &&
|
||||
(want_3d_layer == layer_is_hardware_) &&
|
||||
(want_compositor_layer == !!compositor_layer_.get()) &&
|
||||
layer_bound_to_fullscreen_ == !!fullscreen_container_) {
|
||||
UpdateLayerTransform();
|
||||
return;
|
||||
}
|
||||
|
||||
if (texture_layer_ || compositor_layer_) {
|
||||
if (texture_layer_) {
|
||||
if (!layer_bound_to_fullscreen_)
|
||||
container_->SetCcLayer(nullptr, false);
|
||||
else if (fullscreen_container_)
|
||||
fullscreen_container_->SetLayer(nullptr);
|
||||
if (texture_layer_) {
|
||||
texture_layer_->ClearClient();
|
||||
texture_layer_ = nullptr;
|
||||
}
|
||||
compositor_layer_ = nullptr;
|
||||
texture_layer_->ClearClient();
|
||||
texture_layer_ = nullptr;
|
||||
}
|
||||
|
||||
cc::Layer* either_layer = nullptr;
|
||||
if (want_texture_layer) {
|
||||
bool opaque = false;
|
||||
if (want_3d_layer) {
|
||||
@ -2255,19 +2237,15 @@ void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
|
||||
// wmode=transparent was specified.
|
||||
opaque = opaque || fullscreen_container_;
|
||||
texture_layer_->SetContentsOpaque(opaque);
|
||||
either_layer = texture_layer_.get();
|
||||
} else if (want_compositor_layer) {
|
||||
compositor_layer_ = bound_compositor_->layer();
|
||||
either_layer = compositor_layer_.get();
|
||||
}
|
||||
|
||||
if (either_layer) {
|
||||
if (texture_layer_) {
|
||||
if (fullscreen_container_)
|
||||
fullscreen_container_->SetLayer(either_layer);
|
||||
fullscreen_container_->SetLayer(texture_layer_.get());
|
||||
else
|
||||
container_->SetCcLayer(either_layer, true);
|
||||
container_->SetCcLayer(texture_layer_.get(), true);
|
||||
if (is_flash_plugin_)
|
||||
either_layer->SetMayContainVideo(true);
|
||||
texture_layer_->SetMayContainVideo(true);
|
||||
}
|
||||
|
||||
layer_bound_to_fullscreen_ = !!fullscreen_container_;
|
||||
@ -2448,10 +2426,6 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance,
|
||||
bound_graphics_2d_platform_->BindToInstance(nullptr);
|
||||
bound_graphics_2d_platform_ = nullptr;
|
||||
}
|
||||
if (bound_compositor_) {
|
||||
bound_compositor_->BindToInstance(nullptr);
|
||||
bound_compositor_ = nullptr;
|
||||
}
|
||||
|
||||
// Special-case clearing the current device.
|
||||
if (!device) {
|
||||
@ -2470,12 +2444,9 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance,
|
||||
RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost();
|
||||
ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device);
|
||||
PepperGraphics2DHost* graphics_2d = nullptr;
|
||||
PepperCompositorHost* compositor = nullptr;
|
||||
if (host) {
|
||||
if (host->IsGraphics2DHost()) {
|
||||
graphics_2d = static_cast<PepperGraphics2DHost*>(host);
|
||||
} else if (host->IsCompositorHost()) {
|
||||
compositor = static_cast<PepperCompositorHost*>(host);
|
||||
} else {
|
||||
DLOG(ERROR) <<
|
||||
"Resource is not PepperCompositorHost or PepperGraphics2DHost.";
|
||||
@ -2488,14 +2459,7 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance,
|
||||
? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object())
|
||||
: nullptr;
|
||||
|
||||
if (compositor) {
|
||||
if (compositor->BindToInstance(this)) {
|
||||
bound_compositor_ = compositor;
|
||||
bound_compositor_->set_viewport_to_dip_scale(viewport_to_dip_scale_);
|
||||
UpdateLayer(true);
|
||||
return PP_TRUE;
|
||||
}
|
||||
} else if (graphics_2d) {
|
||||
if (graphics_2d) {
|
||||
if (graphics_2d->BindToInstance(this)) {
|
||||
bound_graphics_2d_platform_ = graphics_2d;
|
||||
bound_graphics_2d_platform_->set_viewport_to_dip_scale(
|
||||
|
@ -107,7 +107,6 @@ namespace content {
|
||||
class FullscreenContainer;
|
||||
class MessageChannel;
|
||||
class PepperAudioController;
|
||||
class PepperCompositorHost;
|
||||
class PepperGraphics2DHost;
|
||||
class PluginInstanceThrottlerImpl;
|
||||
class PluginModule;
|
||||
@ -708,7 +707,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
|
||||
|
||||
// NULL until we have been initialized.
|
||||
blink::WebPluginContainer* container_;
|
||||
scoped_refptr<cc::Layer> compositor_layer_;
|
||||
scoped_refptr<cc::TextureLayer> texture_layer_;
|
||||
bool layer_bound_to_fullscreen_;
|
||||
bool layer_is_hardware_;
|
||||
@ -746,10 +744,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
|
||||
// same as the default values.
|
||||
bool sent_initial_did_change_view_;
|
||||
|
||||
// The current device context for painting in 2D, 3D or compositor.
|
||||
// The current device context for painting in 2D or 3D.
|
||||
scoped_refptr<PPB_Graphics3D_Impl> bound_graphics_3d_;
|
||||
PepperGraphics2DHost* bound_graphics_2d_platform_;
|
||||
PepperCompositorHost* bound_compositor_;
|
||||
|
||||
// We track two types of focus, one from WebKit, which is the focus among
|
||||
// all elements of the page, one one from the browser, which is whether the
|
||||
|
@ -63,8 +63,6 @@
|
||||
#include "ppapi/c/ppb_audio_buffer.h"
|
||||
#include "ppapi/c/ppb_audio_config.h"
|
||||
#include "ppapi/c/ppb_audio_encoder.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_console.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_file_io.h"
|
||||
|
@ -78,10 +78,6 @@ PP_Resource ResourceCreationImpl::CreateAudioOutput(PP_Instance instance) {
|
||||
return 0; // Not supported in-process.
|
||||
}
|
||||
|
||||
PP_Resource ResourceCreationImpl::CreateCompositor(PP_Instance instance) {
|
||||
return 0; // Not supported in-process.
|
||||
}
|
||||
|
||||
PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
|
||||
return (new PPB_Broker_Impl(instance))->GetReference();
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
|
||||
uint32_t sample_frame_count) override;
|
||||
PP_Resource CreateAudioInput(PP_Instance instance) override;
|
||||
PP_Resource CreateAudioOutput(PP_Instance instance) override;
|
||||
PP_Resource CreateCompositor(PP_Instance instance) override;
|
||||
PP_Resource CreateBroker(PP_Instance instance) override;
|
||||
PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) override;
|
||||
PP_Resource CreateCameraDevicePrivate(PP_Instance instance) override;
|
||||
|
@ -164,16 +164,6 @@ void ShellContentRendererClient::PrepareErrorPageForHttpStatusError(
|
||||
}
|
||||
}
|
||||
|
||||
bool ShellContentRendererClient::IsPluginAllowedToUseCompositorAPI(
|
||||
const GURL& url) {
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnablePepperTesting);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ShellContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() {
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
|
@ -42,7 +42,6 @@ class ShellContentRendererClient : public ContentRendererClient {
|
||||
|
||||
// TODO(mkwst): These toggle based on the kEnablePepperTesting flag. Do we
|
||||
// need that outside of web tests?
|
||||
bool IsPluginAllowedToUseCompositorAPI(const GURL& url) override;
|
||||
bool IsPluginAllowedToUseDevChannelAPIs() override;
|
||||
|
||||
void DidInitializeWorkerContextOnWorkerThread(
|
||||
|
@ -23,8 +23,6 @@
|
||||
'ppb_audio_config.h',
|
||||
'ppb_audio_encoder.h',
|
||||
'ppb_audio.h',
|
||||
'ppb_compositor.h',
|
||||
'ppb_compositor_layer.h',
|
||||
'ppb_console.h',
|
||||
'ppb_core.h',
|
||||
'ppb_file_io.h',
|
||||
|
@ -18,8 +18,6 @@
|
||||
'audio_buffer.cc',
|
||||
'audio_config.cc',
|
||||
'audio_encoder.cc',
|
||||
'compositor.cc',
|
||||
'compositor_layer.cc',
|
||||
'core.cc',
|
||||
'directory_entry.cc',
|
||||
'file_io.cc',
|
||||
@ -95,8 +93,6 @@
|
||||
'audio_encoder.h',
|
||||
'audio.h',
|
||||
'completion_callback.h',
|
||||
'compositor.h',
|
||||
'compositor_layer.h',
|
||||
'core.h',
|
||||
'directory_entry.h',
|
||||
'file_io.h',
|
||||
|
@ -36,8 +36,6 @@ test_common_source_files = [
|
||||
"tests/test_audio_encoder.h",
|
||||
"tests/test_case.cc",
|
||||
"tests/test_case.h",
|
||||
"tests/test_compositor.cc",
|
||||
"tests/test_compositor.h",
|
||||
"tests/test_console.cc",
|
||||
"tests/test_console.h",
|
||||
"tests/test_core.cc",
|
||||
|
@ -1,131 +0,0 @@
|
||||
/* Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
[generate_thunk]
|
||||
|
||||
label Chrome {
|
||||
[channel=dev] M37 = 0.1
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the <code>PPB_Compositor</code> interface. Used for setting
|
||||
* <code>PPB_CompositorLayer</code> layers to the Chromium compositor for
|
||||
* compositing. This allows a plugin to combine different sources of visual
|
||||
* data efficiently, such as <code>PPB_ImageData</code> images and
|
||||
* OpenGL textures. See also <code>PPB_CompositorLayer</code> for more
|
||||
* information.
|
||||
* This interface is still in development (Dev API status) and may change,
|
||||
* so is only supported on Dev channel and Canary currently.
|
||||
*
|
||||
* <strong>Example usage from plugin code:</strong>
|
||||
*
|
||||
* <strong>Setup:</strong>
|
||||
* @code
|
||||
* PP_Resource compositor;
|
||||
* compositor = compositor_if->Create(instance);
|
||||
* instance_if->BindGraphics(instance, compositor);
|
||||
* @endcode
|
||||
*
|
||||
* <strong>Setup layer stack:</strong>
|
||||
* @code
|
||||
* PP_Resource color_layer = compositor_if->AddLayer(compositor);
|
||||
* PP_Resource texture_layer = compositor_if->AddLayer(compositor);
|
||||
* @endcode
|
||||
*
|
||||
* <strong> Present one frame:</strong>
|
||||
* layer_if->SetColor(color_layer, 255, 255, 0, 255, PP_MakeSize(400, 400));
|
||||
* PP_CompletionCallback release_callback = {
|
||||
* TextureReleasedCallback, 0, PP_COMPLETIONCALLBACK_FLAG_NONE,
|
||||
* };
|
||||
* layer_if->SetTexture(texture_layer, graphics3d, texture_id,
|
||||
* PP_MakeSize(300, 300), release_callback);
|
||||
*
|
||||
* PP_CompletionCallback callback = {
|
||||
* DidFinishCommitLayersCallback,
|
||||
* (void*) texture_id,
|
||||
* PP_COMPLETIONCALLBACK_FLAG_NONE,
|
||||
* };
|
||||
* compositor_if->CommitLayers(compositor, callback);
|
||||
* @endcode
|
||||
*
|
||||
* <strong>release callback</strong>
|
||||
* void ReleaseCallback(int32_t result, void* user_data) {
|
||||
* if (result == PP_OK) {
|
||||
* uint32_t texture_id = (uint32_t) user_data;
|
||||
* // reuse the texture or delete it.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* <strong>Shutdown:</strong>
|
||||
* @code
|
||||
* core->ReleaseResource(color_layer);
|
||||
* core->ReleaseResource(texture_layer);
|
||||
* core->ReleaseResource(compositor);
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
interface PPB_Compositor {
|
||||
/**
|
||||
* Determines if a resource is a compositor resource.
|
||||
*
|
||||
* @param[in] resource The <code>PP_Resource</code> to test.
|
||||
*
|
||||
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
|
||||
* resource is a compositor resource or <code>PP_FALSE</code> otherwise.
|
||||
*/
|
||||
PP_Bool IsCompositor([in] PP_Resource resource);
|
||||
|
||||
/**
|
||||
* Creates a Compositor resource.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> identifying one instance
|
||||
* of a module.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> containing the compositor resource if
|
||||
* successful or 0 otherwise.
|
||||
*/
|
||||
PP_Resource Create([in] PP_Instance instance);
|
||||
|
||||
/**
|
||||
* Creates a new <code>PPB_CompositorLayer</code> and adds it to the end
|
||||
* of the layer stack. A <code>PP_Resource</code> containing the layer is
|
||||
* returned. It is uninitialized, <code>SetColor()</code>,
|
||||
* <code>SetTexture</code> or <code>SetImage</code> should be used to
|
||||
* initialize it. The layer will appear above other pre-existing layers.
|
||||
* If <code>ResetLayers</code> is called or the <code>PPB_Compositor</code> is
|
||||
* released, the returned layer will be invalidated, and any further calls on
|
||||
* the layer will return <code>PP_ERROR_BADRESOURCE</code>.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> containing the compositor layer
|
||||
* resource if successful or 0 otherwise.
|
||||
*/
|
||||
PP_Resource AddLayer([in] PP_Resource compositor);
|
||||
|
||||
/**
|
||||
* Commits layers added by <code>AddLayer()</code> to the chromium compositor.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
* @param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* layers have been represented on screen.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t CommitLayers([in] PP_Resource compositor,
|
||||
[in] PP_CompletionCallback cc);
|
||||
|
||||
/**
|
||||
* Resets layers added by <code>AddLayer()</code>.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t ResetLayers([in] PP_Resource compositor);
|
||||
};
|
@ -1,251 +0,0 @@
|
||||
/* Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
[generate_thunk]
|
||||
|
||||
label Chrome {
|
||||
[channel=dev] M37 = 0.1,
|
||||
[channel=dev] M38 = 0.2
|
||||
};
|
||||
|
||||
/**
|
||||
* This enumeration contains blend modes used for computing the result pixels
|
||||
* based on the source RGBA values in layers with the RGBA values that are
|
||||
* already in the destination framebuffer.
|
||||
* alpha_src, color_src: source alpha and color.
|
||||
* alpha_dst, color_dst: destination alpha and color (before compositing).
|
||||
* Below descriptions of the blend modes assume the colors are pre-multiplied.
|
||||
* This interface is still in development (Dev API status) and may change,
|
||||
* so is only supported on Dev channel and Canary currently.
|
||||
*/
|
||||
enum PP_BlendMode {
|
||||
/**
|
||||
* No blending, copy source to the destination directly.
|
||||
*/
|
||||
PP_BLENDMODE_NONE,
|
||||
|
||||
/**
|
||||
* Source is placed over the destination.
|
||||
* Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst
|
||||
* Resulting color = color_src + color_dst * (1 - alpha_src)
|
||||
*/
|
||||
PP_BLENDMODE_SRC_OVER,
|
||||
|
||||
/**
|
||||
* The last blend mode.
|
||||
*/
|
||||
PP_BLENDMODE_LAST = PP_BLENDMODE_SRC_OVER
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the <code>PPB_CompositorLayer</code> interface. It is used by
|
||||
* <code>PPB_Compositor</code>.
|
||||
*/
|
||||
interface PPB_CompositorLayer {
|
||||
/**
|
||||
* Determines if a resource is a compositor layer resource.
|
||||
*
|
||||
* @param[in] resource The <code>PP_Resource</code> to test.
|
||||
*
|
||||
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
|
||||
* resource is a compositor layer resource or <code>PP_FALSE</code>
|
||||
* otherwise.
|
||||
*/
|
||||
PP_Bool IsCompositorLayer([in] PP_Resource resource);
|
||||
|
||||
/**
|
||||
* Sets the color of a solid color layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its color.
|
||||
* If the layer has been initialized to another kind of layer, the layer will
|
||||
* not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] red A <code>float</code> for the red color component. It will be
|
||||
* clamped to [0, 1].
|
||||
* param[in] green A <code>float</code> for the green color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] blue A <code>float</code> for the blue color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] alpha A <code>float</code> for the alpha color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetColor([in] PP_Resource layer,
|
||||
[in] float_t red,
|
||||
[in] float_t green,
|
||||
[in] float_t blue,
|
||||
[in] float_t alpha,
|
||||
[in] PP_Size size);
|
||||
|
||||
/**
|
||||
* Sets the texture of a texture layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its texture.
|
||||
* The source rect will be set to ((0, 0), (1, 1)). If the layer has been
|
||||
* initialized to another kind of layer, the layer will not be changed,
|
||||
* and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] context A <code>PP_Resource</code> corresponding to a graphics
|
||||
* 3d resource which owns the GL texture.
|
||||
* param[in] texture A GL texture object id.
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform.
|
||||
* param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* the texture is released by Chromium compositor.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetTexture([in] PP_Resource layer,
|
||||
[in] PP_Resource context,
|
||||
[in] uint32_t texture,
|
||||
[in] PP_Size size,
|
||||
[in] PP_CompletionCallback cc);
|
||||
|
||||
/**
|
||||
* Sets the texture of a texture layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its texture.
|
||||
* The source rect will be set to ((0, 0), (1, 1)). If the layer has been
|
||||
* initialized to another kind of layer, the layer will not be changed,
|
||||
* and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] context A <code>PP_Resource</code> corresponding to a graphics
|
||||
* 3d resource which owns the GL texture.
|
||||
* param[in] target GL texture target (GL_TEXTURE_2D, etc).
|
||||
* param[in] texture A GL texture object id.
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform.
|
||||
* param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* the texture is released by Chromium compositor.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
[version = 0.2]
|
||||
int32_t SetTexture([in] PP_Resource layer,
|
||||
[in] PP_Resource context,
|
||||
[in] uint32_t target,
|
||||
[in] uint32_t texture,
|
||||
[in] PP_Size size,
|
||||
[in] PP_CompletionCallback cc);
|
||||
|
||||
/**
|
||||
* Sets the image of an image layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its image.
|
||||
* The layer size will be set to the image's size. The source rect will be set
|
||||
* to the full image. If the layer has been initialized to another kind of
|
||||
* layer, the layer will not be changed, and <code>PP_ERROR_BADARGUMENT</code>
|
||||
* will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] image_data A <code>PP_Resource</code> corresponding to
|
||||
* an image data resource.
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform. If NULL, the image's size will be used.
|
||||
* param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* the image data is released by Chromium compositor.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetImage([in] PP_Resource layer,
|
||||
[in] PP_Resource image_data,
|
||||
[in] PP_Size size,
|
||||
[in] PP_CompletionCallback cc);
|
||||
|
||||
/**
|
||||
* Sets a clip rectangle for a compositor layer. The Chromium compositor
|
||||
* applies a transform matrix on the layer first, and then clips the layer
|
||||
* with the rectangle.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] rect The clip rectangle. The origin is top-left corner of
|
||||
* the plugin.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetClipRect([in] PP_Resource layer,
|
||||
[in] PP_Rect rect);
|
||||
|
||||
/**
|
||||
* Sets a transform matrix which is used to composite the layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] matrix A float array with 16 elements. The matrix is
|
||||
* column major. The default transform matrix is an identity matrix.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetTransform([in] PP_Resource layer,
|
||||
[in] float_t[16] matrix);
|
||||
|
||||
/**
|
||||
* Sets the opacity value which will be applied to the layer. The effective
|
||||
* value of each pixel is computed as:
|
||||
*
|
||||
* if (premult_alpha)
|
||||
* pixel.rgb = pixel.rgb * opacity;
|
||||
* pixel.a = pixel.a * opactiy;
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] opacity A <code>float</code> for the opacity value, The default
|
||||
* value is 1.0f.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetOpacity([in] PP_Resource layer,
|
||||
[in] float_t opacity);
|
||||
|
||||
/**
|
||||
* Sets the blend mode which is used to composite the layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] mode A <code>PP_BlendMode</code>. The default mode is
|
||||
* <code>PP_BLENDMODE_SRC_OVER</code>.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetBlendMode([in] PP_Resource layer,
|
||||
[in] PP_BlendMode mode);
|
||||
|
||||
/**
|
||||
* Sets a source rectangle for a texture layer or an image layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] rect A <code>PP_FloatRect</code> for an area of the source to
|
||||
* consider. For a texture layer, rect is in uv coordinates. For an image
|
||||
* layer, rect is in pixels. If the rect is beyond the dimensions of the
|
||||
* texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
* If the layer size does not match the source rect size, bilinear scaling
|
||||
* will be used.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetSourceRect([in] PP_Resource layer,
|
||||
[in] PP_FloatRect rect);
|
||||
|
||||
/**
|
||||
* Sets the premultiplied alpha for an texture layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] premult A <code>PP_Bool</code> with <code>PP_TRUE</code> if
|
||||
* pre-multiplied alpha is used.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t SetPremultipliedAlpha([in] PP_Resource layer,
|
||||
[in] PP_Bool premult);
|
||||
};
|
@ -30,8 +30,6 @@ source_set("c") {
|
||||
"ppb_audio_buffer.h",
|
||||
"ppb_audio_config.h",
|
||||
"ppb_audio_encoder.h",
|
||||
"ppb_compositor.h",
|
||||
"ppb_compositor_layer.h",
|
||||
"ppb_console.h",
|
||||
"ppb_core.h",
|
||||
"ppb_file_io.h",
|
||||
|
@ -1,148 +0,0 @@
|
||||
/* Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* From ppb_compositor.idl modified Tue Jun 3 12:44:44 2014. */
|
||||
|
||||
#ifndef PPAPI_C_PPB_COMPOSITOR_H_
|
||||
#define PPAPI_C_PPB_COMPOSITOR_H_
|
||||
|
||||
#include "ppapi/c/pp_bool.h"
|
||||
#include "ppapi/c/pp_completion_callback.h"
|
||||
#include "ppapi/c/pp_instance.h"
|
||||
#include "ppapi/c/pp_macros.h"
|
||||
#include "ppapi/c/pp_resource.h"
|
||||
#include "ppapi/c/pp_stdint.h"
|
||||
|
||||
#define PPB_COMPOSITOR_INTERFACE_0_1 "PPB_Compositor;0.1" /* dev */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup Interfaces
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Defines the <code>PPB_Compositor</code> interface. Used for setting
|
||||
* <code>PPB_CompositorLayer</code> layers to the Chromium compositor for
|
||||
* compositing. This allows a plugin to combine different sources of visual
|
||||
* data efficiently, such as <code>PPB_ImageData</code> images and
|
||||
* OpenGL textures. See also <code>PPB_CompositorLayer</code> for more
|
||||
* information.
|
||||
* This interface is still in development (Dev API status) and may change,
|
||||
* so is only supported on Dev channel and Canary currently.
|
||||
*
|
||||
* <strong>Example usage from plugin code:</strong>
|
||||
*
|
||||
* <strong>Setup:</strong>
|
||||
* @code
|
||||
* PP_Resource compositor;
|
||||
* compositor = compositor_if->Create(instance);
|
||||
* instance_if->BindGraphics(instance, compositor);
|
||||
* @endcode
|
||||
*
|
||||
* <strong>Setup layer stack:</strong>
|
||||
* @code
|
||||
* PP_Resource color_layer = compositor_if->AddLayer(compositor);
|
||||
* PP_Resource texture_layer = compositor_if->AddLayer(compositor);
|
||||
* @endcode
|
||||
*
|
||||
* <strong> Present one frame:</strong>
|
||||
* layer_if->SetColor(color_layer, 255, 255, 0, 255, PP_MakeSize(400, 400));
|
||||
* PP_CompletionCallback release_callback = {
|
||||
* TextureReleasedCallback, 0, PP_COMPLETIONCALLBACK_FLAG_NONE,
|
||||
* };
|
||||
* layer_if->SetTexture(texture_layer, graphics3d, texture_id,
|
||||
* PP_MakeSize(300, 300), release_callback);
|
||||
*
|
||||
* PP_CompletionCallback callback = {
|
||||
* DidFinishCommitLayersCallback,
|
||||
* (void*) texture_id,
|
||||
* PP_COMPLETIONCALLBACK_FLAG_NONE,
|
||||
* };
|
||||
* compositor_if->CommitLayers(compositor, callback);
|
||||
* @endcode
|
||||
*
|
||||
* <strong>release callback</strong>
|
||||
* void ReleaseCallback(int32_t result, void* user_data) {
|
||||
* if (result == PP_OK) {
|
||||
* uint32_t texture_id = (uint32_t) user_data;
|
||||
* // reuse the texture or delete it.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* <strong>Shutdown:</strong>
|
||||
* @code
|
||||
* core->ReleaseResource(color_layer);
|
||||
* core->ReleaseResource(texture_layer);
|
||||
* core->ReleaseResource(compositor);
|
||||
* @endcode
|
||||
*/
|
||||
struct PPB_Compositor_0_1 { /* dev */
|
||||
/**
|
||||
* Determines if a resource is a compositor resource.
|
||||
*
|
||||
* @param[in] resource The <code>PP_Resource</code> to test.
|
||||
*
|
||||
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
|
||||
* resource is a compositor resource or <code>PP_FALSE</code> otherwise.
|
||||
*/
|
||||
PP_Bool (*IsCompositor)(PP_Resource resource);
|
||||
/**
|
||||
* Creates a Compositor resource.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> identifying one instance
|
||||
* of a module.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> containing the compositor resource if
|
||||
* successful or 0 otherwise.
|
||||
*/
|
||||
PP_Resource (*Create)(PP_Instance instance);
|
||||
/**
|
||||
* Creates a new <code>PPB_CompositorLayer</code> and adds it to the end
|
||||
* of the layer stack. A <code>PP_Resource</code> containing the layer is
|
||||
* returned. It is uninitialized, <code>SetColor()</code>,
|
||||
* <code>SetTexture</code> or <code>SetImage</code> should be used to
|
||||
* initialize it. The layer will appear above other pre-existing layers.
|
||||
* If <code>ResetLayers</code> is called or the <code>PPB_Compositor</code> is
|
||||
* released, the returned layer will be invalidated, and any further calls on
|
||||
* the layer will return <code>PP_ERROR_BADRESOURCE</code>.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> containing the compositor layer
|
||||
* resource if successful or 0 otherwise.
|
||||
*/
|
||||
PP_Resource (*AddLayer)(PP_Resource compositor);
|
||||
/**
|
||||
* Commits layers added by <code>AddLayer()</code> to the chromium compositor.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
* @param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* layers have been represented on screen.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*CommitLayers)(PP_Resource compositor,
|
||||
struct PP_CompletionCallback cc);
|
||||
/**
|
||||
* Resets layers added by <code>AddLayer()</code>.
|
||||
*
|
||||
* param[in] compositor A <code>PP_Resource</code> corresponding to
|
||||
* a compositor layer resource.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*ResetLayers)(PP_Resource compositor);
|
||||
};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* PPAPI_C_PPB_COMPOSITOR_H_ */
|
||||
|
@ -1,264 +0,0 @@
|
||||
/* Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* From ppb_compositor_layer.idl modified Thu Aug 14 18:06:33 2014. */
|
||||
|
||||
#ifndef PPAPI_C_PPB_COMPOSITOR_LAYER_H_
|
||||
#define PPAPI_C_PPB_COMPOSITOR_LAYER_H_
|
||||
|
||||
#include "ppapi/c/pp_bool.h"
|
||||
#include "ppapi/c/pp_completion_callback.h"
|
||||
#include "ppapi/c/pp_macros.h"
|
||||
#include "ppapi/c/pp_point.h"
|
||||
#include "ppapi/c/pp_rect.h"
|
||||
#include "ppapi/c/pp_resource.h"
|
||||
#include "ppapi/c/pp_size.h"
|
||||
#include "ppapi/c/pp_stdint.h"
|
||||
|
||||
#define PPB_COMPOSITORLAYER_INTERFACE_0_1 "PPB_CompositorLayer;0.1" /* dev */
|
||||
#define PPB_COMPOSITORLAYER_INTERFACE_0_2 "PPB_CompositorLayer;0.2" /* dev */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup Enums
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* This enumeration contains blend modes used for computing the result pixels
|
||||
* based on the source RGBA values in layers with the RGBA values that are
|
||||
* already in the destination framebuffer.
|
||||
* alpha_src, color_src: source alpha and color.
|
||||
* alpha_dst, color_dst: destination alpha and color (before compositing).
|
||||
* Below descriptions of the blend modes assume the colors are pre-multiplied.
|
||||
* This interface is still in development (Dev API status) and may change,
|
||||
* so is only supported on Dev channel and Canary currently.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* No blending, copy source to the destination directly.
|
||||
*/
|
||||
PP_BLENDMODE_NONE,
|
||||
/**
|
||||
* Source is placed over the destination.
|
||||
* Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst
|
||||
* Resulting color = color_src + color_dst * (1 - alpha_src)
|
||||
*/
|
||||
PP_BLENDMODE_SRC_OVER,
|
||||
/**
|
||||
* The last blend mode.
|
||||
*/
|
||||
PP_BLENDMODE_LAST = PP_BLENDMODE_SRC_OVER
|
||||
} PP_BlendMode;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Interfaces
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Defines the <code>PPB_CompositorLayer</code> interface. It is used by
|
||||
* <code>PPB_Compositor</code>.
|
||||
*/
|
||||
struct PPB_CompositorLayer_0_2 { /* dev */
|
||||
/**
|
||||
* Determines if a resource is a compositor layer resource.
|
||||
*
|
||||
* @param[in] resource The <code>PP_Resource</code> to test.
|
||||
*
|
||||
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
|
||||
* resource is a compositor layer resource or <code>PP_FALSE</code>
|
||||
* otherwise.
|
||||
*/
|
||||
PP_Bool (*IsCompositorLayer)(PP_Resource resource);
|
||||
/**
|
||||
* Sets the color of a solid color layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its color.
|
||||
* If the layer has been initialized to another kind of layer, the layer will
|
||||
* not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] red A <code>float</code> for the red color component. It will be
|
||||
* clamped to [0, 1].
|
||||
* param[in] green A <code>float</code> for the green color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] blue A <code>float</code> for the blue color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] alpha A <code>float</code> for the alpha color component. It will
|
||||
* be clamped to [0, 1].
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetColor)(PP_Resource layer,
|
||||
float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const struct PP_Size* size);
|
||||
/**
|
||||
* Sets the texture of a texture layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its texture.
|
||||
* The source rect will be set to ((0, 0), (1, 1)). If the layer has been
|
||||
* initialized to another kind of layer, the layer will not be changed,
|
||||
* and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] context A <code>PP_Resource</code> corresponding to a graphics
|
||||
* 3d resource which owns the GL texture.
|
||||
* param[in] target GL texture target (GL_TEXTURE_2D, etc).
|
||||
* param[in] texture A GL texture object id.
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform.
|
||||
* param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* the texture is released by Chromium compositor.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetTexture)(PP_Resource layer,
|
||||
PP_Resource context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc);
|
||||
/**
|
||||
* Sets the image of an image layer. If the layer is uninitialized,
|
||||
* it will initialize the layer first, and then set its image.
|
||||
* The layer size will be set to the image's size. The source rect will be set
|
||||
* to the full image. If the layer has been initialized to another kind of
|
||||
* layer, the layer will not be changed, and <code>PP_ERROR_BADARGUMENT</code>
|
||||
* will be returned.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] image_data A <code>PP_Resource</code> corresponding to
|
||||
* an image data resource.
|
||||
* param[in] size A <code>PP_Size</code> for the size of the layer before
|
||||
* transform. If NULL, the image's size will be used.
|
||||
* param[in] cc A <code>PP_CompletionCallback</code> to be called when
|
||||
* the image data is released by Chromium compositor.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetImage)(PP_Resource layer,
|
||||
PP_Resource image_data,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc);
|
||||
/**
|
||||
* Sets a clip rectangle for a compositor layer. The Chromium compositor
|
||||
* applies a transform matrix on the layer first, and then clips the layer
|
||||
* with the rectangle.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] rect The clip rectangle. The origin is top-left corner of
|
||||
* the plugin.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect);
|
||||
/**
|
||||
* Sets a transform matrix which is used to composite the layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] matrix A float array with 16 elements. The matrix is
|
||||
* column major. The default transform matrix is an identity matrix.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]);
|
||||
/**
|
||||
* Sets the opacity value which will be applied to the layer. The effective
|
||||
* value of each pixel is computed as:
|
||||
*
|
||||
* if (premult_alpha)
|
||||
* pixel.rgb = pixel.rgb * opacity;
|
||||
* pixel.a = pixel.a * opactiy;
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] opacity A <code>float</code> for the opacity value, The default
|
||||
* value is 1.0f.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetOpacity)(PP_Resource layer, float opacity);
|
||||
/**
|
||||
* Sets the blend mode which is used to composite the layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] mode A <code>PP_BlendMode</code>. The default mode is
|
||||
* <code>PP_BLENDMODE_SRC_OVER</code>.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode);
|
||||
/**
|
||||
* Sets a source rectangle for a texture layer or an image layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] rect A <code>PP_FloatRect</code> for an area of the source to
|
||||
* consider. For a texture layer, rect is in uv coordinates. For an image
|
||||
* layer, rect is in pixels. If the rect is beyond the dimensions of the
|
||||
* texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
* If the layer size does not match the source rect size, bilinear scaling
|
||||
* will be used.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect);
|
||||
/**
|
||||
* Sets the premultiplied alpha for an texture layer.
|
||||
*
|
||||
* param[in] layer A <code>PP_Resource</code> corresponding to a compositor
|
||||
* layer resource.
|
||||
* param[in] premult A <code>PP_Bool</code> with <code>PP_TRUE</code> if
|
||||
* pre-multiplied alpha is used.
|
||||
*
|
||||
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult);
|
||||
};
|
||||
|
||||
struct PPB_CompositorLayer_0_1 { /* dev */
|
||||
PP_Bool (*IsCompositorLayer)(PP_Resource resource);
|
||||
int32_t (*SetColor)(PP_Resource layer,
|
||||
float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const struct PP_Size* size);
|
||||
int32_t (*SetTexture)(PP_Resource layer,
|
||||
PP_Resource context,
|
||||
uint32_t texture,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc);
|
||||
int32_t (*SetImage)(PP_Resource layer,
|
||||
PP_Resource image_data,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc);
|
||||
int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect);
|
||||
int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]);
|
||||
int32_t (*SetOpacity)(PP_Resource layer, float opacity);
|
||||
int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode);
|
||||
int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect);
|
||||
int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult);
|
||||
};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* PPAPI_C_PPB_COMPOSITOR_LAYER_H_ */
|
||||
|
@ -65,10 +65,6 @@ jumbo_source_set("objects") {
|
||||
"audio_encoder.cc",
|
||||
"audio_encoder.h",
|
||||
"completion_callback.h",
|
||||
"compositor.cc",
|
||||
"compositor.h",
|
||||
"compositor_layer.cc",
|
||||
"compositor_layer.h",
|
||||
"core.cc",
|
||||
"core.h",
|
||||
"directory_entry.cc",
|
||||
|
@ -1,79 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/module_impl.h"
|
||||
#include "ppapi/cpp/var.h"
|
||||
|
||||
namespace pp {
|
||||
|
||||
namespace {
|
||||
|
||||
template <> const char* interface_name<PPB_Compositor_0_1>() {
|
||||
return PPB_COMPOSITOR_INTERFACE_0_1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Compositor::Compositor() {
|
||||
}
|
||||
|
||||
Compositor::Compositor(const InstanceHandle& instance) {
|
||||
if (has_interface<PPB_Compositor_0_1>()) {
|
||||
PassRefFromConstructor(get_interface<PPB_Compositor_0_1>()->Create(
|
||||
instance.pp_instance()));
|
||||
}
|
||||
}
|
||||
|
||||
Compositor::Compositor(
|
||||
const Compositor& other) : Resource(other) {
|
||||
}
|
||||
|
||||
Compositor::Compositor(const Resource& resource)
|
||||
: Resource(resource) {
|
||||
PP_DCHECK(IsCompositor(resource));
|
||||
}
|
||||
|
||||
Compositor::Compositor(PassRef, PP_Resource resource)
|
||||
: Resource(PASS_REF, resource) {
|
||||
}
|
||||
|
||||
Compositor::~Compositor() {
|
||||
}
|
||||
|
||||
CompositorLayer Compositor::AddLayer() {
|
||||
PP_Resource layer = 0;
|
||||
if (has_interface<PPB_Compositor_0_1>()) {
|
||||
layer = get_interface<PPB_Compositor_0_1>()->AddLayer(pp_resource());
|
||||
}
|
||||
return CompositorLayer(PASS_REF, layer);
|
||||
}
|
||||
|
||||
int32_t Compositor::CommitLayers(const CompletionCallback& cc) {
|
||||
if (has_interface<PPB_Compositor_0_1>()) {
|
||||
return get_interface<PPB_Compositor_0_1>()->CommitLayers(
|
||||
pp_resource(), cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t Compositor::ResetLayers() {
|
||||
if (has_interface<PPB_Compositor_0_1>()) {
|
||||
return get_interface<PPB_Compositor_0_1>()->ResetLayers(pp_resource());
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
bool Compositor::IsCompositor(const Resource& resource) {
|
||||
if (has_interface<PPB_Compositor_0_1>()) {
|
||||
return PP_ToBool(get_interface<PPB_Compositor_0_1>()->
|
||||
IsCompositor(resource.pp_resource()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace pp
|
@ -1,92 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_CPP_COMPOSITOR_H_
|
||||
#define PPAPI_CPP_COMPOSITOR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
#include "ppapi/cpp/resource.h"
|
||||
|
||||
/// @file
|
||||
/// This file defines the API to create a compositor in the browser.
|
||||
namespace pp {
|
||||
|
||||
/// The <code>Compositor</code> interface is used for setting
|
||||
/// <code>CompositorLayer</code> layers to the Chromium compositor for
|
||||
/// compositing. This allows a plugin to combine different sources of visual
|
||||
/// data efficiently, such as <code>ImageData</code> images and OpenGL textures.
|
||||
/// See also <code>CompositorLayer</code> for more information.
|
||||
class Compositor : public Resource {
|
||||
public:
|
||||
/// Default constructor for creating an is_null()
|
||||
/// <code>Compositor</code> object.
|
||||
Compositor();
|
||||
|
||||
/// A constructor for creating and initializing a compositor.
|
||||
///
|
||||
/// On failure, the object will be is_null().
|
||||
explicit Compositor(const InstanceHandle& instance);
|
||||
|
||||
/// The copy constructor for <code>Compositor</code>.
|
||||
///
|
||||
/// @param[in] other A reference to a <code>Compositor</code>.
|
||||
Compositor(const Compositor& other);
|
||||
|
||||
/// Constructs a <code>Compositor</code> from a <code>Resource</code>.
|
||||
///
|
||||
/// @param[in] resource A <code>PPB_Compositor</code> resource.
|
||||
explicit Compositor(const Resource& resource);
|
||||
|
||||
/// A constructor used when you have received a <code>PP_Resource</code> as a
|
||||
/// return value that has had 1 ref added on behalf of the caller.
|
||||
///
|
||||
/// @param[in] resource A <code>PPB_Compositor</code> resource.
|
||||
Compositor(PassRef, PP_Resource resource);
|
||||
|
||||
/// Destructor.
|
||||
~Compositor();
|
||||
|
||||
/// Creates a new <code>CompositorLayer</code> and adds it to the end of the
|
||||
/// layer stack. A <code>CompositorLayer</code> containing the layer is
|
||||
/// returned. It is uninitialized, <code>SetColor()</code>,
|
||||
/// <code>SetTexture</code> or <code>SetImage</code> should be used to
|
||||
/// initialize it. The layer will appear above other pre-existing layers.
|
||||
/// If <code>ResetLayers</code> is called or the <code>PPB_Compositor</code>
|
||||
/// is released, the returned layer will be invalidated, and any further calls
|
||||
/// on the layer will return <code>PP_ERROR_BADRESOURCE</code>.
|
||||
///
|
||||
/// @return A <code>CompositorLayer</code> containing the compositor layer
|
||||
/// resource.
|
||||
CompositorLayer AddLayer();
|
||||
|
||||
/// Commits layers added by <code>AddLayer()</code> to the chromium
|
||||
/// compositor.
|
||||
///
|
||||
/// @param[in] cc A <code>CompletionCallback</code> to be called when
|
||||
/// layers have been represented on screen.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t CommitLayers(const CompletionCallback& cc);
|
||||
|
||||
/// Resets layers added by <code>AddLayer()</code>
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t ResetLayers();
|
||||
|
||||
/// Checks whether a <code>Resource</code> is a compositor, to test whether
|
||||
/// it is appropriate for use with the <code>Compositor</code> constructor.
|
||||
///
|
||||
/// @param[in] resource A <code>Resource</code> to test.
|
||||
///
|
||||
/// @return True if <code>resource</code> is a compositor.
|
||||
static bool IsCompositor(const Resource& resource);
|
||||
};
|
||||
|
||||
} // namespace pp
|
||||
|
||||
#endif // PPAPI_CPP_COMPOSITOR_H_
|
@ -1,196 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/module_impl.h"
|
||||
#include "ppapi/cpp/var.h"
|
||||
|
||||
namespace pp {
|
||||
|
||||
namespace {
|
||||
|
||||
template <> const char* interface_name<PPB_CompositorLayer_0_1>() {
|
||||
return PPB_COMPOSITORLAYER_INTERFACE_0_1;
|
||||
}
|
||||
|
||||
template <> const char* interface_name<PPB_CompositorLayer_0_2>() {
|
||||
return PPB_COMPOSITORLAYER_INTERFACE_0_2;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CompositorLayer::CompositorLayer() {
|
||||
}
|
||||
|
||||
CompositorLayer::CompositorLayer(
|
||||
const CompositorLayer& other) : Resource(other) {
|
||||
}
|
||||
|
||||
CompositorLayer::CompositorLayer(const Resource& resource)
|
||||
: Resource(resource) {
|
||||
PP_DCHECK(IsCompositorLayer(resource));
|
||||
}
|
||||
|
||||
CompositorLayer::CompositorLayer(PassRef, PP_Resource resource)
|
||||
: Resource(PASS_REF, resource) {
|
||||
}
|
||||
|
||||
CompositorLayer::~CompositorLayer() {
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetColor(float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const Size& size) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetColor(
|
||||
pp_resource(), red, green, blue, alpha, &size.pp_size());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetColor(
|
||||
pp_resource(), red, green, blue, alpha, &size.pp_size());
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetTexture(const Graphics3D& context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const Size& size,
|
||||
const CompletionCallback& cc) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetTexture(
|
||||
pp_resource(), context.pp_resource(), target, texture, &size.pp_size(),
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
if (target != 0x0DE1) // 0x0DE1 GL_TEXTURE_2D
|
||||
return cc.MayForce(PP_ERROR_NOTSUPPORTED);
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetTexture(
|
||||
pp_resource(), context.pp_resource(), texture, &size.pp_size(),
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetImage(const ImageData& image,
|
||||
const CompletionCallback& cc) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetImage(
|
||||
pp_resource(), image.pp_resource(), NULL,
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetImage(
|
||||
pp_resource(), image.pp_resource(), NULL,
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetImage(const ImageData& image,
|
||||
const Size& size,
|
||||
const CompletionCallback& cc) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetImage(
|
||||
pp_resource(), image.pp_resource(), &size.pp_size(),
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetImage(
|
||||
pp_resource(), image.pp_resource(), &size.pp_size(),
|
||||
cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetClipRect(const Rect& rect) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetClipRect(
|
||||
pp_resource(), &rect.pp_rect());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetClipRect(
|
||||
pp_resource(), &rect.pp_rect());
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetTransform(const float matrix[16]) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetTransform(
|
||||
pp_resource(), matrix);
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetTransform(
|
||||
pp_resource(), matrix);
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetOpacity(float opacity) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetOpacity(
|
||||
pp_resource(), opacity);
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetOpacity(
|
||||
pp_resource(), opacity);
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetBlendMode(
|
||||
pp_resource(), mode);
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetBlendMode(
|
||||
pp_resource(), mode);
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetSourceRect(
|
||||
pp_resource(), &rect.pp_float_rect());
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetSourceRect(
|
||||
pp_resource(), &rect.pp_float_rect());
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_2>()->SetPremultipliedAlpha(
|
||||
pp_resource(), PP_FromBool(premult));
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return get_interface<PPB_CompositorLayer_0_1>()->SetPremultipliedAlpha(
|
||||
pp_resource(), PP_FromBool(premult));
|
||||
}
|
||||
return PP_ERROR_NOINTERFACE;
|
||||
}
|
||||
|
||||
bool CompositorLayer::IsCompositorLayer(const Resource& resource) {
|
||||
if (has_interface<PPB_CompositorLayer_0_2>()) {
|
||||
return PP_ToBool(get_interface<PPB_CompositorLayer_0_2>()->
|
||||
IsCompositorLayer(resource.pp_resource()));
|
||||
}
|
||||
if (has_interface<PPB_CompositorLayer_0_1>()) {
|
||||
return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()->
|
||||
IsCompositorLayer(resource.pp_resource()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace pp
|
@ -1,192 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_CPP_COMPOSITOR_LAYER_H_
|
||||
#define PPAPI_CPP_COMPOSITOR_LAYER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/cpp/graphics_3d.h"
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
#include "ppapi/cpp/rect.h"
|
||||
#include "ppapi/cpp/resource.h"
|
||||
#include "ppapi/cpp/size.h"
|
||||
|
||||
namespace pp {
|
||||
|
||||
class CompositorLayer : public Resource {
|
||||
public:
|
||||
/// Default constructor for creating an is_null()
|
||||
/// <code>CompositorLayer</code> object.
|
||||
CompositorLayer();
|
||||
|
||||
/// The copy constructor for <code>CompositorLayer</code>.
|
||||
///
|
||||
/// @param[in] other A reference to a <code>CompositorLayer</code>.
|
||||
CompositorLayer(const CompositorLayer& other);
|
||||
|
||||
/// Constructs a <code>CompositorLayer</code> from a <code>Resource</code>.
|
||||
///
|
||||
/// @param[in] resource A <code>PPB_CompositorLayer</code> resource.
|
||||
explicit CompositorLayer(const Resource& resource);
|
||||
|
||||
/// A constructor used when you have received a <code>PP_Resource</code> as a
|
||||
/// return value that has had 1 ref added for you.
|
||||
///
|
||||
/// @param[in] resource A <code>PPB_CompositorLayer</code> resource.
|
||||
CompositorLayer(PassRef, PP_Resource resource);
|
||||
|
||||
/// Destructor.
|
||||
~CompositorLayer();
|
||||
|
||||
/// Sets the color of a solid color layer. If the layer is uninitialized, it
|
||||
/// will initialize the layer first, and then set its color. If the layer has
|
||||
/// been initialized to another kind of layer, the layer will not be changed,
|
||||
/// and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
///
|
||||
/// param[in] red A <code>float</code> for the red color component. It will be
|
||||
/// clamped to [0, 1]
|
||||
/// param[in] green A <code>float</code> for the green color component.
|
||||
/// It will be clamped to [0, 1].
|
||||
/// param[in] blue A <code>float</code> for the blue color component. It will
|
||||
/// be clamped to [0, 1].
|
||||
/// param[in] alpha A <code>float</code> for the alpha color component.
|
||||
/// It will be clamped to [0, 1].
|
||||
/// param[in] size A <code>Size</code> for the size of the layer before
|
||||
/// transform.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetColor(float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const Size& size);
|
||||
|
||||
/// Sets the texture of a texture layer. If the layer is uninitialized, it
|
||||
/// will initialize the layer first, and then set its texture. The source rect
|
||||
/// will be set to ((0, 0), (1, 1)). If the layer has been initialized to
|
||||
/// another kind of layer, the layer will not be changed, and
|
||||
/// <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
///
|
||||
/// param[in] context A <code>Graphics3D</code> corresponding to a graphics 3d
|
||||
/// resource which owns the GL texture.
|
||||
/// param[in] target GL texture target (GL_TEXTURE_2D, etc).
|
||||
/// param[in] texture A GL texture object id.
|
||||
/// param[in] size A <code>Size</code> for the size of the layer before
|
||||
/// transform.
|
||||
/// param[in] cc A <code>CompletionCallback</code> to be called when
|
||||
/// the texture is released by Chromium compositor.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetTexture(const Graphics3D& context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const Size& size,
|
||||
const CompletionCallback& cc);
|
||||
|
||||
/// Sets the image of an image layer. If the layer is uninitialized, it will
|
||||
/// initiliaze the layer first, and then set the image of it. If the layer has
|
||||
/// been initialized to another kind of layer, the layer will not be changed,
|
||||
/// and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
///
|
||||
/// param[in] image_data A <code>PP_Resource</code> corresponding to an image
|
||||
/// data resource.
|
||||
/// param[in] cc A <code>CompletionCallback</code> to be called when
|
||||
/// the image data is released by Chromium compositor.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetImage(const ImageData& image,
|
||||
const CompletionCallback& callback);
|
||||
|
||||
/// Sets the image of an image layer. If the layer is uninitialized, it will
|
||||
/// initialize the layer first, and then set its image. The layer size will
|
||||
/// be set to the image's size. The source rect will be set to the full image.
|
||||
/// If the layer has been initialized to another kind of layer, the layer will
|
||||
/// not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
///
|
||||
/// param[in] image_data A <code>ImageData</code> corresponding to an image
|
||||
/// data resource.
|
||||
/// param[in] size A <code>Size</code> for the size of the layer before
|
||||
/// transform.
|
||||
/// param[in] cc A <code>CompletionCallback</code> to be called when the image
|
||||
/// data is released by Chromium compositor.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetImage(const ImageData& image,
|
||||
const Size& size,
|
||||
const CompletionCallback& callback);
|
||||
|
||||
/// Sets a clip rectangle for a compositor layer. The Chromium compositor
|
||||
/// applies a transform matrix on the layer first, and then clips the layer
|
||||
/// with the rectangle.
|
||||
///
|
||||
/// param[in] rect The clip rectangle. The origin is top-left corner of
|
||||
/// the plugin.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetClipRect(const Rect& rect);
|
||||
|
||||
/// Sets a transform matrix which is used to composite the layer.
|
||||
///
|
||||
/// param[in] matrix A float array with 16 elements. The matrix is coloum
|
||||
/// major. The default transform matrix is an identity matrix.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetTransform(const float matrix[16]);
|
||||
|
||||
/// Sets the opacity value which will be applied to the layer. The effective
|
||||
/// value of each pixel is computed as:
|
||||
///
|
||||
/// if (premult_alpha)
|
||||
/// pixel.rgb = pixel.rgb * opacity;
|
||||
/// pixel.a = pixel.a * opactiy;
|
||||
///
|
||||
/// param[in] opacity A <code>float</code> for the opacity value.
|
||||
/// The default value is 1.0f.
|
||||
///
|
||||
///@return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetOpacity(float opacity);
|
||||
|
||||
/// Sets the blend mode which is used to composite the layer.
|
||||
///
|
||||
/// param[in] mode A <code>PP_BlendMode</code>. The default value is
|
||||
/// <code>PP_BLENDMODE_SRC_OVER</code>.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetBlendMode(PP_BlendMode mode);
|
||||
|
||||
/// Sets a source rectangle for a texture layer or an image layer.
|
||||
///
|
||||
/// param[in] rect A <code>FloatRect</code> for an area of the source to
|
||||
/// consider. For a texture layer, rect is in uv coordinates. For an image
|
||||
/// layer, rect is in pixels. If the rect is beyond the dimensions of the
|
||||
/// texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned.
|
||||
/// If the layer size does not match the source rect size, bilinear scaling
|
||||
/// will be used.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetSourceRect(const FloatRect& rect);
|
||||
|
||||
/// Sets the premultiplied alpha for an texture layer.
|
||||
///
|
||||
/// param[in] premult A <code>bool</code> with <code>true</code> if
|
||||
/// pre-multiplied alpha is used.
|
||||
///
|
||||
/// @return An int32_t containing a result code from <code>pp_errors.h</code>.
|
||||
int32_t SetPremultipliedAlpha(bool premult);
|
||||
|
||||
/// Checks whether a <code>Resource</code> is a compositor layer, to test
|
||||
/// whether it is appropriate for use with the <code>CompositorLayer</code>
|
||||
/// constructor.
|
||||
///
|
||||
/// @param[in] resource A <code>Resource</code> to test.
|
||||
///
|
||||
/// @return True if <code>resource</code> is a compositor layer.
|
||||
static bool IsCompositorLayer(const Resource& resource);
|
||||
};
|
||||
|
||||
} // namespace pp
|
||||
|
||||
#endif // PPAPI_CPP_COMPOSITOR_LAYER_H_
|
@ -10,7 +10,6 @@
|
||||
#include "ppapi/c/ppb_instance.h"
|
||||
#include "ppapi/c/ppb_messaging.h"
|
||||
#include "ppapi/c/ppp_message_handler.h"
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
#include "ppapi/cpp/graphics_2d.h"
|
||||
#include "ppapi/cpp/graphics_3d.h"
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
@ -126,13 +125,6 @@ bool Instance::BindGraphics(const Graphics3D& graphics) {
|
||||
pp_instance(), graphics.pp_resource()));
|
||||
}
|
||||
|
||||
bool Instance::BindGraphics(const Compositor& compositor) {
|
||||
if (!has_interface<PPB_Instance_1_0>())
|
||||
return false;
|
||||
return PP_ToBool(get_interface<PPB_Instance_1_0>()->BindGraphics(
|
||||
pp_instance(), compositor.pp_resource()));
|
||||
}
|
||||
|
||||
bool Instance::IsFullFrame() {
|
||||
if (!has_interface<PPB_Instance_1_0>())
|
||||
return false;
|
||||
|
@ -26,7 +26,6 @@
|
||||
/// The C++ interface to the Pepper API.
|
||||
namespace pp {
|
||||
|
||||
class Compositor;
|
||||
class Graphics2D;
|
||||
class Graphics3D;
|
||||
class InputEvent;
|
||||
@ -317,17 +316,6 @@ class Instance {
|
||||
/// instance, so the caller can release its reference if it chooses.
|
||||
bool BindGraphics(const Graphics3D& graphics);
|
||||
|
||||
/// Binds the given Compositor as the current display surface.
|
||||
/// Refer to <code>BindGraphics(const Graphics2D& graphics)</code> for
|
||||
/// further information.
|
||||
///
|
||||
/// @param[in] compositor A <code>Compositor</code> to bind.
|
||||
///
|
||||
/// @return true if bind was successful or false if the device was not the
|
||||
/// correct type. On success, a reference to the device will be held by the
|
||||
/// instance, so the caller can release its reference if it chooses.
|
||||
bool BindGraphics(const Compositor& compositor);
|
||||
|
||||
/// IsFullFrame() determines if the instance is full-frame (repr).
|
||||
/// Such an instance represents the entire document in a frame rather than an
|
||||
/// embedded resource. This can happen if the user does a top-level
|
||||
|
@ -9,7 +9,6 @@ group("examples") {
|
||||
"//ppapi/examples/audio",
|
||||
"//ppapi/examples/audio_encode",
|
||||
"//ppapi/examples/audio_input",
|
||||
"//ppapi/examples/compositor",
|
||||
"//ppapi/examples/crxfs",
|
||||
"//ppapi/examples/enumerate_devices",
|
||||
"//ppapi/examples/file_chooser",
|
||||
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//ppapi/examples/ppapi_example.gni")
|
||||
|
||||
ppapi_example("compositor") {
|
||||
output_name = "ppapi_example_compositor"
|
||||
sources = [
|
||||
"compositor.cc",
|
||||
"spinning_cube.cc",
|
||||
"spinning_cube.h",
|
||||
]
|
||||
deps = [
|
||||
"//ppapi/cpp",
|
||||
"//ppapi/lib/gl/gles2",
|
||||
]
|
||||
}
|
@ -1,453 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Needed on Windows to get |M_PI| from math.h.
|
||||
#ifdef _WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/pp_input_event.h"
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
#include "ppapi/cpp/graphics_3d.h"
|
||||
#include "ppapi/cpp/graphics_3d_client.h"
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
#include "ppapi/cpp/input_event.h"
|
||||
#include "ppapi/cpp/instance.h"
|
||||
#include "ppapi/cpp/module.h"
|
||||
#include "ppapi/cpp/rect.h"
|
||||
#include "ppapi/cpp/var_dictionary.h"
|
||||
#include "ppapi/examples/compositor/spinning_cube.h"
|
||||
#include "ppapi/lib/gl/gles2/gl2ext_ppapi.h"
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2.h"
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2ext.h"
|
||||
#include "ppapi/utility/completion_callback_factory.h"
|
||||
|
||||
// Use assert as a makeshift CHECK, even in non-debug mode.
|
||||
// Since <assert.h> redefines assert on every inclusion (it doesn't use
|
||||
// include-guards), make sure this is the last file #include'd in this file.
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// When compiling natively on Windows, PostMessage can be #define-d to
|
||||
// something else.
|
||||
#ifdef PostMessage
|
||||
#undef PostMessage
|
||||
#endif
|
||||
|
||||
// Assert |context_| isn't holding any GL Errors. Done as a macro instead of a
|
||||
// function to preserve line number information in the failure message.
|
||||
#define AssertNoGLError() \
|
||||
PP_DCHECK(!glGetError());
|
||||
|
||||
namespace {
|
||||
|
||||
const int32_t kTextureWidth = 800;
|
||||
const int32_t kTextureHeight = 800;
|
||||
const int32_t kImageWidth = 256;
|
||||
const int32_t kImageHeight = 256;
|
||||
|
||||
class DemoInstance : public pp::Instance, public pp::Graphics3DClient {
|
||||
public:
|
||||
DemoInstance(PP_Instance instance);
|
||||
virtual ~DemoInstance();
|
||||
|
||||
// pp::Instance implementation (see PPP_Instance).
|
||||
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
|
||||
virtual void DidChangeView(const pp::Rect& position,
|
||||
const pp::Rect& clip);
|
||||
virtual bool HandleInputEvent(const pp::InputEvent& event);
|
||||
|
||||
// pp::Graphics3DClient implementation.
|
||||
virtual void Graphics3DContextLost();
|
||||
|
||||
private:
|
||||
// GL-related functions.
|
||||
void InitGL(int32_t result);
|
||||
GLuint PrepareFramebuffer();
|
||||
pp::ImageData PrepareImage();
|
||||
void PrepareLayers(int32_t frame);
|
||||
void Paint(int32_t result, int32_t frame);
|
||||
void OnTextureReleased(int32_t result, GLuint texture);
|
||||
void OnImageReleased(int32_t result, const pp::ImageData& image);
|
||||
|
||||
pp::CompletionCallbackFactory<DemoInstance> callback_factory_;
|
||||
|
||||
// Owned data.
|
||||
pp::Graphics3D* context_;
|
||||
|
||||
GLuint fbo_;
|
||||
GLuint rbo_;
|
||||
|
||||
std::vector<GLuint> textures_;
|
||||
std::vector<pp::ImageData> images_;
|
||||
|
||||
pp::Compositor compositor_;
|
||||
pp::CompositorLayer color_layer_;
|
||||
pp::CompositorLayer stable_texture_layer_;
|
||||
pp::CompositorLayer texture_layer_;
|
||||
pp::CompositorLayer image_layer_;
|
||||
|
||||
bool rebuild_layers_;
|
||||
int32_t total_resource_;
|
||||
|
||||
SpinningCube* cube_;
|
||||
};
|
||||
|
||||
DemoInstance::DemoInstance(PP_Instance instance)
|
||||
: pp::Instance(instance),
|
||||
pp::Graphics3DClient(this),
|
||||
callback_factory_(this),
|
||||
context_(NULL),
|
||||
fbo_(0),
|
||||
rbo_(0),
|
||||
rebuild_layers_(true),
|
||||
total_resource_(0),
|
||||
cube_(new SpinningCube()) {
|
||||
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
|
||||
}
|
||||
|
||||
DemoInstance::~DemoInstance() {
|
||||
delete cube_;
|
||||
assert(glTerminatePPAPI());
|
||||
delete context_;
|
||||
}
|
||||
|
||||
bool DemoInstance::Init(uint32_t /*argc*/,
|
||||
const char* /*argn*/[],
|
||||
const char* /*argv*/[]) {
|
||||
return !!glInitializePPAPI(pp::Module::Get()->get_browser_interface());
|
||||
}
|
||||
|
||||
void DemoInstance::DidChangeView(
|
||||
const pp::Rect& position, const pp::Rect& /*clip*/) {
|
||||
if (position.width() == 0 || position.height() == 0)
|
||||
return;
|
||||
// Initialize graphics.
|
||||
InitGL(0);
|
||||
}
|
||||
|
||||
bool DemoInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
switch (event.GetType()) {
|
||||
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
|
||||
rebuild_layers_ = true;
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DemoInstance::Graphics3DContextLost() {
|
||||
fbo_ = 0;
|
||||
rbo_ = 0;
|
||||
rebuild_layers_ = true;
|
||||
total_resource_ -= static_cast<int32_t>(textures_.size());
|
||||
textures_.clear();
|
||||
delete context_;
|
||||
context_ = NULL;
|
||||
cube_->OnGLContextLost();
|
||||
pp::CompletionCallback cb = callback_factory_.NewCallback(
|
||||
&DemoInstance::InitGL);
|
||||
pp::Module::Get()->core()->CallOnMainThread(0, cb, 0);
|
||||
}
|
||||
|
||||
void DemoInstance::InitGL(int32_t /*result*/) {
|
||||
if (context_)
|
||||
return;
|
||||
int32_t context_attributes[] = {
|
||||
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
|
||||
PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
|
||||
PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
|
||||
PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
|
||||
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
|
||||
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
|
||||
PP_GRAPHICS3DATTRIB_SAMPLES, 0,
|
||||
PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
|
||||
PP_GRAPHICS3DATTRIB_WIDTH, 32,
|
||||
PP_GRAPHICS3DATTRIB_HEIGHT, 32,
|
||||
PP_GRAPHICS3DATTRIB_NONE,
|
||||
};
|
||||
context_ = new pp::Graphics3D(this, context_attributes);
|
||||
assert(!context_->is_null());
|
||||
assert(BindGraphics(compositor_));
|
||||
|
||||
glSetCurrentContextPPAPI(context_->pp_resource());
|
||||
|
||||
cube_->Init(kTextureWidth, kTextureHeight);
|
||||
|
||||
Paint(PP_OK, 0);
|
||||
}
|
||||
|
||||
GLuint DemoInstance::PrepareFramebuffer() {
|
||||
GLuint texture = 0;
|
||||
if (textures_.empty()) {
|
||||
total_resource_++;
|
||||
// Create a texture object
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kTextureWidth, kTextureHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
} else {
|
||||
texture = textures_.back();
|
||||
textures_.pop_back();
|
||||
}
|
||||
|
||||
if (!rbo_) {
|
||||
// create a renderbuffer object to store depth info
|
||||
glGenRenderbuffers(1, &rbo_);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rbo_);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
|
||||
kTextureWidth, kTextureHeight);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
if (!fbo_) {
|
||||
// create a framebuffer object
|
||||
glGenFramebuffers(1, &fbo_);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
||||
|
||||
// attach the texture to FBO color attachment point
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
texture,
|
||||
0);
|
||||
|
||||
// attach the renderbuffer to depth attachment point
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER,
|
||||
GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER,
|
||||
rbo_);
|
||||
|
||||
// check FBO status
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
assert(status == GL_FRAMEBUFFER_COMPLETE);
|
||||
|
||||
AssertNoGLError();
|
||||
return texture;
|
||||
}
|
||||
|
||||
pp::ImageData DemoInstance::PrepareImage() {
|
||||
if (images_.empty()) {
|
||||
total_resource_++;
|
||||
return pp::ImageData(this,
|
||||
PP_IMAGEDATAFORMAT_RGBA_PREMUL,
|
||||
pp::Size(kImageWidth, kImageHeight),
|
||||
false);
|
||||
}
|
||||
pp::ImageData image = images_.back();
|
||||
images_.pop_back();
|
||||
return image;
|
||||
}
|
||||
|
||||
void DemoInstance::Paint(int32_t result, int32_t frame) {
|
||||
assert(result == PP_OK);
|
||||
if (result != PP_OK || !context_)
|
||||
return;
|
||||
|
||||
if (rebuild_layers_) {
|
||||
compositor_ = pp::Compositor(this);
|
||||
assert(BindGraphics(compositor_));
|
||||
color_layer_ = pp::CompositorLayer();
|
||||
stable_texture_layer_ = pp::CompositorLayer();
|
||||
texture_layer_ = pp::CompositorLayer();
|
||||
image_layer_ = pp::CompositorLayer();
|
||||
frame = 0;
|
||||
rebuild_layers_ = false;
|
||||
}
|
||||
|
||||
PrepareLayers(frame);
|
||||
|
||||
int32_t rv = compositor_.CommitLayers(
|
||||
callback_factory_.NewCallback(&DemoInstance::Paint, ++frame));
|
||||
assert(rv == PP_OK_COMPLETIONPENDING);
|
||||
|
||||
pp::VarDictionary dict;
|
||||
dict.Set("total_resource", total_resource_);
|
||||
size_t free_resource = textures_.size() + images_.size();
|
||||
dict.Set("free_resource", static_cast<int32_t>(free_resource));
|
||||
PostMessage(dict);
|
||||
}
|
||||
|
||||
void DemoInstance::PrepareLayers(int32_t frame) {
|
||||
int32_t rv;
|
||||
float factor_sin = sin(static_cast<float>(M_PI) / 180 * frame);
|
||||
float factor_cos = cos(static_cast<float>(M_PI) / 180 * frame);
|
||||
{
|
||||
// Set the background color layer.
|
||||
if (color_layer_.is_null()) {
|
||||
color_layer_ = compositor_.AddLayer();
|
||||
assert(!color_layer_.is_null());
|
||||
static const float transform[16] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
rv = color_layer_.SetTransform(transform);
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
rv = color_layer_.SetColor(fabs(factor_sin),
|
||||
fabs(factor_cos),
|
||||
fabs(factor_sin * factor_cos),
|
||||
1.0f,
|
||||
pp::Size(800, 600));
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
|
||||
{
|
||||
// Set the image layer
|
||||
if (image_layer_.is_null()) {
|
||||
image_layer_ = compositor_.AddLayer();
|
||||
assert(!image_layer_.is_null());
|
||||
}
|
||||
float x = static_cast<float>(frame % 800);
|
||||
float y = 200 - 200 * factor_sin;
|
||||
const float transform[16] = {
|
||||
fabsf(factor_sin) + 0.2f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, fabsf(factor_sin) + 0.2f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
x, y, 0.0f, 1.0f,
|
||||
};
|
||||
rv = image_layer_.SetTransform(transform);
|
||||
assert(rv == PP_OK);
|
||||
|
||||
pp::ImageData image = PrepareImage();
|
||||
uint8_t *p = static_cast<uint8_t*>(image.data());
|
||||
for (int x = 0; x < kImageWidth; ++x) {
|
||||
for (int y = 0; y < kImageHeight; ++y) {
|
||||
*(p++) = static_cast<uint8_t>(frame);
|
||||
*(p++) = static_cast<uint8_t>(frame * x);
|
||||
*(p++) = static_cast<uint8_t>(frame * y);
|
||||
*(p++) = 255;
|
||||
}
|
||||
}
|
||||
rv = image_layer_.SetImage(image, pp::Size(kImageWidth, kImageHeight),
|
||||
callback_factory_.NewCallback(&DemoInstance::OnImageReleased, image));
|
||||
assert(rv == PP_OK_COMPLETIONPENDING);
|
||||
}
|
||||
|
||||
{
|
||||
// Set the stable texture layer
|
||||
if (stable_texture_layer_.is_null()) {
|
||||
stable_texture_layer_ = compositor_.AddLayer();
|
||||
assert(!stable_texture_layer_.is_null());
|
||||
GLuint texture = PrepareFramebuffer();
|
||||
cube_->UpdateForTimeDelta(0.02f);
|
||||
cube_->Draw();
|
||||
rv = stable_texture_layer_.SetTexture(
|
||||
*context_,
|
||||
GL_TEXTURE_2D,
|
||||
texture,
|
||||
pp::Size(600, 600),
|
||||
callback_factory_.NewCallback(&DemoInstance::OnTextureReleased,
|
||||
texture));
|
||||
assert(rv == PP_OK_COMPLETIONPENDING);
|
||||
rv = stable_texture_layer_.SetPremultipliedAlpha(PP_FALSE);
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
|
||||
int32_t delta = static_cast<int32_t>(200 * fabsf(factor_sin));
|
||||
if (delta != 0) {
|
||||
int32_t x_y = 25 + delta;
|
||||
int32_t w_h = 650 - delta - delta;
|
||||
rv = stable_texture_layer_.SetClipRect(pp::Rect(x_y, x_y, w_h, w_h));
|
||||
} else {
|
||||
rv = stable_texture_layer_.SetClipRect(pp::Rect());
|
||||
}
|
||||
assert(rv == PP_OK);
|
||||
|
||||
const float transform[16] = {
|
||||
factor_cos, -factor_sin, 0.0f, 0.0f,
|
||||
factor_sin, factor_cos, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
50.0f, 50.0f, 0.0f, 1.0f,
|
||||
};
|
||||
rv = stable_texture_layer_.SetTransform(transform);
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
|
||||
{
|
||||
// Set the dynamic texture layer.
|
||||
if (texture_layer_.is_null()) {
|
||||
texture_layer_ = compositor_.AddLayer();
|
||||
assert(!texture_layer_.is_null());
|
||||
static const float transform[16] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
200.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
rv = texture_layer_.SetTransform(transform);
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
|
||||
GLuint texture = PrepareFramebuffer();
|
||||
cube_->UpdateForTimeDelta(0.02f);
|
||||
cube_->Draw();
|
||||
rv = texture_layer_.SetTexture(
|
||||
*context_,
|
||||
GL_TEXTURE_2D,
|
||||
texture,
|
||||
pp::Size(400, 400),
|
||||
callback_factory_.NewCallback(&DemoInstance::OnTextureReleased,
|
||||
texture));
|
||||
assert(rv == PP_OK_COMPLETIONPENDING);
|
||||
rv = texture_layer_.SetPremultipliedAlpha(PP_FALSE);
|
||||
assert(rv == PP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void DemoInstance::OnTextureReleased(int32_t result, GLuint texture) {
|
||||
if (result == PP_OK) {
|
||||
textures_.push_back(texture);
|
||||
} else {
|
||||
glDeleteTextures(1, &texture);
|
||||
total_resource_--;
|
||||
}
|
||||
}
|
||||
|
||||
void DemoInstance::OnImageReleased(int32_t result, const pp::ImageData& image) {
|
||||
if (result == PP_OK) {
|
||||
images_.push_back(image);
|
||||
} else {
|
||||
total_resource_--;
|
||||
}
|
||||
}
|
||||
|
||||
// This object is the global object representing this plugin library as long
|
||||
// as it is loaded.
|
||||
class DemoModule : public pp::Module {
|
||||
public:
|
||||
DemoModule() : Module() {}
|
||||
virtual ~DemoModule() {}
|
||||
|
||||
virtual pp::Instance* CreateInstance(PP_Instance instance) {
|
||||
return new DemoInstance(instance);
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace pp {
|
||||
// Factory function for your specialization of the Module object.
|
||||
Module* CreateModule() {
|
||||
return new DemoModule();
|
||||
}
|
||||
} // namespace pp
|
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<head>
|
||||
<title>GLES2 Spinning Cube Example</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<embed id="plugin" type="application/x-ppapi-example-compositor"
|
||||
width="800" height="600"/> <br/>
|
||||
Total resource: <input id="total" > <br/>
|
||||
Free resource: <input id="free" > <br/>
|
||||
<script type="text/javascript">
|
||||
var plugin = document.getElementById('plugin');
|
||||
var total = document.getElementById('total');
|
||||
var free = document.getElementById('free');
|
||||
plugin.addEventListener('message', function(message) {
|
||||
total.value = message.data.total_resource;
|
||||
free.value = message.data.free_resource;
|
||||
}, false);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,459 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This example program is based on Simple_VertexShader.c from:
|
||||
|
||||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
#include "ppapi/examples/compositor/spinning_cube.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const float kPi = 3.14159265359f;
|
||||
|
||||
int GenerateCube(GLuint *vbo_vertices,
|
||||
GLuint *vbo_indices) {
|
||||
const int num_indices = 36;
|
||||
|
||||
const GLfloat cube_vertices[] = {
|
||||
-0.5f, -0.5f, -0.5f,
|
||||
0.5f, -0.5f, -0.5f,
|
||||
0.5f, -0.5f, 0.5f,
|
||||
-0.5f, -0.5f, 0.5f,
|
||||
-0.5f, 0.5f, -0.5f,
|
||||
0.5f, 0.5f, -0.5f,
|
||||
0.5f, 0.5f, 0.5f,
|
||||
-0.5f, 0.5f, 0.5f,
|
||||
};
|
||||
|
||||
const GLushort cube_indices[] = {
|
||||
0, 2, 1,
|
||||
0, 3, 2,
|
||||
4, 5, 6,
|
||||
4, 6, 7,
|
||||
3, 6, 2,
|
||||
3, 7, 6,
|
||||
0, 1, 5,
|
||||
0, 5, 4,
|
||||
0, 7, 3,
|
||||
0, 4, 7,
|
||||
1, 2, 6,
|
||||
1, 6, 5,
|
||||
};
|
||||
|
||||
if (vbo_vertices) {
|
||||
glGenBuffers(1, vbo_vertices);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, *vbo_vertices);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
sizeof(cube_vertices),
|
||||
cube_vertices,
|
||||
GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
if (vbo_indices) {
|
||||
glGenBuffers(1, vbo_indices);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *vbo_indices);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
sizeof(cube_indices),
|
||||
cube_indices,
|
||||
GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
return num_indices;
|
||||
}
|
||||
|
||||
GLuint LoadShader(GLenum type,
|
||||
const char* shader_source) {
|
||||
GLuint shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &shader_source, NULL);
|
||||
glCompileShader(shader);
|
||||
|
||||
GLint compiled = 0;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
|
||||
|
||||
if (!compiled) {
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
GLuint LoadProgram(const char* vertext_shader_source,
|
||||
const char* fragment_shader_source) {
|
||||
GLuint vertex_shader = LoadShader(GL_VERTEX_SHADER,
|
||||
vertext_shader_source);
|
||||
if (!vertex_shader)
|
||||
return 0;
|
||||
|
||||
GLuint fragment_shader = LoadShader(GL_FRAGMENT_SHADER,
|
||||
fragment_shader_source);
|
||||
if (!fragment_shader) {
|
||||
glDeleteShader(vertex_shader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLuint program_object = glCreateProgram();
|
||||
glAttachShader(program_object, vertex_shader);
|
||||
glAttachShader(program_object, fragment_shader);
|
||||
|
||||
glLinkProgram(program_object);
|
||||
|
||||
glDeleteShader(vertex_shader);
|
||||
glDeleteShader(fragment_shader);
|
||||
|
||||
GLint linked = 0;
|
||||
glGetProgramiv(program_object, GL_LINK_STATUS, &linked);
|
||||
|
||||
if (!linked) {
|
||||
glDeleteProgram(program_object);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return program_object;
|
||||
}
|
||||
|
||||
class ESMatrix {
|
||||
public:
|
||||
GLfloat m[4][4];
|
||||
|
||||
ESMatrix() {
|
||||
LoadZero();
|
||||
}
|
||||
|
||||
void LoadZero() {
|
||||
memset(this, 0x0, sizeof(ESMatrix));
|
||||
}
|
||||
|
||||
void LoadIdentity() {
|
||||
LoadZero();
|
||||
m[0][0] = 1.0f;
|
||||
m[1][1] = 1.0f;
|
||||
m[2][2] = 1.0f;
|
||||
m[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
void Multiply(ESMatrix* a, ESMatrix* b) {
|
||||
ESMatrix result;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
result.m[i][0] = (a->m[i][0] * b->m[0][0]) +
|
||||
(a->m[i][1] * b->m[1][0]) +
|
||||
(a->m[i][2] * b->m[2][0]) +
|
||||
(a->m[i][3] * b->m[3][0]);
|
||||
|
||||
result.m[i][1] = (a->m[i][0] * b->m[0][1]) +
|
||||
(a->m[i][1] * b->m[1][1]) +
|
||||
(a->m[i][2] * b->m[2][1]) +
|
||||
(a->m[i][3] * b->m[3][1]);
|
||||
|
||||
result.m[i][2] = (a->m[i][0] * b->m[0][2]) +
|
||||
(a->m[i][1] * b->m[1][2]) +
|
||||
(a->m[i][2] * b->m[2][2]) +
|
||||
(a->m[i][3] * b->m[3][2]);
|
||||
|
||||
result.m[i][3] = (a->m[i][0] * b->m[0][3]) +
|
||||
(a->m[i][1] * b->m[1][3]) +
|
||||
(a->m[i][2] * b->m[2][3]) +
|
||||
(a->m[i][3] * b->m[3][3]);
|
||||
}
|
||||
*this = result;
|
||||
}
|
||||
|
||||
void Frustum(float left,
|
||||
float right,
|
||||
float bottom,
|
||||
float top,
|
||||
float near_z,
|
||||
float far_z) {
|
||||
float delta_x = right - left;
|
||||
float delta_y = top - bottom;
|
||||
float delta_z = far_z - near_z;
|
||||
|
||||
if ((near_z <= 0.0f) ||
|
||||
(far_z <= 0.0f) ||
|
||||
(delta_z <= 0.0f) ||
|
||||
(delta_y <= 0.0f) ||
|
||||
(delta_y <= 0.0f))
|
||||
return;
|
||||
|
||||
ESMatrix frust;
|
||||
frust.m[0][0] = 2.0f * near_z / delta_x;
|
||||
frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f;
|
||||
|
||||
frust.m[1][1] = 2.0f * near_z / delta_y;
|
||||
frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f;
|
||||
|
||||
frust.m[2][0] = (right + left) / delta_x;
|
||||
frust.m[2][1] = (top + bottom) / delta_y;
|
||||
frust.m[2][2] = -(near_z + far_z) / delta_z;
|
||||
frust.m[2][3] = -1.0f;
|
||||
|
||||
frust.m[3][2] = -2.0f * near_z * far_z / delta_z;
|
||||
frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f;
|
||||
|
||||
Multiply(&frust, this);
|
||||
}
|
||||
|
||||
void Perspective(float fov_y, float aspect, float near_z, float far_z) {
|
||||
GLfloat frustum_h = tanf(fov_y / 360.0f * kPi) * near_z;
|
||||
GLfloat frustum_w = frustum_h * aspect;
|
||||
Frustum(-frustum_w, frustum_w, -frustum_h, frustum_h, near_z, far_z);
|
||||
}
|
||||
|
||||
void Translate(GLfloat tx, GLfloat ty, GLfloat tz) {
|
||||
m[3][0] += m[0][0] * tx + m[1][0] * ty + m[2][0] * tz;
|
||||
m[3][1] += m[0][1] * tx + m[1][1] * ty + m[2][1] * tz;
|
||||
m[3][2] += m[0][2] * tx + m[1][2] * ty + m[2][2] * tz;
|
||||
m[3][3] += m[0][3] * tx + m[1][3] * ty + m[2][3] * tz;
|
||||
}
|
||||
|
||||
void Rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
|
||||
GLfloat mag = sqrtf(x * x + y * y + z * z);
|
||||
|
||||
GLfloat sin_angle = sinf(angle * kPi / 180.0f);
|
||||
GLfloat cos_angle = cosf(angle * kPi / 180.0f);
|
||||
if (mag > 0.0f) {
|
||||
GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs;
|
||||
GLfloat one_minus_cos;
|
||||
ESMatrix rotation;
|
||||
|
||||
x /= mag;
|
||||
y /= mag;
|
||||
z /= mag;
|
||||
|
||||
xx = x * x;
|
||||
yy = y * y;
|
||||
zz = z * z;
|
||||
xy = x * y;
|
||||
yz = y * z;
|
||||
zx = z * x;
|
||||
xs = x * sin_angle;
|
||||
ys = y * sin_angle;
|
||||
zs = z * sin_angle;
|
||||
one_minus_cos = 1.0f - cos_angle;
|
||||
|
||||
rotation.m[0][0] = (one_minus_cos * xx) + cos_angle;
|
||||
rotation.m[0][1] = (one_minus_cos * xy) - zs;
|
||||
rotation.m[0][2] = (one_minus_cos * zx) + ys;
|
||||
rotation.m[0][3] = 0.0F;
|
||||
|
||||
rotation.m[1][0] = (one_minus_cos * xy) + zs;
|
||||
rotation.m[1][1] = (one_minus_cos * yy) + cos_angle;
|
||||
rotation.m[1][2] = (one_minus_cos * yz) - xs;
|
||||
rotation.m[1][3] = 0.0F;
|
||||
|
||||
rotation.m[2][0] = (one_minus_cos * zx) - ys;
|
||||
rotation.m[2][1] = (one_minus_cos * yz) + xs;
|
||||
rotation.m[2][2] = (one_minus_cos * zz) + cos_angle;
|
||||
rotation.m[2][3] = 0.0F;
|
||||
|
||||
rotation.m[3][0] = 0.0F;
|
||||
rotation.m[3][1] = 0.0F;
|
||||
rotation.m[3][2] = 0.0F;
|
||||
rotation.m[3][3] = 1.0F;
|
||||
|
||||
Multiply(&rotation, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
float RotationForTimeDelta(float delta_time) {
|
||||
return delta_time * 40.0f;
|
||||
}
|
||||
|
||||
float RotationForDragDistance(float drag_distance) {
|
||||
return drag_distance / 5; // Arbitrary damping.
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class SpinningCube::GLState {
|
||||
public:
|
||||
GLState();
|
||||
|
||||
void OnGLContextLost();
|
||||
|
||||
GLfloat angle_; // Survives losing the GL context.
|
||||
|
||||
GLuint program_object_;
|
||||
GLint position_location_;
|
||||
GLint mvp_location_;
|
||||
GLuint vbo_vertices_;
|
||||
GLuint vbo_indices_;
|
||||
int num_indices_;
|
||||
ESMatrix mvp_matrix_;
|
||||
};
|
||||
|
||||
SpinningCube::GLState::GLState()
|
||||
: angle_(0) {
|
||||
OnGLContextLost();
|
||||
}
|
||||
|
||||
void SpinningCube::GLState::OnGLContextLost() {
|
||||
program_object_ = 0;
|
||||
position_location_ = 0;
|
||||
mvp_location_ = 0;
|
||||
vbo_vertices_ = 0;
|
||||
vbo_indices_ = 0;
|
||||
num_indices_ = 0;
|
||||
}
|
||||
|
||||
SpinningCube::SpinningCube()
|
||||
: initialized_(false),
|
||||
width_(0),
|
||||
height_(0),
|
||||
state_(new GLState()),
|
||||
fling_multiplier_(1.0f),
|
||||
direction_(1) {
|
||||
state_->angle_ = 45.0f;
|
||||
}
|
||||
|
||||
SpinningCube::~SpinningCube() {
|
||||
if (!initialized_)
|
||||
return;
|
||||
if (state_->vbo_vertices_)
|
||||
glDeleteBuffers(1, &state_->vbo_vertices_);
|
||||
if (state_->vbo_indices_)
|
||||
glDeleteBuffers(1, &state_->vbo_indices_);
|
||||
if (state_->program_object_)
|
||||
glDeleteProgram(state_->program_object_);
|
||||
|
||||
delete state_;
|
||||
}
|
||||
|
||||
void SpinningCube::Init(uint32_t width, uint32_t height) {
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
|
||||
if (!initialized_) {
|
||||
initialized_ = true;
|
||||
const char vertext_shader_source[] =
|
||||
"uniform mat4 u_mvpMatrix; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"varying vec4 v_color; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = u_mvpMatrix * a_position; \n"
|
||||
" v_color = vec4(a_position.x + 0.5, \n"
|
||||
" a_position.y + 0.5, \n"
|
||||
" a_position.z + 0.5, \n"
|
||||
" 0.8); \n"
|
||||
"} \n";
|
||||
|
||||
const char fragment_shader_source[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec4 v_color; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = v_color; \n"
|
||||
"} \n";
|
||||
|
||||
state_->program_object_ = LoadProgram(
|
||||
vertext_shader_source, fragment_shader_source);
|
||||
state_->position_location_ = glGetAttribLocation(
|
||||
state_->program_object_, "a_position");
|
||||
state_->mvp_location_ = glGetUniformLocation(
|
||||
state_->program_object_, "u_mvpMatrix");
|
||||
state_->num_indices_ = GenerateCube(&state_->vbo_vertices_,
|
||||
&state_->vbo_indices_);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
void SpinningCube::OnGLContextLost() {
|
||||
// TODO(yzshen): Is it correct that in this case we don't need to do cleanup
|
||||
// for program and buffers?
|
||||
initialized_ = false;
|
||||
height_ = 0;
|
||||
width_ = 0;
|
||||
state_->OnGLContextLost();
|
||||
}
|
||||
|
||||
void SpinningCube::SetFlingMultiplier(float drag_distance,
|
||||
float drag_time) {
|
||||
fling_multiplier_ = RotationForDragDistance(drag_distance) /
|
||||
RotationForTimeDelta(drag_time);
|
||||
|
||||
}
|
||||
|
||||
void SpinningCube::UpdateForTimeDelta(float delta_time) {
|
||||
state_->angle_ += RotationForTimeDelta(delta_time) * fling_multiplier_;
|
||||
if (state_->angle_ >= 360.0f)
|
||||
state_->angle_ -= 360.0f;
|
||||
|
||||
// Arbitrary 50-step linear reduction in spin speed.
|
||||
if (fling_multiplier_ > 1.0f) {
|
||||
fling_multiplier_ =
|
||||
std::max(1.0f, fling_multiplier_ - (fling_multiplier_ - 1.0f) / 50);
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void SpinningCube::UpdateForDragDistance(float distance) {
|
||||
state_->angle_ += RotationForDragDistance(distance);
|
||||
if (state_->angle_ >= 360.0f )
|
||||
state_->angle_ -= 360.0f;
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void SpinningCube::Draw() {
|
||||
glViewport(0, 0, width_, height_);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glUseProgram(state_->program_object_);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, state_->vbo_vertices_);
|
||||
glVertexAttribPointer(state_->position_location_,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE, 3 * sizeof(GLfloat),
|
||||
0);
|
||||
glEnableVertexAttribArray(state_->position_location_);
|
||||
|
||||
glUniformMatrix4fv(state_->mvp_location_,
|
||||
1,
|
||||
GL_FALSE,
|
||||
(GLfloat*) &state_->mvp_matrix_.m[0][0]);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, state_->vbo_indices_);
|
||||
glDrawElements(GL_TRIANGLES,
|
||||
state_->num_indices_,
|
||||
GL_UNSIGNED_SHORT,
|
||||
0);
|
||||
}
|
||||
|
||||
void SpinningCube::Update() {
|
||||
float aspect = static_cast<GLfloat>(width_) / static_cast<GLfloat>(height_);
|
||||
|
||||
ESMatrix perspective;
|
||||
perspective.LoadIdentity();
|
||||
perspective.Perspective(60.0f, aspect, 1.0f, 20.0f );
|
||||
|
||||
ESMatrix modelview;
|
||||
modelview.LoadIdentity();
|
||||
modelview.Translate(0.0, 0.0, -2.0);
|
||||
modelview.Rotate(state_->angle_ * direction_, 1.0, 0.0, 1.0);
|
||||
|
||||
state_->mvp_matrix_.Multiply(&modelview, &perspective);
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_EXAMPLES_COMPOSITOR_SPINNING_CUBE_H_
|
||||
#define PPAPI_EXAMPLES_COMPOSITOR_SPINNING_CUBE_H_
|
||||
|
||||
#include "ppapi/c/pp_stdint.h"
|
||||
|
||||
class SpinningCube {
|
||||
public:
|
||||
SpinningCube();
|
||||
~SpinningCube();
|
||||
|
||||
void Init(uint32_t width, uint32_t height);
|
||||
void set_direction(int direction) { direction_ = direction; }
|
||||
void SetFlingMultiplier(float drag_distance, float drag_time);
|
||||
void UpdateForTimeDelta(float delta_time);
|
||||
void UpdateForDragDistance(float distance);
|
||||
void Draw();
|
||||
|
||||
void OnGLContextLost();
|
||||
|
||||
private:
|
||||
class GLState;
|
||||
|
||||
// Disallow copy and assign.
|
||||
SpinningCube(const SpinningCube& other);
|
||||
SpinningCube& operator=(const SpinningCube& other);
|
||||
|
||||
void Update();
|
||||
|
||||
bool initialized_;
|
||||
uint32_t width_;
|
||||
uint32_t height_;
|
||||
// Owned ptr.
|
||||
GLState* state_;
|
||||
float fling_multiplier_;
|
||||
int direction_;
|
||||
};
|
||||
|
||||
#endif // PPAPI_EXAMPLES_COMPOSITOR_SPINNING_CUBE_H_
|
@ -50,10 +50,6 @@ void ResourceHost::SendReply(const ReplyMessageContext& context,
|
||||
host_->SendReply(context, msg);
|
||||
}
|
||||
|
||||
bool ResourceHost::IsCompositorHost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ResourceHost::IsFileRefHost() {
|
||||
return false;
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ class PPAPI_HOST_EXPORT ResourceHost : public ResourceMessageHandler {
|
||||
|
||||
// Simple RTTI. A subclass that is a host for one of these APIs will override
|
||||
// the appropriate function and return true.
|
||||
virtual bool IsCompositorHost();
|
||||
virtual bool IsFileRefHost();
|
||||
virtual bool IsFileSystemHost();
|
||||
virtual bool IsGraphics2DHost();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2018 The Chromium Authors. All rights reserved.
|
||||
/* Copyright (c) 2019 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
@ -18,8 +18,6 @@
|
||||
#include "ppapi/c/dev/ppb_video_capture_dev.h"
|
||||
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
|
||||
#include "ppapi/c/ppb_audio_encoder.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_console.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_file_io.h"
|
||||
@ -89,9 +87,6 @@ static int mystrcmp(const char* s1, const char *s2) {
|
||||
/* BEGIN Declarations for all Wrapper Infos */
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioEncoder_0_1;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Compositor_0_1;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_1;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_2;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Core_1_0;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_0;
|
||||
@ -266,143 +261,6 @@ static void Pnacl_M47_PPB_AudioEncoder_Close(PP_Resource audio_encoder) {
|
||||
|
||||
/* End wrapper methods for PPB_AudioEncoder_0_1 */
|
||||
|
||||
/* Begin wrapper methods for PPB_Compositor_0_1 */
|
||||
|
||||
static PP_Bool Pnacl_M37_PPB_Compositor_IsCompositor(PP_Resource resource) {
|
||||
const struct PPB_Compositor_0_1 *iface = Pnacl_WrapperInfo_PPB_Compositor_0_1.real_iface;
|
||||
return iface->IsCompositor(resource);
|
||||
}
|
||||
|
||||
static PP_Resource Pnacl_M37_PPB_Compositor_Create(PP_Instance instance) {
|
||||
const struct PPB_Compositor_0_1 *iface = Pnacl_WrapperInfo_PPB_Compositor_0_1.real_iface;
|
||||
return iface->Create(instance);
|
||||
}
|
||||
|
||||
static PP_Resource Pnacl_M37_PPB_Compositor_AddLayer(PP_Resource compositor) {
|
||||
const struct PPB_Compositor_0_1 *iface = Pnacl_WrapperInfo_PPB_Compositor_0_1.real_iface;
|
||||
return iface->AddLayer(compositor);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_Compositor_CommitLayers(PP_Resource compositor, struct PP_CompletionCallback* cc) {
|
||||
const struct PPB_Compositor_0_1 *iface = Pnacl_WrapperInfo_PPB_Compositor_0_1.real_iface;
|
||||
return iface->CommitLayers(compositor, *cc);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_Compositor_ResetLayers(PP_Resource compositor) {
|
||||
const struct PPB_Compositor_0_1 *iface = Pnacl_WrapperInfo_PPB_Compositor_0_1.real_iface;
|
||||
return iface->ResetLayers(compositor);
|
||||
}
|
||||
|
||||
/* End wrapper methods for PPB_Compositor_0_1 */
|
||||
|
||||
/* Begin wrapper methods for PPB_CompositorLayer_0_1 */
|
||||
|
||||
static PP_Bool Pnacl_M37_PPB_CompositorLayer_IsCompositorLayer(PP_Resource resource) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->IsCompositorLayer(resource);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetColor(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetColor(layer, red, green, blue, alpha, size);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetTexture(PP_Resource layer, PP_Resource context, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback* cc) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetTexture(layer, context, texture, size, *cc);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetImage(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback* cc) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetImage(layer, image_data, size, *cc);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetClipRect(PP_Resource layer, const struct PP_Rect* rect) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetClipRect(layer, rect);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetTransform(PP_Resource layer, const float matrix[16]) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetTransform(layer, matrix);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetOpacity(PP_Resource layer, float opacity) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetOpacity(layer, opacity);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetBlendMode(PP_Resource layer, PP_BlendMode mode) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetBlendMode(layer, mode);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetSourceRect(PP_Resource layer, const struct PP_FloatRect* rect) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetSourceRect(layer, rect);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M37_PPB_CompositorLayer_SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) {
|
||||
const struct PPB_CompositorLayer_0_1 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_1.real_iface;
|
||||
return iface->SetPremultipliedAlpha(layer, premult);
|
||||
}
|
||||
|
||||
/* End wrapper methods for PPB_CompositorLayer_0_1 */
|
||||
|
||||
/* Begin wrapper methods for PPB_CompositorLayer_0_2 */
|
||||
|
||||
static PP_Bool Pnacl_M38_PPB_CompositorLayer_IsCompositorLayer(PP_Resource resource) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->IsCompositorLayer(resource);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetColor(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetColor(layer, red, green, blue, alpha, size);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetTexture(PP_Resource layer, PP_Resource context, uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback* cc) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetTexture(layer, context, target, texture, size, *cc);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetImage(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback* cc) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetImage(layer, image_data, size, *cc);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetClipRect(PP_Resource layer, const struct PP_Rect* rect) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetClipRect(layer, rect);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetTransform(PP_Resource layer, const float matrix[16]) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetTransform(layer, matrix);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetOpacity(PP_Resource layer, float opacity) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetOpacity(layer, opacity);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetBlendMode(PP_Resource layer, PP_BlendMode mode) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetBlendMode(layer, mode);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetSourceRect(PP_Resource layer, const struct PP_FloatRect* rect) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetSourceRect(layer, rect);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M38_PPB_CompositorLayer_SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) {
|
||||
const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface;
|
||||
return iface->SetPremultipliedAlpha(layer, premult);
|
||||
}
|
||||
|
||||
/* End wrapper methods for PPB_CompositorLayer_0_2 */
|
||||
|
||||
/* Begin wrapper methods for PPB_Console_1_0 */
|
||||
|
||||
static void Pnacl_M25_PPB_Console_Log(PP_Instance instance, PP_LogLevel level, struct PP_Var* value) {
|
||||
@ -4501,40 +4359,6 @@ static const struct PPB_AudioEncoder_0_1 Pnacl_Wrappers_PPB_AudioEncoder_0_1 = {
|
||||
.Close = (void (*)(PP_Resource audio_encoder))&Pnacl_M47_PPB_AudioEncoder_Close
|
||||
};
|
||||
|
||||
static const struct PPB_Compositor_0_1 Pnacl_Wrappers_PPB_Compositor_0_1 = {
|
||||
.IsCompositor = (PP_Bool (*)(PP_Resource resource))&Pnacl_M37_PPB_Compositor_IsCompositor,
|
||||
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M37_PPB_Compositor_Create,
|
||||
.AddLayer = (PP_Resource (*)(PP_Resource compositor))&Pnacl_M37_PPB_Compositor_AddLayer,
|
||||
.CommitLayers = (int32_t (*)(PP_Resource compositor, struct PP_CompletionCallback cc))&Pnacl_M37_PPB_Compositor_CommitLayers,
|
||||
.ResetLayers = (int32_t (*)(PP_Resource compositor))&Pnacl_M37_PPB_Compositor_ResetLayers
|
||||
};
|
||||
|
||||
static const struct PPB_CompositorLayer_0_1 Pnacl_Wrappers_PPB_CompositorLayer_0_1 = {
|
||||
.IsCompositorLayer = (PP_Bool (*)(PP_Resource resource))&Pnacl_M37_PPB_CompositorLayer_IsCompositorLayer,
|
||||
.SetColor = (int32_t (*)(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size))&Pnacl_M37_PPB_CompositorLayer_SetColor,
|
||||
.SetTexture = (int32_t (*)(PP_Resource layer, PP_Resource context, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M37_PPB_CompositorLayer_SetTexture,
|
||||
.SetImage = (int32_t (*)(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M37_PPB_CompositorLayer_SetImage,
|
||||
.SetClipRect = (int32_t (*)(PP_Resource layer, const struct PP_Rect* rect))&Pnacl_M37_PPB_CompositorLayer_SetClipRect,
|
||||
.SetTransform = (int32_t (*)(PP_Resource layer, const float matrix[16]))&Pnacl_M37_PPB_CompositorLayer_SetTransform,
|
||||
.SetOpacity = (int32_t (*)(PP_Resource layer, float opacity))&Pnacl_M37_PPB_CompositorLayer_SetOpacity,
|
||||
.SetBlendMode = (int32_t (*)(PP_Resource layer, PP_BlendMode mode))&Pnacl_M37_PPB_CompositorLayer_SetBlendMode,
|
||||
.SetSourceRect = (int32_t (*)(PP_Resource layer, const struct PP_FloatRect* rect))&Pnacl_M37_PPB_CompositorLayer_SetSourceRect,
|
||||
.SetPremultipliedAlpha = (int32_t (*)(PP_Resource layer, PP_Bool premult))&Pnacl_M37_PPB_CompositorLayer_SetPremultipliedAlpha
|
||||
};
|
||||
|
||||
static const struct PPB_CompositorLayer_0_2 Pnacl_Wrappers_PPB_CompositorLayer_0_2 = {
|
||||
.IsCompositorLayer = (PP_Bool (*)(PP_Resource resource))&Pnacl_M38_PPB_CompositorLayer_IsCompositorLayer,
|
||||
.SetColor = (int32_t (*)(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size))&Pnacl_M38_PPB_CompositorLayer_SetColor,
|
||||
.SetTexture = (int32_t (*)(PP_Resource layer, PP_Resource context, uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M38_PPB_CompositorLayer_SetTexture,
|
||||
.SetImage = (int32_t (*)(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M38_PPB_CompositorLayer_SetImage,
|
||||
.SetClipRect = (int32_t (*)(PP_Resource layer, const struct PP_Rect* rect))&Pnacl_M38_PPB_CompositorLayer_SetClipRect,
|
||||
.SetTransform = (int32_t (*)(PP_Resource layer, const float matrix[16]))&Pnacl_M38_PPB_CompositorLayer_SetTransform,
|
||||
.SetOpacity = (int32_t (*)(PP_Resource layer, float opacity))&Pnacl_M38_PPB_CompositorLayer_SetOpacity,
|
||||
.SetBlendMode = (int32_t (*)(PP_Resource layer, PP_BlendMode mode))&Pnacl_M38_PPB_CompositorLayer_SetBlendMode,
|
||||
.SetSourceRect = (int32_t (*)(PP_Resource layer, const struct PP_FloatRect* rect))&Pnacl_M38_PPB_CompositorLayer_SetSourceRect,
|
||||
.SetPremultipliedAlpha = (int32_t (*)(PP_Resource layer, PP_Bool premult))&Pnacl_M38_PPB_CompositorLayer_SetPremultipliedAlpha
|
||||
};
|
||||
|
||||
static const struct PPB_Console_1_0 Pnacl_Wrappers_PPB_Console_1_0 = {
|
||||
.Log = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var value))&Pnacl_M25_PPB_Console_Log,
|
||||
.LogWithSource = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var source, struct PP_Var value))&Pnacl_M25_PPB_Console_LogWithSource
|
||||
@ -5674,24 +5498,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioEncoder_0_1 = {
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Compositor_0_1 = {
|
||||
.iface_macro = PPB_COMPOSITOR_INTERFACE_0_1,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Compositor_0_1,
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_1 = {
|
||||
.iface_macro = PPB_COMPOSITORLAYER_INTERFACE_0_1,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_CompositorLayer_0_1,
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_2 = {
|
||||
.iface_macro = PPB_COMPOSITORLAYER_INTERFACE_0_2,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_CompositorLayer_0_2,
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0 = {
|
||||
.iface_macro = PPB_CONSOLE_INTERFACE_1_0,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Console_1_0,
|
||||
@ -6312,9 +6118,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1 = {
|
||||
|
||||
static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
|
||||
&Pnacl_WrapperInfo_PPB_AudioEncoder_0_1,
|
||||
&Pnacl_WrapperInfo_PPB_Compositor_0_1,
|
||||
&Pnacl_WrapperInfo_PPB_CompositorLayer_0_1,
|
||||
&Pnacl_WrapperInfo_PPB_CompositorLayer_0_2,
|
||||
&Pnacl_WrapperInfo_PPB_Console_1_0,
|
||||
&Pnacl_WrapperInfo_PPB_Core_1_0,
|
||||
&Pnacl_WrapperInfo_PPB_FileIO_1_0,
|
||||
|
@ -36,10 +36,6 @@ jumbo_component("proxy") {
|
||||
"camera_capabilities_resource.h",
|
||||
"camera_device_resource.cc",
|
||||
"camera_device_resource.h",
|
||||
"compositor_layer_resource.cc",
|
||||
"compositor_layer_resource.h",
|
||||
"compositor_resource.cc",
|
||||
"compositor_resource.h",
|
||||
"connection.h",
|
||||
"dispatcher.cc",
|
||||
"dispatcher.h",
|
||||
|
@ -1,384 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/proxy/compositor_layer_resource.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "gpu/GLES2/gl2extchromium.h"
|
||||
#include "gpu/command_buffer/client/gles2_implementation.h"
|
||||
#include "gpu/command_buffer/common/mailbox.h"
|
||||
#include "gpu/command_buffer/common/sync_token.h"
|
||||
#include "ppapi/proxy/compositor_resource.h"
|
||||
#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppb_graphics_3d_api.h"
|
||||
#include "ppapi/thunk/ppb_image_data_api.h"
|
||||
|
||||
using gpu::gles2::GLES2Implementation;
|
||||
using ppapi::thunk::EnterResourceNoLock;
|
||||
using ppapi::thunk::PPB_ImageData_API;
|
||||
using ppapi::thunk::PPB_Graphics3D_API;
|
||||
|
||||
namespace ppapi {
|
||||
namespace proxy {
|
||||
|
||||
namespace {
|
||||
|
||||
float clamp(float value) {
|
||||
return std::min(std::max(value, 0.0f), 1.0f);
|
||||
}
|
||||
|
||||
void OnTextureReleased(const ScopedPPResource& layer,
|
||||
const ScopedPPResource& context,
|
||||
uint32_t texture,
|
||||
const scoped_refptr<TrackedCallback>& release_callback,
|
||||
int32_t result,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost) {
|
||||
if (!TrackedCallback::IsPending(release_callback))
|
||||
return;
|
||||
|
||||
if (result != PP_OK) {
|
||||
release_callback->Run(result);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
if (!sync_token.HasData())
|
||||
break;
|
||||
|
||||
EnterResourceNoLock<PPB_Graphics3D_API> enter(context.get(), true);
|
||||
if (enter.failed())
|
||||
break;
|
||||
|
||||
PPB_Graphics3D_Shared* graphics =
|
||||
static_cast<PPB_Graphics3D_Shared*>(enter.object());
|
||||
|
||||
GLES2Implementation* gl = graphics->gles2_impl();
|
||||
gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
|
||||
} while (false);
|
||||
|
||||
release_callback->Run(is_lost ? PP_ERROR_FAILED : PP_OK);
|
||||
}
|
||||
|
||||
void OnImageReleased(const ScopedPPResource& layer,
|
||||
const ScopedPPResource& image,
|
||||
const scoped_refptr<TrackedCallback>& release_callback,
|
||||
int32_t result,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost) {
|
||||
if (!TrackedCallback::IsPending(release_callback))
|
||||
return;
|
||||
release_callback->Run(result);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CompositorLayerResource::CompositorLayerResource(
|
||||
Connection connection,
|
||||
PP_Instance instance,
|
||||
const CompositorResource* compositor)
|
||||
: PluginResource(connection, instance),
|
||||
compositor_(compositor),
|
||||
source_size_(PP_MakeFloatSize(0.0f, 0.0f)) {
|
||||
}
|
||||
|
||||
CompositorLayerResource::~CompositorLayerResource() {
|
||||
DCHECK(!compositor_);
|
||||
DCHECK(release_callback_.is_null());
|
||||
}
|
||||
|
||||
thunk::PPB_CompositorLayer_API*
|
||||
CompositorLayerResource::AsPPB_CompositorLayer_API() {
|
||||
return this;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetColor(float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const PP_Size* size) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
if (!SetType(TYPE_COLOR))
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
DCHECK(data_.color);
|
||||
|
||||
if (!size)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
data_.color->red = clamp(red);
|
||||
data_.color->green = clamp(green);
|
||||
data_.color->blue = clamp(blue);
|
||||
data_.color->alpha = clamp(alpha);
|
||||
data_.common.size = *size;
|
||||
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetTexture0_1(
|
||||
PP_Resource context,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<TrackedCallback>& release_callback) {
|
||||
return SetTexture(context, GL_TEXTURE_2D, texture, size, release_callback);
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetTexture(
|
||||
PP_Resource context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<TrackedCallback>& release_callback) {
|
||||
int32_t rv = CheckForSetTextureAndImage(TYPE_TEXTURE, release_callback);
|
||||
if (rv != PP_OK)
|
||||
return rv;
|
||||
DCHECK(data_.texture);
|
||||
|
||||
EnterResourceNoLock<PPB_Graphics3D_API> enter(context, true);
|
||||
if (enter.failed())
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (target != GL_TEXTURE_2D &&
|
||||
target != GL_TEXTURE_EXTERNAL_OES &&
|
||||
target != GL_TEXTURE_RECTANGLE_ARB) {
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
if (!size || size->width <= 0 || size->height <= 0)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
PPB_Graphics3D_Shared* graphics =
|
||||
static_cast<PPB_Graphics3D_Shared*>(enter.object());
|
||||
|
||||
GLES2Implementation* gl = graphics->gles2_impl();
|
||||
|
||||
// Generate a Mailbox for the texture.
|
||||
gl->ProduceTextureDirectCHROMIUM(texture, data_.texture->mailbox.name);
|
||||
|
||||
// Set the source size to (1, 1). It will be used to verify the source_rect
|
||||
// passed to SetSourceRect().
|
||||
source_size_ = PP_MakeFloatSize(1.0f, 1.0f);
|
||||
|
||||
data_.common.size = *size;
|
||||
data_.common.resource_id = compositor_->GenerateResourceId();
|
||||
data_.texture->target = target;
|
||||
data_.texture->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f);
|
||||
data_.texture->source_rect.size = source_size_;
|
||||
|
||||
gl->GenSyncTokenCHROMIUM(data_.texture->sync_token.GetData());
|
||||
|
||||
// If the PP_Resource of this layer is released by the plugin, the
|
||||
// release_callback will be aborted immediately, but the texture or image
|
||||
// in this layer may still being used by chromium compositor. So we have to
|
||||
// use ScopedPPResource to keep this resource alive until the texture or image
|
||||
// is released by the chromium compositor.
|
||||
release_callback_ = base::Bind(
|
||||
&OnTextureReleased,
|
||||
ScopedPPResource(pp_resource()), // Keep layer alive.
|
||||
ScopedPPResource(context), // Keep context alive
|
||||
texture,
|
||||
release_callback);
|
||||
|
||||
return PP_OK_COMPLETIONPENDING;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetImage(
|
||||
PP_Resource image_data,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<TrackedCallback>& release_callback) {
|
||||
int32_t rv = CheckForSetTextureAndImage(TYPE_IMAGE, release_callback);
|
||||
if (rv != PP_OK)
|
||||
return rv;
|
||||
DCHECK(data_.image);
|
||||
|
||||
EnterResourceNoLock<PPB_ImageData_API> enter(image_data, true);
|
||||
if (enter.failed())
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
PP_ImageDataDesc desc;
|
||||
if (!enter.object()->Describe(&desc))
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
// TODO(penghuang): Support image which width * 4 != stride.
|
||||
if (desc.size.width * 4 != desc.stride)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
// TODO(penghuang): Support all formats.
|
||||
if (desc.format != PP_IMAGEDATAFORMAT_RGBA_PREMUL)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
if (size && (size->width <= 0 || size->height <= 0))
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
// Set the source size to image's size. It will be used to verify
|
||||
// the source_rect passed to SetSourceRect().
|
||||
source_size_ = PP_MakeFloatSize(desc.size.width, desc.size.height);
|
||||
|
||||
data_.common.size = size ? *size : desc.size;
|
||||
data_.common.resource_id = compositor_->GenerateResourceId();
|
||||
data_.image->resource = enter.resource()->host_resource().host_resource();
|
||||
data_.image->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f);
|
||||
data_.image->source_rect.size = source_size_;
|
||||
|
||||
// If the PP_Resource of this layer is released by the plugin, the
|
||||
// release_callback will be aborted immediately, but the texture or image
|
||||
// in this layer may still being used by chromium compositor. So we have to
|
||||
// use ScopedPPResource to keep this resource alive until the texture or image
|
||||
// is released by the chromium compositor.
|
||||
release_callback_ = base::Bind(
|
||||
&OnImageReleased,
|
||||
ScopedPPResource(pp_resource()), // Keep layer alive.
|
||||
ScopedPPResource(image_data), // Keep image_data alive.
|
||||
release_callback);
|
||||
|
||||
return PP_OK_COMPLETIONPENDING;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetClipRect(const PP_Rect* rect) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
data_.common.clip_rect = rect ? *rect : PP_MakeRectFromXYWH(0, 0, 0, 0);
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetTransform(const float matrix[16]) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
std::copy(matrix, matrix + 16, data_.common.transform.matrix);
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetOpacity(float opacity) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
data_.common.opacity = clamp(opacity);
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetBlendMode(PP_BlendMode mode) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
switch (mode) {
|
||||
case PP_BLENDMODE_NONE:
|
||||
case PP_BLENDMODE_SRC_OVER:
|
||||
data_.common.blend_mode = mode;
|
||||
return PP_OK;
|
||||
}
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetSourceRect(
|
||||
const PP_FloatRect* rect) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
const float kEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (!rect ||
|
||||
rect->point.x < -kEpsilon ||
|
||||
rect->point.y < -kEpsilon ||
|
||||
rect->point.x + rect->size.width > source_size_.width + kEpsilon ||
|
||||
rect->point.y + rect->size.height > source_size_.height + kEpsilon) {
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
if (data_.texture) {
|
||||
data_.texture->source_rect = *rect;
|
||||
return PP_OK;
|
||||
}
|
||||
if (data_.image) {
|
||||
data_.image->source_rect = *rect;
|
||||
return PP_OK;
|
||||
}
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::SetPremultipliedAlpha(PP_Bool premult) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
if (data_.texture) {
|
||||
data_.texture->premult_alpha = PP_ToBool(premult);
|
||||
return PP_OK;
|
||||
}
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
}
|
||||
|
||||
bool CompositorLayerResource::SetType(LayerType type) {
|
||||
if (type == TYPE_COLOR) {
|
||||
if (data_.is_null())
|
||||
data_.color.reset(new CompositorLayerData::ColorLayer());
|
||||
return !!data_.color;
|
||||
}
|
||||
|
||||
if (type == TYPE_TEXTURE) {
|
||||
if (data_.is_null())
|
||||
data_.texture.reset(new CompositorLayerData::TextureLayer());
|
||||
return !!data_.texture;
|
||||
}
|
||||
|
||||
if (type == TYPE_IMAGE) {
|
||||
if (data_.is_null())
|
||||
data_.image.reset(new CompositorLayerData::ImageLayer());
|
||||
return !!data_.image;
|
||||
}
|
||||
|
||||
// Should not be reached.
|
||||
DCHECK(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t CompositorLayerResource::CheckForSetTextureAndImage(
|
||||
LayerType type,
|
||||
const scoped_refptr<TrackedCallback>& release_callback) {
|
||||
if (!compositor_)
|
||||
return PP_ERROR_BADRESOURCE;
|
||||
|
||||
if (compositor_->IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
if (!SetType(type))
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
// The layer's image has been set and it is not committed.
|
||||
if (!release_callback_.is_null())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
// Do not allow using a block callback as a release callback.
|
||||
if (release_callback->is_blocking())
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
@ -1,113 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
|
||||
#define PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/proxy/plugin_resource.h"
|
||||
#include "ppapi/proxy/ppapi_proxy_export.h"
|
||||
#include "ppapi/shared_impl/compositor_layer_data.h"
|
||||
#include "ppapi/shared_impl/scoped_pp_resource.h"
|
||||
#include "ppapi/thunk/ppb_compositor_layer_api.h"
|
||||
|
||||
namespace gpu {
|
||||
struct SyncToken;
|
||||
}
|
||||
|
||||
namespace ppapi {
|
||||
namespace proxy {
|
||||
|
||||
class CompositorResource;
|
||||
|
||||
class PPAPI_PROXY_EXPORT CompositorLayerResource
|
||||
: public PluginResource,
|
||||
public thunk::PPB_CompositorLayer_API {
|
||||
public:
|
||||
// Release callback for texture or image layer.
|
||||
typedef base::Callback<void(int32_t, const gpu::SyncToken&, bool)>
|
||||
ReleaseCallback;
|
||||
|
||||
CompositorLayerResource(Connection connection,
|
||||
PP_Instance instance,
|
||||
const CompositorResource* compositor);
|
||||
|
||||
const CompositorLayerData& data() const { return data_; }
|
||||
const ReleaseCallback& release_callback() const {
|
||||
return release_callback_;
|
||||
}
|
||||
void ResetReleaseCallback() { release_callback_.Reset(); }
|
||||
void Invalidate() { compositor_ = NULL; }
|
||||
|
||||
private:
|
||||
enum LayerType {
|
||||
TYPE_COLOR,
|
||||
TYPE_TEXTURE,
|
||||
TYPE_IMAGE,
|
||||
};
|
||||
|
||||
~CompositorLayerResource() override;
|
||||
|
||||
// Resource overrides:
|
||||
thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() override;
|
||||
|
||||
// thunk::PPB_Compositor_API overrides:
|
||||
int32_t SetColor(float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const PP_Size* size) override;
|
||||
int32_t SetTexture0_1(
|
||||
PP_Resource context,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) override;
|
||||
int32_t SetTexture(
|
||||
PP_Resource context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<TrackedCallback>& callback) override;
|
||||
int32_t SetImage(
|
||||
PP_Resource image_data,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<TrackedCallback>& callback) override;
|
||||
int32_t SetClipRect(const PP_Rect* rect) override;
|
||||
int32_t SetTransform(const float matrix[16]) override;
|
||||
int32_t SetOpacity(float opacity) override;
|
||||
int32_t SetBlendMode(PP_BlendMode mode) override;
|
||||
int32_t SetSourceRect(const PP_FloatRect* rect) override;
|
||||
int32_t SetPremultipliedAlpha(PP_Bool premult) override;
|
||||
|
||||
bool SetType(LayerType type);
|
||||
int32_t CheckForSetTextureAndImage(
|
||||
LayerType type,
|
||||
const scoped_refptr<TrackedCallback>& release_callback);
|
||||
|
||||
// The CompositorResource which own the layer. The layer is invalidated if
|
||||
// compositor_ is NULL.
|
||||
const CompositorResource* compositor_;
|
||||
|
||||
// Release callback for uncommitted texture or image. When CommitLayers() on
|
||||
// the compositor_ is called, the callback will be copied into a map in the
|
||||
// compositor_, and it will be reset to NULL.
|
||||
ReleaseCallback release_callback_;
|
||||
|
||||
// Size of texture or image. It is used to verify the rect arg of
|
||||
// SetSourceRect().
|
||||
PP_FloatSize source_size_;
|
||||
|
||||
// Layer data.
|
||||
CompositorLayerData data_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CompositorLayerResource);
|
||||
};
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
|
@ -1,155 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/proxy/compositor_resource.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "ppapi/proxy/ppapi_messages.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace proxy {
|
||||
|
||||
CompositorResource::CompositorResource(Connection connection,
|
||||
PP_Instance instance)
|
||||
: PluginResource(connection, instance),
|
||||
layer_reset_(true),
|
||||
last_resource_id_(0) {
|
||||
SendCreate(RENDERER, PpapiHostMsg_Compositor_Create());
|
||||
}
|
||||
|
||||
bool CompositorResource::IsInProgress() const {
|
||||
ProxyLock::AssertAcquiredDebugOnly();
|
||||
return TrackedCallback::IsPending(commit_callback_);
|
||||
}
|
||||
|
||||
int32_t CompositorResource::GenerateResourceId() const {
|
||||
ProxyLock::AssertAcquiredDebugOnly();
|
||||
return ++last_resource_id_;
|
||||
}
|
||||
|
||||
CompositorResource::~CompositorResource() {
|
||||
ResetLayersInternal(true);
|
||||
|
||||
// Abort all release callbacks.
|
||||
for (ReleaseCallbackMap::iterator it = release_callback_map_.begin();
|
||||
it != release_callback_map_.end(); ++it) {
|
||||
if (!it->second.is_null())
|
||||
it->second.Run(PP_ERROR_ABORTED, gpu::SyncToken(), false);
|
||||
}
|
||||
}
|
||||
|
||||
thunk::PPB_Compositor_API* CompositorResource::AsPPB_Compositor_API() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void CompositorResource::OnReplyReceived(
|
||||
const ResourceMessageReplyParams& params,
|
||||
const IPC::Message& msg) {
|
||||
PPAPI_BEGIN_MESSAGE_MAP(CompositorResource, msg)
|
||||
PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
|
||||
PpapiPluginMsg_Compositor_ReleaseResource,
|
||||
OnPluginMsgReleaseResource)
|
||||
PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
|
||||
PluginResource::OnReplyReceived(params, msg))
|
||||
PPAPI_END_MESSAGE_MAP()
|
||||
}
|
||||
|
||||
PP_Resource CompositorResource::AddLayer() {
|
||||
scoped_refptr<CompositorLayerResource> resource(new CompositorLayerResource(
|
||||
connection(), pp_instance(), this));
|
||||
layers_.push_back(resource);
|
||||
return resource->GetReference();
|
||||
}
|
||||
|
||||
int32_t CompositorResource::CommitLayers(
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) {
|
||||
if (IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
std::vector<CompositorLayerData> layers;
|
||||
layers.reserve(layers_.size());
|
||||
|
||||
for (LayerList::const_iterator it = layers_.begin();
|
||||
it != layers_.end(); ++it) {
|
||||
if ((*it)->data().is_null())
|
||||
return PP_ERROR_FAILED;
|
||||
layers.push_back((*it)->data());
|
||||
}
|
||||
|
||||
commit_callback_ = callback;
|
||||
Call<PpapiPluginMsg_Compositor_CommitLayersReply>(
|
||||
RENDERER,
|
||||
PpapiHostMsg_Compositor_CommitLayers(layers, layer_reset_),
|
||||
base::Bind(&CompositorResource::OnPluginMsgCommitLayersReply,
|
||||
base::Unretained(this)),
|
||||
callback);
|
||||
|
||||
return PP_OK_COMPLETIONPENDING;
|
||||
}
|
||||
|
||||
int32_t CompositorResource::ResetLayers() {
|
||||
if (IsInProgress())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
ResetLayersInternal(false);
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
void CompositorResource::OnPluginMsgCommitLayersReply(
|
||||
const ResourceMessageReplyParams& params) {
|
||||
if (!TrackedCallback::IsPending(commit_callback_))
|
||||
return;
|
||||
|
||||
// On success, we put layers' release_callbacks into a map,
|
||||
// otherwise we will do nothing. So plugin may change layers and
|
||||
// call CommitLayers() again.
|
||||
if (params.result() == PP_OK) {
|
||||
layer_reset_ = false;
|
||||
for (LayerList::iterator it = layers_.begin();
|
||||
it != layers_.end(); ++it) {
|
||||
ReleaseCallback release_callback = (*it)->release_callback();
|
||||
if (!release_callback.is_null()) {
|
||||
release_callback_map_.insert(ReleaseCallbackMap::value_type(
|
||||
(*it)->data().common.resource_id, release_callback));
|
||||
(*it)->ResetReleaseCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scoped_refptr<TrackedCallback> callback;
|
||||
callback.swap(commit_callback_);
|
||||
callback->Run(params.result());
|
||||
}
|
||||
|
||||
void CompositorResource::OnPluginMsgReleaseResource(
|
||||
const ResourceMessageReplyParams& params,
|
||||
int32_t id,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost) {
|
||||
ReleaseCallbackMap::iterator it = release_callback_map_.find(id);
|
||||
DCHECK(it != release_callback_map_.end()) <<
|
||||
"Can not found release_callback_ by id(" << id << ")!";
|
||||
it->second.Run(PP_OK, sync_token, is_lost);
|
||||
release_callback_map_.erase(it);
|
||||
}
|
||||
|
||||
void CompositorResource::ResetLayersInternal(bool is_aborted) {
|
||||
for (LayerList::iterator it = layers_.begin();
|
||||
it != layers_.end(); ++it) {
|
||||
ReleaseCallback release_callback = (*it)->release_callback();
|
||||
if (!release_callback.is_null()) {
|
||||
release_callback.Run(is_aborted ? PP_ERROR_ABORTED : PP_OK,
|
||||
gpu::SyncToken(), false);
|
||||
(*it)->ResetReleaseCallback();
|
||||
}
|
||||
(*it)->Invalidate();
|
||||
}
|
||||
|
||||
layers_.clear();
|
||||
layer_reset_ = true;
|
||||
}
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
@ -1,85 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_PROXY_COMPOSITOR_RESOURCE_H_
|
||||
#define PPAPI_PROXY_COMPOSITOR_RESOURCE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "ppapi/proxy/compositor_layer_resource.h"
|
||||
#include "ppapi/proxy/plugin_resource.h"
|
||||
#include "ppapi/proxy/ppapi_proxy_export.h"
|
||||
#include "ppapi/shared_impl/proxy_lock.h"
|
||||
#include "ppapi/thunk/ppb_compositor_api.h"
|
||||
|
||||
namespace gpu {
|
||||
struct SyncToken;
|
||||
}
|
||||
|
||||
namespace ppapi {
|
||||
namespace proxy {
|
||||
|
||||
class PPAPI_PROXY_EXPORT CompositorResource
|
||||
: public PluginResource,
|
||||
public thunk::PPB_Compositor_API {
|
||||
public:
|
||||
CompositorResource(Connection connection,
|
||||
PP_Instance instance);
|
||||
|
||||
bool IsInProgress() const;
|
||||
|
||||
int32_t GenerateResourceId() const;
|
||||
|
||||
private:
|
||||
~CompositorResource() override;
|
||||
|
||||
// Resource overrides:
|
||||
thunk::PPB_Compositor_API* AsPPB_Compositor_API() override;
|
||||
|
||||
// PluginResource overrides:
|
||||
void OnReplyReceived(const ResourceMessageReplyParams& params,
|
||||
const IPC::Message& msg) override;
|
||||
|
||||
// thunk::PPB_Compositor_API overrides:
|
||||
PP_Resource AddLayer() override;
|
||||
int32_t CommitLayers(const scoped_refptr<TrackedCallback>& callback) override;
|
||||
int32_t ResetLayers() override;
|
||||
|
||||
// IPC msg handlers:
|
||||
void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params);
|
||||
void OnPluginMsgReleaseResource(const ResourceMessageReplyParams& params,
|
||||
int32_t id,
|
||||
const gpu::SyncToken& sync_token,
|
||||
bool is_lost);
|
||||
|
||||
void ResetLayersInternal(bool is_aborted);
|
||||
|
||||
// Callback for CommitLayers().
|
||||
scoped_refptr<TrackedCallback> commit_callback_;
|
||||
|
||||
// True if layers_ has been reset by ResetLayers().
|
||||
bool layer_reset_;
|
||||
|
||||
// Layer stack.
|
||||
typedef std::vector<scoped_refptr<CompositorLayerResource> > LayerList;
|
||||
LayerList layers_;
|
||||
|
||||
// Release callback map for texture and image.
|
||||
typedef CompositorLayerResource::ReleaseCallback ReleaseCallback;
|
||||
typedef std::map<int32_t, ReleaseCallback> ReleaseCallbackMap;
|
||||
ReleaseCallbackMap release_callback_map_;
|
||||
|
||||
// The last resource id for texture or image.
|
||||
mutable int32_t last_resource_id_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CompositorResource);
|
||||
};
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_
|
@ -35,8 +35,6 @@
|
||||
#include "ppapi/c/ppb_audio_buffer.h"
|
||||
#include "ppapi/c/ppb_audio_config.h"
|
||||
#include "ppapi/c/ppb_audio_encoder.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_console.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_file_io.h"
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "ppapi/c/pp_size.h"
|
||||
#include "ppapi/c/pp_time.h"
|
||||
#include "ppapi/c/ppb_audio_config.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_image_data.h"
|
||||
#include "ppapi/c/ppb_tcp_socket.h"
|
||||
#include "ppapi/c/ppb_text_input_controller.h"
|
||||
@ -66,7 +65,6 @@
|
||||
#include "ppapi/proxy/serialized_handle.h"
|
||||
#include "ppapi/proxy/serialized_structs.h"
|
||||
#include "ppapi/proxy/serialized_var.h"
|
||||
#include "ppapi/shared_impl/compositor_layer_data.h"
|
||||
#include "ppapi/shared_impl/dir_contents.h"
|
||||
#include "ppapi/shared_impl/file_growth.h"
|
||||
#include "ppapi/shared_impl/file_path.h"
|
||||
@ -93,7 +91,6 @@
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(ppapi::TCPSocketVersion,
|
||||
ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_AudioSampleRate, PP_AUDIOSAMPLERATE_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_BlendMode, PP_BLENDMODE_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_DeviceType_Dev, PP_DEVICETYPE_DEV_MAX)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_FileSystemType, PP_FILESYSTEMTYPE_ISOLATED)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_FileType, PP_FILETYPE_OTHER)
|
||||
@ -305,42 +302,6 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::FileGrowth)
|
||||
IPC_STRUCT_TRAITS_MEMBER(append_mode_write_amount)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData)
|
||||
IPC_STRUCT_TRAITS_MEMBER(common)
|
||||
IPC_STRUCT_TRAITS_MEMBER(color)
|
||||
IPC_STRUCT_TRAITS_MEMBER(texture)
|
||||
IPC_STRUCT_TRAITS_MEMBER(image)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::LayerCommon)
|
||||
IPC_STRUCT_TRAITS_MEMBER(size)
|
||||
IPC_STRUCT_TRAITS_MEMBER(clip_rect)
|
||||
IPC_STRUCT_TRAITS_MEMBER(transform)
|
||||
IPC_STRUCT_TRAITS_MEMBER(blend_mode)
|
||||
IPC_STRUCT_TRAITS_MEMBER(opacity)
|
||||
IPC_STRUCT_TRAITS_MEMBER(resource_id)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::ColorLayer)
|
||||
IPC_STRUCT_TRAITS_MEMBER(red)
|
||||
IPC_STRUCT_TRAITS_MEMBER(green)
|
||||
IPC_STRUCT_TRAITS_MEMBER(blue)
|
||||
IPC_STRUCT_TRAITS_MEMBER(alpha)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::ImageLayer)
|
||||
IPC_STRUCT_TRAITS_MEMBER(resource)
|
||||
IPC_STRUCT_TRAITS_MEMBER(source_rect)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::TextureLayer)
|
||||
IPC_STRUCT_TRAITS_MEMBER(mailbox)
|
||||
IPC_STRUCT_TRAITS_MEMBER(sync_token)
|
||||
IPC_STRUCT_TRAITS_MEMBER(target)
|
||||
IPC_STRUCT_TRAITS_MEMBER(source_rect)
|
||||
IPC_STRUCT_TRAITS_MEMBER(premult_alpha)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::DeviceRefData)
|
||||
IPC_STRUCT_TRAITS_MEMBER(type)
|
||||
IPC_STRUCT_TRAITS_MEMBER(name)
|
||||
@ -525,10 +486,6 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPB_AudioEncodeParameters)
|
||||
IPC_STRUCT_TRAITS_MEMBER(acceleration)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::Transform)
|
||||
IPC_STRUCT_TRAITS_MEMBER(matrix)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
#if !defined(OS_NACL) && !defined(NACL_WIN64)
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPPDecryptor_Buffer)
|
||||
@ -1472,17 +1429,6 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_UMA_HistogramEnumeration,
|
||||
IPC_MESSAGE_CONTROL0(PpapiHostMsg_UMA_IsCrashReportingEnabled)
|
||||
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_UMA_IsCrashReportingEnabledReply)
|
||||
|
||||
// Compositor
|
||||
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Compositor_Create)
|
||||
IPC_MESSAGE_CONTROL2(PpapiHostMsg_Compositor_CommitLayers,
|
||||
std::vector<ppapi::CompositorLayerData> /* layers */,
|
||||
bool /* reset */)
|
||||
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Compositor_CommitLayersReply)
|
||||
IPC_MESSAGE_CONTROL3(PpapiPluginMsg_Compositor_ReleaseResource,
|
||||
int32_t /* id */,
|
||||
gpu::SyncToken /* sync_token */,
|
||||
bool /* is_lost */)
|
||||
|
||||
// File chooser.
|
||||
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileChooser_Create)
|
||||
IPC_MESSAGE_CONTROL4(PpapiHostMsg_FileChooser_Show,
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "ppapi/c/pp_rect.h"
|
||||
#include "ppapi/c/pp_var.h"
|
||||
#include "ppapi/proxy/ppapi_proxy_export.h"
|
||||
#include "ppapi/shared_impl/compositor_layer_data.h"
|
||||
#include "ppapi/shared_impl/file_path.h"
|
||||
#include "ppapi/shared_impl/file_ref_create_info.h"
|
||||
#include "ppapi/shared_impl/media_stream_video_track_shared.h"
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "ppapi/shared_impl/scoped_pp_var.h"
|
||||
#include "ppapi/shared_impl/var.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppb_compositor_api.h"
|
||||
#include "ppapi/thunk/ppb_graphics_2d_api.h"
|
||||
#include "ppapi/thunk/ppb_graphics_3d_api.h"
|
||||
#include "ppapi/thunk/thunk.h"
|
||||
@ -54,7 +53,6 @@
|
||||
|
||||
using ppapi::thunk::EnterInstanceNoLock;
|
||||
using ppapi::thunk::EnterResourceNoLock;
|
||||
using ppapi::thunk::PPB_Compositor_API;
|
||||
using ppapi::thunk::PPB_Graphics2D_API;
|
||||
using ppapi::thunk::PPB_Graphics3D_API;
|
||||
using ppapi::thunk::PPB_Instance_API;
|
||||
@ -197,13 +195,11 @@ PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance,
|
||||
PpapiGlobals::Get()->GetResourceTracker()->GetResource(device);
|
||||
if (!resource || resource->pp_instance() != instance)
|
||||
return PP_FALSE;
|
||||
// We need to pass different resource to Graphics 2D, 3D and Compositor
|
||||
// right now. Once 3D is migrated to the new design, we should be able to
|
||||
// unify this.
|
||||
// We need to pass different resource to Graphics 2D and 3D right now. Once
|
||||
// 3D is migrated to the new design, we should be able to unify this.
|
||||
if (resource->AsPPB_Graphics3D_API()) {
|
||||
pp_resource = resource->host_resource().host_resource();
|
||||
} else if (resource->AsPPB_Graphics2D_API() ||
|
||||
resource->AsPPB_Compositor_API()) {
|
||||
} else if (resource->AsPPB_Graphics2D_API()) {
|
||||
pp_resource = resource->pp_resource();
|
||||
} else {
|
||||
// A bad resource.
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "ppapi/proxy/audio_input_resource.h"
|
||||
#include "ppapi/proxy/audio_output_resource.h"
|
||||
#include "ppapi/proxy/camera_device_resource.h"
|
||||
#include "ppapi/proxy/compositor_resource.h"
|
||||
#include "ppapi/proxy/connection.h"
|
||||
#include "ppapi/proxy/file_chooser_resource.h"
|
||||
#include "ppapi/proxy/file_io_resource.h"
|
||||
@ -230,10 +229,6 @@ PP_Resource ResourceCreationProxy::CreateCameraDevicePrivate(
|
||||
return (new CameraDeviceResource(GetConnection(), instance))->GetReference();
|
||||
}
|
||||
|
||||
PP_Resource ResourceCreationProxy::CreateCompositor(PP_Instance instance) {
|
||||
return (new CompositorResource(GetConnection(), instance))->GetReference();
|
||||
}
|
||||
|
||||
PP_Resource ResourceCreationProxy::CreateFileChooser(
|
||||
PP_Instance instance,
|
||||
PP_FileChooserMode_Dev mode,
|
||||
|
@ -108,7 +108,6 @@ class ResourceCreationProxy : public InterfaceProxy,
|
||||
PP_AudioSampleRate sample_rate,
|
||||
uint32_t sample_frame_count) override;
|
||||
PP_Resource CreateCameraDevicePrivate(PP_Instance instance) override;
|
||||
PP_Resource CreateCompositor(PP_Instance instance) override;
|
||||
PP_Resource CreateFileChooser(PP_Instance instance,
|
||||
PP_FileChooserMode_Dev mode,
|
||||
const PP_Var& accept_types) override;
|
||||
|
@ -21,8 +21,6 @@ jumbo_component("shared_impl") {
|
||||
"array_writer.h",
|
||||
"callback_tracker.cc",
|
||||
"callback_tracker.h",
|
||||
"compositor_layer_data.cc",
|
||||
"compositor_layer_data.h",
|
||||
"dictionary_var.cc",
|
||||
"dictionary_var.h",
|
||||
"file_growth.cc",
|
||||
|
@ -1,36 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/shared_impl/compositor_layer_data.h"
|
||||
|
||||
namespace ppapi {
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
void Copy(std::unique_ptr<T>* a, const std::unique_ptr<T>& b) {
|
||||
if (b) {
|
||||
if (!(*a))
|
||||
a->reset(new T());
|
||||
**a = *b;
|
||||
} else {
|
||||
a->reset();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const CompositorLayerData& CompositorLayerData::operator=(
|
||||
const CompositorLayerData& other) {
|
||||
DCHECK(other.is_null() || other.is_valid());
|
||||
|
||||
common = other.common;
|
||||
Copy(&color, other.color);
|
||||
Copy(&texture, other.texture);
|
||||
Copy(&image, other.image);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace ppapi
|
@ -1,123 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
|
||||
#define PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "gpu/command_buffer/common/mailbox.h"
|
||||
#include "gpu/command_buffer/common/sync_token.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/shared_impl/host_resource.h"
|
||||
#include "ppapi/shared_impl/ppapi_shared_export.h"
|
||||
|
||||
namespace ppapi {
|
||||
|
||||
struct PPAPI_SHARED_EXPORT CompositorLayerData {
|
||||
|
||||
struct Transform {
|
||||
Transform() {
|
||||
matrix[0] = 1.0f;
|
||||
matrix[1] = 0.0f;
|
||||
matrix[2] = 0.0f;
|
||||
matrix[3] = 0.0f;
|
||||
matrix[4] = 0.0f;
|
||||
matrix[5] = 1.0f;
|
||||
matrix[6] = 0.0f;
|
||||
matrix[7] = 0.0f;
|
||||
matrix[8] = 0.0f;
|
||||
matrix[9] = 0.0f;
|
||||
matrix[10] = 1.0f;
|
||||
matrix[11] = 0.0f;
|
||||
matrix[12] = 0.0f;
|
||||
matrix[13] = 0.0f;
|
||||
matrix[14] = 0.0f;
|
||||
matrix[15] = 1.0f;
|
||||
}
|
||||
|
||||
float matrix[16];
|
||||
};
|
||||
|
||||
struct LayerCommon {
|
||||
LayerCommon()
|
||||
: size(PP_MakeSize(0, 0)),
|
||||
clip_rect(PP_MakeRectFromXYWH(0, 0, 0, 0)),
|
||||
blend_mode(PP_BLENDMODE_SRC_OVER),
|
||||
opacity(1.0f),
|
||||
resource_id(0) {
|
||||
}
|
||||
|
||||
PP_Size size;
|
||||
PP_Rect clip_rect;
|
||||
Transform transform;
|
||||
PP_BlendMode blend_mode;
|
||||
float opacity;
|
||||
uint32_t resource_id;
|
||||
};
|
||||
|
||||
struct ColorLayer {
|
||||
ColorLayer() : red(0.0f), green(0.0f), blue(0.0f), alpha(0.0f) {}
|
||||
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
struct ImageLayer {
|
||||
ImageLayer()
|
||||
: resource(0),
|
||||
source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 0.0f, 0.0f)) {}
|
||||
|
||||
PP_Resource resource;
|
||||
PP_FloatRect source_rect;
|
||||
};
|
||||
|
||||
struct TextureLayer {
|
||||
TextureLayer()
|
||||
: target(0),
|
||||
source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 1.0f, 1.0f)),
|
||||
premult_alpha(true) {}
|
||||
|
||||
gpu::Mailbox mailbox;
|
||||
gpu::SyncToken sync_token;
|
||||
uint32_t target;
|
||||
PP_FloatRect source_rect;
|
||||
bool premult_alpha;
|
||||
};
|
||||
|
||||
CompositorLayerData() {}
|
||||
|
||||
CompositorLayerData(const CompositorLayerData& other) {
|
||||
*this = other;
|
||||
}
|
||||
|
||||
bool is_null() const {
|
||||
return !(color || texture || image);
|
||||
}
|
||||
|
||||
bool is_valid() const {
|
||||
int i = 0;
|
||||
if (color) ++i;
|
||||
if (texture) ++i;
|
||||
if (image) ++i;
|
||||
return i == 1;
|
||||
}
|
||||
|
||||
const CompositorLayerData& operator=(const CompositorLayerData& other);
|
||||
|
||||
LayerCommon common;
|
||||
std::unique_ptr<ColorLayer> color;
|
||||
std::unique_ptr<TextureLayer> texture;
|
||||
std::unique_ptr<ImageLayer> image;
|
||||
};
|
||||
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
|
@ -33,8 +33,6 @@
|
||||
F(PPB_Buffer_API) \
|
||||
F(PPB_CameraCapabilities_API) \
|
||||
F(PPB_CameraDevice_API) \
|
||||
F(PPB_Compositor_API) \
|
||||
F(PPB_CompositorLayer_API) \
|
||||
F(PPB_DeviceRef_API) \
|
||||
F(PPB_Ext_CrxFileSystem_Private_API) \
|
||||
F(PPB_FileChooser_API) \
|
||||
|
@ -52,8 +52,6 @@
|
||||
#include "ppapi/c/ppb_audio.h"
|
||||
#include "ppapi/c/ppb_audio_buffer.h"
|
||||
#include "ppapi/c/ppb_audio_config.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/c/ppb_console.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_file_io.h"
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include "ppapi/cpp/audio_buffer.h"
|
||||
#include "ppapi/cpp/audio_config.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
#include "ppapi/cpp/core.h"
|
||||
#include "ppapi/cpp/dev/buffer_dev.h"
|
||||
#include "ppapi/cpp/dev/device_ref_dev.h"
|
||||
|
@ -1,434 +0,0 @@
|
||||
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ppapi/tests/test_compositor.h"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ppapi/c/ppb_opengles2.h"
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
#include "ppapi/lib/gl/gles2/gl2ext_ppapi.h"
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2.h"
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2ext.h"
|
||||
#include "ppapi/tests/test_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const float kMatrix[16] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
REGISTER_TEST_CASE(Compositor);
|
||||
|
||||
#define VERIFY(r) do { \
|
||||
std::string result = (r); \
|
||||
if (!result.empty()) \
|
||||
return result; \
|
||||
} while (false)
|
||||
|
||||
bool TestCompositor::Init() {
|
||||
if (!CheckTestingInterface())
|
||||
return false;
|
||||
|
||||
if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestCompositor::RunTests(const std::string& filter) {
|
||||
RUN_CALLBACK_TEST(TestCompositor, Release, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, ReleaseWithoutCommit, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, CommitTwoTimesWithoutChange, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, General, filter);
|
||||
|
||||
RUN_CALLBACK_TEST(TestCompositor, ReleaseUnbound, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, ReleaseWithoutCommitUnbound, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, CommitTwoTimesWithoutChangeUnbound, filter);
|
||||
RUN_CALLBACK_TEST(TestCompositor, GeneralUnbound, filter);
|
||||
|
||||
RUN_CALLBACK_TEST(TestCompositor, BindUnbind, filter);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestRelease() {
|
||||
return TestReleaseInternal(true);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestReleaseWithoutCommit() {
|
||||
return TestReleaseWithoutCommitInternal(true);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestCommitTwoTimesWithoutChange() {
|
||||
return TestCommitTwoTimesWithoutChangeInternal(true);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestGeneral() {
|
||||
return TestGeneralInternal(true);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestReleaseUnbound() {
|
||||
return TestReleaseInternal(false);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestReleaseWithoutCommitUnbound() {
|
||||
return TestReleaseWithoutCommitInternal(false);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestCommitTwoTimesWithoutChangeUnbound() {
|
||||
return TestCommitTwoTimesWithoutChangeInternal(false);
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestGeneralUnbound() {
|
||||
return TestGeneralInternal(false);
|
||||
}
|
||||
|
||||
// TODO(penghuang): refactor common part in all tests to a member function.
|
||||
std::string TestCompositor::TestBindUnbind() {
|
||||
// Setup GLES2
|
||||
const int32_t attribs[] = {
|
||||
PP_GRAPHICS3DATTRIB_WIDTH, 16,
|
||||
PP_GRAPHICS3DATTRIB_HEIGHT, 16,
|
||||
PP_GRAPHICS3DATTRIB_NONE
|
||||
};
|
||||
pp::Graphics3D graphics_3d(instance_, attribs);
|
||||
ASSERT_FALSE(graphics_3d.is_null());
|
||||
glSetCurrentContextPPAPI(graphics_3d.pp_resource());
|
||||
|
||||
pp::Compositor compositor = pp::Compositor(instance_);
|
||||
ASSERT_FALSE(compositor.is_null());
|
||||
|
||||
// Add layers on an unbound compositor.
|
||||
pp::CompositorLayer color_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(color_layer.is_null());
|
||||
|
||||
VERIFY(SetColorLayer(color_layer, PP_OK));
|
||||
|
||||
uint32_t texture = 0;
|
||||
VERIFY(CreateTexture(&texture));
|
||||
pp::CompositorLayer texture_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(texture_layer.is_null());
|
||||
TestCompletionCallback texture_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture,
|
||||
pp::Size(100, 100),
|
||||
texture_release_callback.GetCallback()));
|
||||
|
||||
pp::ImageData image;
|
||||
VERIFY(CreateImage(&image));
|
||||
pp::CompositorLayer image_layer = compositor.AddLayer();
|
||||
TestCompletionCallback image_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
image_layer.SetImage(image, pp::Size(100, 100),
|
||||
image_release_callback.GetCallback()));
|
||||
|
||||
// Commit layers to the chromium compositor.
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// Bind the compositor and call CommitLayers() again.
|
||||
ASSERT_TRUE(instance_->BindGraphics(compositor));
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// Unbind the compositor and call CommitLayers() again.
|
||||
ASSERT_TRUE(instance_->BindGraphics(pp::Compositor()));
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// Reset layers and call CommitLayers() again.
|
||||
ASSERT_EQ(PP_OK, compositor.ResetLayers());
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
texture_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_OK, texture_release_callback.result());
|
||||
ReleaseTexture(texture);
|
||||
|
||||
image_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_OK, image_release_callback.result());
|
||||
|
||||
// Reset
|
||||
glSetCurrentContextPPAPI(0);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestReleaseInternal(bool bind) {
|
||||
// Setup GLES2
|
||||
const int32_t attribs[] = {
|
||||
PP_GRAPHICS3DATTRIB_WIDTH, 16,
|
||||
PP_GRAPHICS3DATTRIB_HEIGHT, 16,
|
||||
PP_GRAPHICS3DATTRIB_NONE
|
||||
};
|
||||
pp::Graphics3D graphics_3d(instance_, attribs);
|
||||
ASSERT_FALSE(graphics_3d.is_null());
|
||||
glSetCurrentContextPPAPI(graphics_3d.pp_resource());
|
||||
|
||||
pp::Compositor compositor = pp::Compositor(instance_);
|
||||
ASSERT_FALSE(compositor.is_null());
|
||||
|
||||
// Bind the compositor to the instance
|
||||
if (bind)
|
||||
ASSERT_TRUE(instance_->BindGraphics(compositor));
|
||||
|
||||
pp::CompositorLayer color_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(color_layer.is_null());
|
||||
|
||||
VERIFY(SetColorLayer(color_layer, PP_OK));
|
||||
|
||||
uint32_t texture = 0;
|
||||
VERIFY(CreateTexture(&texture));
|
||||
pp::CompositorLayer texture_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(texture_layer.is_null());
|
||||
TestCompletionCallback texture_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture,
|
||||
pp::Size(100, 100),
|
||||
texture_release_callback.GetCallback()));
|
||||
|
||||
pp::ImageData image;
|
||||
VERIFY(CreateImage(&image));
|
||||
pp::CompositorLayer image_layer = compositor.AddLayer();
|
||||
TestCompletionCallback image_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
image_layer.SetImage(image, pp::Size(100, 100),
|
||||
image_release_callback.GetCallback()));
|
||||
|
||||
// Commit layers to the chromium compositor.
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// Release the compositor, and then release_callback will be aborted.
|
||||
compositor = pp::Compositor();
|
||||
|
||||
texture_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_ERROR_ABORTED, texture_release_callback.result());
|
||||
ReleaseTexture(texture);
|
||||
|
||||
image_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_ERROR_ABORTED, image_release_callback.result());
|
||||
|
||||
// Reset
|
||||
glSetCurrentContextPPAPI(0);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestReleaseWithoutCommitInternal(bool bind) {
|
||||
// Setup GLES2
|
||||
const int32_t attribs[] = {
|
||||
PP_GRAPHICS3DATTRIB_WIDTH, 16,
|
||||
PP_GRAPHICS3DATTRIB_HEIGHT, 16,
|
||||
PP_GRAPHICS3DATTRIB_NONE
|
||||
};
|
||||
pp::Graphics3D graphics_3d(instance_, attribs);
|
||||
ASSERT_FALSE(graphics_3d.is_null());
|
||||
glSetCurrentContextPPAPI(graphics_3d.pp_resource());
|
||||
|
||||
pp::Compositor compositor = pp::Compositor(instance_);
|
||||
ASSERT_FALSE(compositor.is_null());
|
||||
|
||||
// Bind the compositor to the instance
|
||||
if (bind)
|
||||
ASSERT_TRUE(instance_->BindGraphics(compositor));
|
||||
|
||||
pp::CompositorLayer color_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(color_layer.is_null());
|
||||
|
||||
VERIFY(SetColorLayer(color_layer, PP_OK));
|
||||
|
||||
uint32_t texture = 0;
|
||||
VERIFY(CreateTexture(&texture));
|
||||
pp::CompositorLayer texture_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(texture_layer.is_null());
|
||||
TestCompletionCallback texture_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture,
|
||||
pp::Size(100, 100),
|
||||
texture_release_callback.GetCallback()));
|
||||
|
||||
pp::ImageData image;
|
||||
VERIFY(CreateImage(&image));
|
||||
pp::CompositorLayer image_layer = compositor.AddLayer();
|
||||
TestCompletionCallback image_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
image_layer.SetImage(image, pp::Size(100, 100),
|
||||
image_release_callback.GetCallback()));
|
||||
|
||||
// Release the compositor, and then release_callback will be aborted.
|
||||
compositor = pp::Compositor();
|
||||
|
||||
// All release_callbacks should be called.
|
||||
texture_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_ERROR_ABORTED, texture_release_callback.result());
|
||||
ReleaseTexture(texture);
|
||||
|
||||
image_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_ERROR_ABORTED, image_release_callback.result());
|
||||
|
||||
// The layer associated to the compositor will become invalidated.
|
||||
VERIFY(SetColorLayer(color_layer, PP_ERROR_BADRESOURCE));
|
||||
|
||||
// Reset
|
||||
glSetCurrentContextPPAPI(0);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestCommitTwoTimesWithoutChangeInternal(bool bind) {
|
||||
pp::Compositor compositor(instance_);
|
||||
ASSERT_FALSE(compositor.is_null());
|
||||
if (bind)
|
||||
ASSERT_TRUE(instance_->BindGraphics(compositor));
|
||||
pp::CompositorLayer layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(layer.is_null());
|
||||
VERIFY(SetColorLayer(layer, PP_OK));
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// CommitLayers() without any change.
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestCompositor::TestGeneralInternal(bool bind) {
|
||||
// Setup GLES2
|
||||
const int32_t attribs[] = {
|
||||
PP_GRAPHICS3DATTRIB_WIDTH, 16,
|
||||
PP_GRAPHICS3DATTRIB_HEIGHT, 16,
|
||||
PP_GRAPHICS3DATTRIB_NONE
|
||||
};
|
||||
pp::Graphics3D graphics_3d(instance_, attribs);
|
||||
ASSERT_FALSE(graphics_3d.is_null());
|
||||
glSetCurrentContextPPAPI(graphics_3d.pp_resource());
|
||||
|
||||
// All functions should work with a bound compositor
|
||||
pp::Compositor compositor(instance_);
|
||||
ASSERT_FALSE(compositor.is_null());
|
||||
if (bind)
|
||||
ASSERT_TRUE(instance_->BindGraphics(compositor));
|
||||
|
||||
pp::CompositorLayer color_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(color_layer.is_null());
|
||||
VERIFY(SetColorLayer(color_layer, PP_OK));
|
||||
|
||||
uint32_t texture = 0;
|
||||
VERIFY(CreateTexture(&texture));
|
||||
pp::CompositorLayer texture_layer = compositor.AddLayer();
|
||||
ASSERT_FALSE(texture_layer.is_null());
|
||||
TestCompletionCallback texture_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
texture_layer.SetTexture(graphics_3d, texture, GL_TEXTURE_2D,
|
||||
pp::Size(100, 100),
|
||||
texture_release_callback.GetCallback()));
|
||||
|
||||
pp::ImageData image;
|
||||
VERIFY(CreateImage(&image));
|
||||
pp::CompositorLayer image_layer = compositor.AddLayer();
|
||||
TestCompletionCallback image_release_callback(instance_->pp_instance(),
|
||||
PP_REQUIRED);
|
||||
ASSERT_EQ(PP_OK_COMPLETIONPENDING,
|
||||
image_layer.SetImage(image, pp::Size(100, 100),
|
||||
image_release_callback.GetCallback()));
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
// After ResetLayers(), all layers should be invalidated.
|
||||
ASSERT_EQ(PP_OK, compositor.ResetLayers());
|
||||
VERIFY(SetColorLayer(color_layer, PP_ERROR_BADRESOURCE));
|
||||
|
||||
// Commit empty layer stack to the chromium compositor, and then the texture
|
||||
// and the image will be released by the chromium compositor soon.
|
||||
callback.WaitForResult(compositor.CommitLayers(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
texture_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_OK, texture_release_callback.result());
|
||||
ReleaseTexture(texture);
|
||||
|
||||
image_release_callback.WaitForResult(PP_OK_COMPLETIONPENDING);
|
||||
ASSERT_EQ(PP_OK, image_release_callback.result());
|
||||
|
||||
// Reset
|
||||
glSetCurrentContextPPAPI(0);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestCompositor::CreateTexture(uint32_t* texture) {
|
||||
glGenTextures(1, texture);
|
||||
ASSERT_NE(0, *texture);
|
||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 400, 400, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string TestCompositor::ReleaseTexture(uint32_t texture) {
|
||||
ASSERT_NE(0u, texture);
|
||||
glDeleteTextures(1, &texture);
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string TestCompositor::CreateImage(pp::ImageData* image) {
|
||||
*image = pp::ImageData(instance_, PP_IMAGEDATAFORMAT_RGBA_PREMUL,
|
||||
pp::Size(400, 400), false);
|
||||
ASSERT_FALSE(image->is_null());
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string TestCompositor::SetColorLayer(
|
||||
pp::CompositorLayer layer, int32_t result) {
|
||||
ASSERT_EQ(result, layer.SetColor(255, 255, 255, 255, pp::Size(100, 100)));
|
||||
ASSERT_EQ(result, layer.SetClipRect(pp::Rect(0, 0, 50, 50)));
|
||||
ASSERT_EQ(result, layer.SetTransform(kMatrix));
|
||||
ASSERT_EQ(result, layer.SetOpacity(128));
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PAPPI_TESTS_TEST_COMPOSITOR_H_
|
||||
#define PAPPI_TESTS_TEST_COMPOSITOR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "ppapi/cpp/compositor.h"
|
||||
#include "ppapi/cpp/compositor_layer.h"
|
||||
#include "ppapi/cpp/graphics_3d.h"
|
||||
#include "ppapi/lib/gl/include/GLES2/gl2.h"
|
||||
#include "ppapi/tests/test_case.h"
|
||||
|
||||
class TestCompositor : public TestCase {
|
||||
public:
|
||||
TestCompositor(TestingInstance* instance) : TestCase(instance) {}
|
||||
|
||||
// TestCase implementation.
|
||||
virtual bool Init();
|
||||
virtual void RunTests(const std::string& filter);
|
||||
|
||||
private:
|
||||
// Various tests.
|
||||
std::string TestRelease();
|
||||
std::string TestReleaseWithoutCommit();
|
||||
std::string TestCommitTwoTimesWithoutChange();
|
||||
std::string TestGeneral();
|
||||
|
||||
std::string TestReleaseUnbound();
|
||||
std::string TestReleaseWithoutCommitUnbound();
|
||||
std::string TestCommitTwoTimesWithoutChangeUnbound();
|
||||
std::string TestGeneralUnbound();
|
||||
|
||||
std::string TestBindUnbind();
|
||||
|
||||
std::string TestReleaseInternal(bool bind);
|
||||
std::string TestReleaseWithoutCommitInternal(bool bind);
|
||||
std::string TestCommitTwoTimesWithoutChangeInternal(bool bind);
|
||||
std::string TestGeneralInternal(bool bind);
|
||||
|
||||
// Helper functions
|
||||
std::string CreateTexture(uint32_t* texture);
|
||||
std::string ReleaseTexture(uint32_t texture);
|
||||
std::string CreateImage(pp::ImageData* image);
|
||||
std::string SetColorLayer(pp::CompositorLayer layer, int32_t result);
|
||||
|
||||
};
|
||||
|
||||
#endif // PAPPI_TESTS_TEST_COMPOSItor_H_
|
@ -40,10 +40,6 @@ source_set("thunk") {
|
||||
"ppb_camera_capabilities_private_thunk.cc",
|
||||
"ppb_camera_device_api.h",
|
||||
"ppb_camera_device_private_thunk.cc",
|
||||
"ppb_compositor_api.h",
|
||||
"ppb_compositor_layer_api.h",
|
||||
"ppb_compositor_layer_thunk.cc",
|
||||
"ppb_compositor_thunk.cc",
|
||||
"ppb_console_thunk.cc",
|
||||
"ppb_cursor_control_thunk.cc",
|
||||
"ppb_device_ref_api.h",
|
||||
|
@ -5,13 +5,12 @@
|
||||
// Please see inteface_ppb_public_stable for the documentation on the format of
|
||||
// this file.
|
||||
|
||||
// no-include-guard-because-multiply-included
|
||||
|
||||
#include "ppapi/thunk/interfaces_preamble.h"
|
||||
|
||||
// Interfaces go here.
|
||||
PROXIED_IFACE(PPB_AUDIOENCODER_INTERFACE_0_1, PPB_AudioEncoder_0_1)
|
||||
PROXIED_IFACE(PPB_COMPOSITOR_INTERFACE_0_1, PPB_Compositor_0_1)
|
||||
PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_1, PPB_CompositorLayer_0_1)
|
||||
PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_2, PPB_CompositorLayer_0_2)
|
||||
PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1)
|
||||
PROXIED_IFACE(PPB_VIDEOENCODER_INTERFACE_0_1, PPB_VideoEncoder_0_1)
|
||||
PROXIED_IFACE(PPB_VPNPROVIDER_INTERFACE_0_1, PPB_VpnProvider_0_1)
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_THUNK_PPB_COMPOSITOR_API_H_
|
||||
#define PPAPI_THUNK_PPB_COMPOSITOR_API_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/shared_impl/tracked_callback.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace thunk {
|
||||
|
||||
class PPAPI_THUNK_EXPORT PPB_Compositor_API {
|
||||
public:
|
||||
virtual ~PPB_Compositor_API() {}
|
||||
virtual PP_Resource AddLayer() = 0;
|
||||
virtual int32_t CommitLayers(
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) = 0;
|
||||
virtual int32_t ResetLayers() = 0;
|
||||
};
|
||||
|
||||
} // namespace thunk
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_THUNK_PPB_COMPOSITOR_API_H_
|
@ -1,51 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PPAPI_THUNK_PPB_COMPOSITOR_LAYER_API_H_
|
||||
#define PPAPI_THUNK_PPB_COMPOSITOR_LAYER_API_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/shared_impl/tracked_callback.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace thunk {
|
||||
|
||||
class PPAPI_THUNK_EXPORT PPB_CompositorLayer_API {
|
||||
public:
|
||||
virtual ~PPB_CompositorLayer_API() {}
|
||||
virtual int32_t SetColor(float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const PP_Size* size) = 0;
|
||||
virtual int32_t SetTexture0_1(
|
||||
PP_Resource context,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) = 0;
|
||||
virtual int32_t SetTexture(
|
||||
PP_Resource context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) = 0;
|
||||
virtual int32_t SetImage(
|
||||
PP_Resource image_data,
|
||||
const PP_Size* size,
|
||||
const scoped_refptr<ppapi::TrackedCallback>& callback) = 0;
|
||||
virtual int32_t SetClipRect(const PP_Rect* rects) = 0;
|
||||
virtual int32_t SetTransform(const float matrix[16]) = 0;
|
||||
virtual int32_t SetOpacity(float opacity) = 0;
|
||||
virtual int32_t SetBlendMode(PP_BlendMode mode) = 0;
|
||||
virtual int32_t SetSourceRect(const PP_FloatRect* rect) = 0;
|
||||
virtual int32_t SetPremultipliedAlpha(PP_Bool premult) = 0;
|
||||
};
|
||||
|
||||
} // namespace thunk
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_THUNK_PPB_COMPOSITOR_API_H_
|
@ -1,155 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// From ppb_compositor_layer.idl modified Wed Jan 27 17:10:16 2016.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ppapi/c/pp_completion_callback.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/ppb_compositor_layer.h"
|
||||
#include "ppapi/shared_impl/tracked_callback.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppapi_thunk_export.h"
|
||||
#include "ppapi/thunk/ppb_compositor_layer_api.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace thunk {
|
||||
|
||||
namespace {
|
||||
|
||||
PP_Bool IsCompositorLayer(PP_Resource resource) {
|
||||
VLOG(4) << "PPB_CompositorLayer::IsCompositorLayer()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(resource, false);
|
||||
return PP_FromBool(enter.succeeded());
|
||||
}
|
||||
|
||||
int32_t SetColor(PP_Resource layer,
|
||||
float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha,
|
||||
const struct PP_Size* size) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetColor()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetColor(red, green, blue, alpha, size);
|
||||
}
|
||||
|
||||
int32_t SetTexture_0_1(PP_Resource layer,
|
||||
PP_Resource context,
|
||||
uint32_t texture,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetTexture_0_1()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.SetResult(
|
||||
enter.object()->SetTexture0_1(context, texture, size, enter.callback()));
|
||||
}
|
||||
|
||||
int32_t SetTexture(PP_Resource layer,
|
||||
PP_Resource context,
|
||||
uint32_t target,
|
||||
uint32_t texture,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetTexture()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.SetResult(enter.object()->SetTexture(context, target, texture,
|
||||
size, enter.callback()));
|
||||
}
|
||||
|
||||
int32_t SetImage(PP_Resource layer,
|
||||
PP_Resource image_data,
|
||||
const struct PP_Size* size,
|
||||
struct PP_CompletionCallback cc) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetImage()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.SetResult(
|
||||
enter.object()->SetImage(image_data, size, enter.callback()));
|
||||
}
|
||||
|
||||
int32_t SetClipRect(PP_Resource layer, const struct PP_Rect* rect) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetClipRect()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetClipRect(rect);
|
||||
}
|
||||
|
||||
int32_t SetTransform(PP_Resource layer, const float matrix[16]) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetTransform()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetTransform(matrix);
|
||||
}
|
||||
|
||||
int32_t SetOpacity(PP_Resource layer, float opacity) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetOpacity()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetOpacity(opacity);
|
||||
}
|
||||
|
||||
int32_t SetBlendMode(PP_Resource layer, PP_BlendMode mode) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetBlendMode()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetBlendMode(mode);
|
||||
}
|
||||
|
||||
int32_t SetSourceRect(PP_Resource layer, const struct PP_FloatRect* rect) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetSourceRect()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetSourceRect(rect);
|
||||
}
|
||||
|
||||
int32_t SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) {
|
||||
VLOG(4) << "PPB_CompositorLayer::SetPremultipliedAlpha()";
|
||||
EnterResource<PPB_CompositorLayer_API> enter(layer, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->SetPremultipliedAlpha(premult);
|
||||
}
|
||||
|
||||
const PPB_CompositorLayer_0_1 g_ppb_compositorlayer_thunk_0_1 = {
|
||||
&IsCompositorLayer, &SetColor,
|
||||
&SetTexture_0_1, &SetImage,
|
||||
&SetClipRect, &SetTransform,
|
||||
&SetOpacity, &SetBlendMode,
|
||||
&SetSourceRect, &SetPremultipliedAlpha};
|
||||
|
||||
const PPB_CompositorLayer_0_2 g_ppb_compositorlayer_thunk_0_2 = {
|
||||
&IsCompositorLayer, &SetColor,
|
||||
&SetTexture, &SetImage,
|
||||
&SetClipRect, &SetTransform,
|
||||
&SetOpacity, &SetBlendMode,
|
||||
&SetSourceRect, &SetPremultipliedAlpha};
|
||||
|
||||
} // namespace
|
||||
|
||||
PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_1*
|
||||
GetPPB_CompositorLayer_0_1_Thunk() {
|
||||
return &g_ppb_compositorlayer_thunk_0_1;
|
||||
}
|
||||
|
||||
PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_2*
|
||||
GetPPB_CompositorLayer_0_2_Thunk() {
|
||||
return &g_ppb_compositorlayer_thunk_0_2;
|
||||
}
|
||||
|
||||
} // namespace thunk
|
||||
} // namespace ppapi
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// From ppb_compositor.idl modified Wed Jan 27 17:39:22 2016.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ppapi/c/pp_completion_callback.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/ppb_compositor.h"
|
||||
#include "ppapi/shared_impl/tracked_callback.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppapi_thunk_export.h"
|
||||
#include "ppapi/thunk/ppb_compositor_api.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace thunk {
|
||||
|
||||
namespace {
|
||||
|
||||
PP_Bool IsCompositor(PP_Resource resource) {
|
||||
VLOG(4) << "PPB_Compositor::IsCompositor()";
|
||||
EnterResource<PPB_Compositor_API> enter(resource, false);
|
||||
return PP_FromBool(enter.succeeded());
|
||||
}
|
||||
|
||||
PP_Resource Create(PP_Instance instance) {
|
||||
VLOG(4) << "PPB_Compositor::Create()";
|
||||
EnterResourceCreation enter(instance);
|
||||
if (enter.failed())
|
||||
return 0;
|
||||
return enter.functions()->CreateCompositor(instance);
|
||||
}
|
||||
|
||||
PP_Resource AddLayer(PP_Resource compositor) {
|
||||
VLOG(4) << "PPB_Compositor::AddLayer()";
|
||||
EnterResource<PPB_Compositor_API> enter(compositor, true);
|
||||
if (enter.failed())
|
||||
return 0;
|
||||
return enter.object()->AddLayer();
|
||||
}
|
||||
|
||||
int32_t CommitLayers(PP_Resource compositor, struct PP_CompletionCallback cc) {
|
||||
VLOG(4) << "PPB_Compositor::CommitLayers()";
|
||||
EnterResource<PPB_Compositor_API> enter(compositor, cc, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.SetResult(enter.object()->CommitLayers(enter.callback()));
|
||||
}
|
||||
|
||||
int32_t ResetLayers(PP_Resource compositor) {
|
||||
VLOG(4) << "PPB_Compositor::ResetLayers()";
|
||||
EnterResource<PPB_Compositor_API> enter(compositor, true);
|
||||
if (enter.failed())
|
||||
return enter.retval();
|
||||
return enter.object()->ResetLayers();
|
||||
}
|
||||
|
||||
const PPB_Compositor_0_1 g_ppb_compositor_thunk_0_1 = {
|
||||
&IsCompositor, &Create, &AddLayer, &CommitLayers, &ResetLayers};
|
||||
|
||||
} // namespace
|
||||
|
||||
PPAPI_THUNK_EXPORT const PPB_Compositor_0_1* GetPPB_Compositor_0_1_Thunk() {
|
||||
return &g_ppb_compositor_thunk_0_1;
|
||||
}
|
||||
|
||||
} // namespace thunk
|
||||
} // namespace ppapi
|
@ -133,7 +133,6 @@ class ResourceCreationAPI {
|
||||
PP_AudioSampleRate sample_rate,
|
||||
uint32_t sample_frame_count) = 0;
|
||||
virtual PP_Resource CreateCameraDevicePrivate(PP_Instance instance) = 0;
|
||||
virtual PP_Resource CreateCompositor(PP_Instance instance) = 0;
|
||||
virtual PP_Resource CreateFileChooser(PP_Instance instance,
|
||||
PP_FileChooserMode_Dev mode,
|
||||
const PP_Var& accept_types) = 0;
|
||||
|
@ -41584,7 +41584,7 @@ Called by update_net_trust_anchors.py.-->
|
||||
<int value="8760108" label="PPB_Testing_Private;1.0"/>
|
||||
<int value="10714106" label="PPB_OutputProtection_Private;0.1"/>
|
||||
<int value="11143977" label="PPB_PlatformVerification_Private;0.2"/>
|
||||
<int value="12033600" label="PPB_Compositor;0.1"/>
|
||||
<int value="12033600" label="PPB_Compositor;0.1 (Removed)"/>
|
||||
<int value="13662160" label="PPB_CharSet(Dev);0.4"/>
|
||||
<int value="22816901" label="PPB_FileChooser(Dev);0.5"/>
|
||||
<int value="28187368" label="PPB_IMEInputEvent(Dev);0.2"/>
|
||||
@ -41603,14 +41603,14 @@ Called by update_net_trust_anchors.py.-->
|
||||
<int value="156766028" label="PPB_UMA_Private;0.3"/>
|
||||
<int value="162107265" label="PPB_NetworkMonitor;1.0"/>
|
||||
<int value="180906214" label="PPB_Instance_Private;0.1"/>
|
||||
<int value="206043276" label="PPB_CompositorLayer;0.1"/>
|
||||
<int value="206043276" label="PPB_CompositorLayer;0.1 (Removed)"/>
|
||||
<int value="221802429" label="PPB_URLUtil(Dev);0.7"/>
|
||||
<int value="225125520" label="PPB_Find(Private);0.3"/>
|
||||
<int value="226206264" label="PPB_FileRef;1.1"/>
|
||||
<int value="229560990" label="PPB_Var(Deprecated);0.3"/>
|
||||
<int value="250764663" label="PPB_Graphics2D(Dev);0.2"/>
|
||||
<int value="320267009" label="PPB_Flash_File_ModuleLocal;3"/>
|
||||
<int value="344923193" label="PPB_CompositorLayer;0.2"/>
|
||||
<int value="344923193" label="PPB_CompositorLayer;0.2 (Removed)"/>
|
||||
<int value="348907389" label="PPB_TCPSocket_Private;0.4"/>
|
||||
<int value="382780521" label="PPB_FileRef;1.2"/>
|
||||
<int value="415548516" label="PPB_MessageLoop;1.0"/>
|
||||
|
Reference in New Issue
Block a user