summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 08:38:41 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 08:38:41 +0000
commitf53da3970187a0ac5592b849ea44c5e2e8a0470b (patch)
tree3461669fca9b71ba761dce89e593b4dd7ca9e4df /cc
parent1b2545f9c8087aa782e3615e27b0881635c0ce8d (diff)
downloadchromium_src-f53da3970187a0ac5592b849ea44c5e2e8a0470b.zip
chromium_src-f53da3970187a0ac5592b849ea44c5e2e8a0470b.tar.gz
chromium_src-f53da3970187a0ac5592b849ea44c5e2e8a0470b.tar.bz2
cc: Chromify ResourceProvider.
Style-only change. Make the ResourceProvider class match chromium style. R=piman Review URL: https://chromiumcodereview.appspot.com/12468009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/delegated_renderer_layer_impl.cc12
-rw-r--r--cc/delegating_renderer.cc14
-rw-r--r--cc/gl_renderer.cc40
-rw-r--r--cc/gl_renderer_pixeltest.cc2
-rw-r--r--cc/gl_renderer_unittest.cc22
-rw-r--r--cc/heads_up_display_layer_impl.cc10
-rw-r--r--cc/io_surface_layer_impl.cc2
-rw-r--r--cc/layer_tree_host_impl.cc4
-rw-r--r--cc/layer_tree_host_impl_unittest.cc16
-rw-r--r--cc/layer_tree_host_unittest.cc2
-rw-r--r--cc/layer_tree_host_unittest_context.cc8
-rw-r--r--cc/layer_tree_host_unittest_delegated.cc24
-rw-r--r--cc/nine_patch_layer_unittest.cc2
-rw-r--r--cc/picture_layer_tiling_set_unittest.cc4
-rw-r--r--cc/prioritized_resource.cc4
-rw-r--r--cc/prioritized_resource_manager.cc4
-rw-r--r--cc/prioritized_resource_unittest.cc2
-rw-r--r--cc/resource_pool.cc8
-rw-r--r--cc/resource_provider.cc2181
-rw-r--r--cc/resource_provider.h653
-rw-r--r--cc/resource_provider_unittest.cc200
-rw-r--r--cc/resource_update_controller.cc22
-rw-r--r--cc/resource_update_controller_unittest.cc2
-rw-r--r--cc/scoped_resource.cc4
-rw-r--r--cc/scoped_resource_unittest.cc30
-rw-r--r--cc/single_thread_proxy.cc6
-rw-r--r--cc/software_renderer.cc18
-rw-r--r--cc/software_renderer_unittest.cc10
-rw-r--r--cc/test/render_pass_test_common.cc44
-rw-r--r--cc/texture_layer_impl.cc10
-rw-r--r--cc/texture_layer_unittest.cc12
-rw-r--r--cc/thread_proxy.cc6
-rw-r--r--cc/tile_manager.cc20
-rw-r--r--cc/tiled_layer_unittest.cc2
-rw-r--r--cc/video_layer_impl.cc18
35 files changed, 1750 insertions, 1668 deletions
diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc
index 4b9b38a..55443e0 100644
--- a/cc/delegated_renderer_layer_impl.cc
+++ b/cc/delegated_renderer_layer_impl.cc
@@ -65,7 +65,7 @@ void DelegatedRendererLayerImpl::SetFrameData(
ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
const ResourceProvider::ResourceIdMap& resource_map =
- resource_provider->getChildToParentMap(child_id_);
+ resource_provider->GetChildToParentMap(child_id_);
if (frame_data) {
// A frame with an empty root render pass is invalid.
@@ -83,7 +83,7 @@ void DelegatedRendererLayerImpl::SetFrameData(
setUpdateRect(gfx::UnionRects(updateRect(), damage_in_layer));
}
- resource_provider->receiveFromChild(child_id_, frame_data->resource_list);
+ resource_provider->ReceiveFromChild(child_id_, frame_data->resource_list);
bool invalid_frame = false;
ResourceProvider::ResourceIdSet used_resources;
@@ -114,11 +114,11 @@ void DelegatedRendererLayerImpl::SetFrameData(
it != resource_map.end();
++it) {
bool resource_is_in_current_frame = resources_.count(it->second);
- bool resource_is_in_use = resource_provider->inUseByConsumer(it->second);
+ bool resource_is_in_use = resource_provider->InUseByConsumer(it->second);
if (!resource_is_in_current_frame && !resource_is_in_use)
unused_resources.push_back(it->second);
}
- resource_provider->prepareSendToChild(
+ resource_provider->PrepareSendToChild(
child_id_, unused_resources, resources_for_ack);
}
@@ -334,7 +334,7 @@ void DelegatedRendererLayerImpl::CreateChildIdIfNeeded() {
return;
ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
- child_id_ = resource_provider->createChild();
+ child_id_ = resource_provider->CreateChild();
}
void DelegatedRendererLayerImpl::ClearChildId() {
@@ -342,7 +342,7 @@ void DelegatedRendererLayerImpl::ClearChildId() {
return;
ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
- resource_provider->destroyChild(child_id_);
+ resource_provider->DestroyChild(child_id_);
child_id_ = 0;
}
diff --git a/cc/delegating_renderer.cc b/cc/delegating_renderer.cc
index 2537a37..f36a21d 100644
--- a/cc/delegating_renderer.cc
+++ b/cc/delegating_renderer.cc
@@ -56,11 +56,11 @@ bool DelegatingRenderer::Initialize() {
// but the parent compositor may pipeline for us.
// TODO(danakj): Can we use this in single-thread mode?
capabilities_.usingSwapCompleteCallback = true;
- capabilities_.maxTextureSize = resource_provider_->maxTextureSize();
- capabilities_.bestTextureFormat = resource_provider_->bestTextureFormat();
+ capabilities_.maxTextureSize = resource_provider_->max_texture_size();
+ capabilities_.bestTextureFormat = resource_provider_->best_texture_format();
capabilities_.allowPartialTextureUpdates = false;
- WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D();
+ WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D();
if (!context3d) {
// Software compositing.
@@ -122,7 +122,7 @@ bool DelegatingRenderer::Initialize() {
}
DelegatingRenderer::~DelegatingRenderer() {
- WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D();
+ WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D();
if (context3d)
context3d->setContextLostCallback(NULL);
}
@@ -160,7 +160,7 @@ void DelegatingRenderer::drawFrame(
// Move the render passes and resources into the |out_frame|.
DelegatedFrameData& out_data = *out_frame.delegated_frame_data;
out_data.render_pass_list.swap(render_passes_in_draw_order);
- resource_provider_->prepareSendToParent(resources, &out_data.resource_list);
+ resource_provider_->PrepareSendToParent(resources, &out_data.resource_list);
output_surface_->SendFrameToParentCompositor(&out_frame);
}
@@ -176,14 +176,14 @@ void DelegatingRenderer::getFramebufferPixels(void *pixels,
void DelegatingRenderer::receiveCompositorFrameAck(
const CompositorFrameAck& ack) {
- resource_provider_->receiveFromParent(ack.resources);
+ resource_provider_->ReceiveFromParent(ack.resources);
if (m_client->hasImplThread())
m_client->onSwapBuffersComplete();
}
bool DelegatingRenderer::isContextLost() {
- WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D();
+ WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D();
if (!context3d)
return false;
return context3d->getGraphicsResetStatusARB() != GL_NO_ERROR;
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index fc30278..7db40b8 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -61,7 +61,7 @@ namespace {
class SimpleSwapFence : public ResourceProvider::Fence {
public:
SimpleSwapFence() : m_hasPassed(false) {}
- virtual bool hasPassed() OVERRIDE { return m_hasPassed; }
+ virtual bool HasPassed() OVERRIDE { return m_hasPassed; }
void setHasPassed() { m_hasPassed = true; }
private:
virtual ~SimpleSwapFence() {}
@@ -145,8 +145,8 @@ bool GLRenderer::initialize()
m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external");
- m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize();
- m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat();
+ m_capabilities.maxTextureSize = m_resourceProvider->max_texture_size();
+ m_capabilities.bestTextureFormat = m_resourceProvider->best_texture_format();
// The updater can access textures while the GLRenderer is using them.
m_capabilities.allowPartialTextureUpdates = true;
@@ -382,7 +382,7 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
if (filters.isEmpty())
return SkBitmap();
- cc::ContextProvider* offscreenContexts = renderer->resourceProvider()->offscreenContextProvider();
+ cc::ContextProvider* offscreenContexts = renderer->resourceProvider()->offscreen_context_provider();
if (!offscreenContexts || !offscreenContexts->Context3d() || !offscreenContexts->GrContext())
return SkBitmap();
@@ -391,12 +391,12 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
// Flush the compositor context to ensure that textures there are available
// in the shared context. Do this after locking/creating the compositor
// texture.
- renderer->resourceProvider()->flush();
+ renderer->resourceProvider()->Flush();
// Make sure skia uses the correct GL context.
offscreenContexts->Context3d()->makeContextCurrent();
- SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sourceTextureResource->size(), offscreenContexts->GrContext());
+ SkBitmap source = RenderSurfaceFilters::apply(filters, lock.texture_id(), sourceTextureResource->size(), offscreenContexts->GrContext());
// Flush skia context so that all the rendered stuff appears on the
// texture.
@@ -407,7 +407,7 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
offscreenContexts->Context3d()->flush();
// Use the compositor's GL context again.
- renderer->resourceProvider()->graphicsContext3D()->makeContextCurrent();
+ renderer->resourceProvider()->GraphicsContext3D()->makeContextCurrent();
return source;
}
@@ -416,7 +416,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
if (!filter)
return SkBitmap();
- cc::ContextProvider* offscreenContexts = renderer->resourceProvider()->offscreenContextProvider();
+ cc::ContextProvider* offscreenContexts = renderer->resourceProvider()->offscreen_context_provider();
if (!offscreenContexts || !offscreenContexts->Context3d() || !offscreenContexts->GrContext())
return SkBitmap();
@@ -425,7 +425,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
// Flush the compositor context to ensure that textures there are available
// in the shared context. Do this after locking/creating the compositor
// texture.
- renderer->resourceProvider()->flush();
+ renderer->resourceProvider()->Flush();
// Make sure skia uses the correct GL context.
offscreenContexts->Context3d()->makeContextCurrent();
@@ -435,7 +435,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
backendTextureDescription.fWidth = sourceTextureResource->size().width();
backendTextureDescription.fHeight = sourceTextureResource->size().height();
backendTextureDescription.fConfig = kSkia8888_GrPixelConfig;
- backendTextureDescription.fTextureHandle = lock.textureId();
+ backendTextureDescription.fTextureHandle = lock.texture_id();
backendTextureDescription.fOrigin = kTopLeft_GrSurfaceOrigin;
skia::RefPtr<GrTexture> texture = skia::AdoptRef(offscreenContexts->GrContext()->wrapBackendTexture(backendTextureDescription));
@@ -475,7 +475,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
offscreenContexts->Context3d()->flush();
// Use the compositor's GL context again.
- renderer->resourceProvider()->graphicsContext3D()->makeContextCurrent();
+ renderer->resourceProvider()->GraphicsContext3D()->makeContextCurrent();
return device.accessBitmap(false);
}
@@ -588,7 +588,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
if (backgroundTexture) {
DCHECK(backgroundTexture->size() == quad->rect.size());
ResourceProvider::ScopedReadLockGL lock(m_resourceProvider, backgroundTexture->id());
- copyTextureToFramebuffer(frame, lock.textureId(), quad->rect, quad->quadTransform());
+ copyTextureToFramebuffer(frame, lock.texture_id(), quad->rect, quad->quadTransform());
}
bool clipped = false;
@@ -608,7 +608,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
unsigned maskTextureId = 0;
if (quad->mask_resource_id) {
maskResourceLock.reset(new ResourceProvider::ScopedReadLockGL(m_resourceProvider, quad->mask_resource_id));
- maskTextureId = maskResourceLock->textureId();
+ maskTextureId = maskResourceLock->texture_id();
}
// FIXME: use the backgroundTexture and blend the background in with this draw instead of having a separate copy of the background texture.
@@ -700,7 +700,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
quad->mask_uv_rect.x(), quad->mask_uv_rect.y()));
GLC(context(), context()->uniform2f(shaderMaskTexCoordScaleLocation,
quad->mask_uv_rect.width() / tex_scale_x, quad->mask_uv_rect.height() / tex_scale_y));
- m_resourceProvider->bindForSampling(quad->mask_resource_id, GL_TEXTURE_2D, GL_LINEAR);
+ m_resourceProvider->BindForSampling(quad->mask_resource_id, GL_TEXTURE_2D, GL_LINEAR);
GLC(context(), context()->activeTexture(GL_TEXTURE0));
}
@@ -1078,7 +1078,7 @@ void GLRenderer::flushTextureQuadCache()
// Assume the current active textures is 0.
ResourceProvider::ScopedReadLockGL lockedQuad(m_resourceProvider, m_drawCache.resource_id);
- GLC(context(), context()->bindTexture(GL_TEXTURE_2D, lockedQuad.textureId()));
+ GLC(context(), context()->bindTexture(GL_TEXTURE_2D, lockedQuad.texture_id()));
// set up premultiplied alpha.
if (!m_drawCache.use_premultiplied_alpha) {
@@ -1373,8 +1373,8 @@ bool GLRenderer::swapBuffers()
// written to after one full frame has past since it was last read.
if (m_lastSwapFence)
static_cast<SimpleSwapFence*>(m_lastSwapFence.get())->setHasPassed();
- m_lastSwapFence = m_resourceProvider->getReadLockFence();
- m_resourceProvider->setReadLockFence(new SimpleSwapFence());
+ m_lastSwapFence = m_resourceProvider->GetReadLockFence();
+ m_resourceProvider->SetReadLockFence(new SimpleSwapFence());
return true;
}
@@ -1437,7 +1437,7 @@ void GLRenderer::enforceMemoryPolicy()
releaseRenderPassTextures();
if (m_discardBackbufferWhenNotVisible)
discardBackbuffer();
- m_resourceProvider->releaseCachedData();
+ m_resourceProvider->ReleaseCachedData();
GLC(m_context, m_context->flush());
}
}
@@ -1546,7 +1546,7 @@ bool GLRenderer::getFramebufferTexture(ScopedResource* texture, const gfx::Rect&
return false;
ResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id());
- GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, lock.textureId()));
+ GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, lock.texture_id()));
GLC(m_context, m_context->copyTexImage2D(GL_TEXTURE_2D, 0, texture->format(),
deviceRect.x(), deviceRect.y(), deviceRect.width(), deviceRect.height(), 0));
return true;
@@ -1573,7 +1573,7 @@ bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResou
GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_offscreenFramebufferId));
m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL(m_resourceProvider, texture->id()));
- unsigned textureId = m_currentFramebufferLock->textureId();
+ unsigned textureId = m_currentFramebufferLock->texture_id();
GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0));
DCHECK(m_context->checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE || isContextLost());
diff --git a/cc/gl_renderer_pixeltest.cc b/cc/gl_renderer_pixeltest.cc
index 347428b..2e7838d 100644
--- a/cc/gl_renderer_pixeltest.cc
+++ b/cc/gl_renderer_pixeltest.cc
@@ -58,7 +58,7 @@ class GLRendererPixelTest : public testing::Test {
context3d->Initialize(WebKit::WebGraphicsContext3D::Attributes(), NULL);
output_surface_.reset(new OutputSurface(
context3d.PassAs<WebKit::WebGraphicsContext3D>()));
- resource_provider_ = ResourceProvider::create(output_surface_.get());
+ resource_provider_ = ResourceProvider::Create(output_surface_.get());
renderer_ = GLRenderer::create(&fake_client_,
output_surface_.get(),
resource_provider_.get());
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc
index dbf6bbd..709c63f 100644
--- a/cc/gl_renderer_unittest.cc
+++ b/cc/gl_renderer_unittest.cc
@@ -129,7 +129,7 @@ protected:
: m_suggestHaveBackbufferYes(1, true)
, m_suggestHaveBackbufferNo(1, false)
, m_outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext())))
- , m_resourceProvider(ResourceProvider::create(m_outputSurface.get()))
+ , m_resourceProvider(ResourceProvider::Create(m_outputSurface.get()))
, m_renderer(&m_mockClient, m_outputSurface.get(), m_resourceProvider.get())
{
}
@@ -311,7 +311,7 @@ TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext)));
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
EXPECT_TRUE(renderer.initialize());
@@ -354,7 +354,7 @@ TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext)));
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
renderer.initialize();
@@ -376,7 +376,7 @@ TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShoul
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
renderer.initialize();
@@ -404,7 +404,7 @@ TEST(GLRendererTest2, opaqueBackground)
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
mockClient.rootRenderPass()->has_transparent_background = false;
@@ -427,7 +427,7 @@ TEST(GLRendererTest2, transparentBackground)
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
mockClient.rootRenderPass()->has_transparent_background = true;
@@ -478,7 +478,7 @@ TEST(GLRendererTest2, visibilityChangeIsLastCall)
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext)));
VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
EXPECT_TRUE(renderer.initialize());
@@ -530,7 +530,7 @@ TEST(GLRendererTest2, activeTextureState)
FakeRendererClient fakeClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.get());
// During initialization we are allowed to set any texture parameters.
@@ -597,7 +597,7 @@ TEST(GLRendererTest2, shouldClearRootRenderPass)
NoClearRootRenderPassFakeClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext)));
NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRenderPassMockContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
EXPECT_TRUE(renderer.initialize());
@@ -666,7 +666,7 @@ private:
TEST(GLRendererTest2, scissorTestWhenClearing) {
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ScissorTestOnClearCheckingContext)));
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get());
EXPECT_TRUE(renderer.initialize());
EXPECT_FALSE(renderer.capabilities().usingPartialSwap);
@@ -735,7 +735,7 @@ class MockOutputSurfaceTest : public testing::Test,
public FakeRendererClient {
protected:
MockOutputSurfaceTest()
- : m_resourceProvider(ResourceProvider::create(&m_outputSurface))
+ : m_resourceProvider(ResourceProvider::Create(&m_outputSurface))
, m_renderer(this, &m_outputSurface, m_resourceProvider.get())
{
}
diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc
index 27f43b5..53e7b2d 100644
--- a/cc/heads_up_display_layer_impl.cc
+++ b/cc/heads_up_display_layer_impl.cc
@@ -95,16 +95,16 @@ void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider)
// TODO(danakj): Scale the HUD by deviceScale to make it more friendly under high DPI.
// TODO(danakj): The HUD could swap between two textures instead of creating a texture every frame in ubercompositor.
- if (m_hudTexture->size() != bounds() || resourceProvider->inUseByConsumer(m_hudTexture->id()))
+ if (m_hudTexture->size() != bounds() || resourceProvider->InUseByConsumer(m_hudTexture->id()))
m_hudTexture->Free();
if (!m_hudTexture->id()) {
m_hudTexture->Allocate(bounds(), GL_RGBA, ResourceProvider::TextureUsageAny);
- // TODO(epenner): This texture was being used before setPixels was called,
+ // TODO(epenner): This texture was being used before SetPixels was called,
// which is now not allowed (it's an uninitialized read). This should be fixed
// and this allocateForTesting() removed.
// http://crbug.com/166784
- resourceProvider->allocateForTesting(m_hudTexture->id());
+ resourceProvider->AllocateForTesting(m_hudTexture->id());
}
}
@@ -151,7 +151,7 @@ void HeadsUpDisplayLayerImpl::updateHudTexture(ResourceProvider* resourceProvide
gfx::Rect layerRect(gfx::Point(), bounds());
DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config);
- resourceProvider->setPixels(m_hudTexture->id(), static_cast<const uint8_t*>(bitmap->getPixels()), layerRect, layerRect, gfx::Vector2d());
+ resourceProvider->SetPixels(m_hudTexture->id(), static_cast<const uint8_t*>(bitmap->getPixels()), layerRect, layerRect, gfx::Vector2d());
}
void HeadsUpDisplayLayerImpl::didDraw(ResourceProvider* resourceProvider)
@@ -164,7 +164,7 @@ void HeadsUpDisplayLayerImpl::didDraw(ResourceProvider* resourceProvider)
// FIXME: the following assert will not be true when sending resources to a
// parent compositor. We will probably need to hold on to m_hudTexture for
// longer, and have several HUD textures in the pipeline.
- DCHECK(!resourceProvider->inUseByConsumer(m_hudTexture->id()));
+ DCHECK(!resourceProvider->InUseByConsumer(m_hudTexture->id()));
}
void HeadsUpDisplayLayerImpl::didLoseOutputSurface()
diff --git a/cc/io_surface_layer_impl.cc b/cc/io_surface_layer_impl.cc
index cc0d840..4af99c3 100644
--- a/cc/io_surface_layer_impl.cc
+++ b/cc/io_surface_layer_impl.cc
@@ -55,7 +55,7 @@ void IOSurfaceLayerImpl::willDraw(ResourceProvider* resourceProvider)
LayerImpl::willDraw(resourceProvider);
if (m_ioSurfaceChanged) {
- WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsContext3D();
+ WebKit::WebGraphicsContext3D* context3d = resourceProvider->GraphicsContext3D();
if (!context3d) {
// FIXME: Implement this path for software compositing.
return;
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 791a47a..c372d4b 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -842,7 +842,7 @@ void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame)
// Once all layers have been drawn, pending texture uploads should no
// longer block future uploads.
- m_resourceProvider->markPendingUploadsAsNonBlocking();
+ m_resourceProvider->MarkPendingUploadsAsNonBlocking();
}
void LayerTreeHostImpl::finishAllRendering()
@@ -1072,7 +1072,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa
if (!outputSurface->BindToClient(this))
return false;
- scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(outputSurface.get());
+ scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::Create(outputSurface.get());
if (!resourceProvider)
return false;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 5ca504c..168526f 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -1032,8 +1032,8 @@ private:
setTilingData(*tilingData.get());
setSkipsDraw(skipsDraw);
if (!tileMissing) {
- ResourceProvider::ResourceId resource = resourceProvider->createResource(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource);
+ ResourceProvider::ResourceId resource = resourceProvider->CreateResource(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny);
+ resourceProvider->AllocateForTesting(resource);
pushTileProperties(0, 0, resource, gfx::Rect(), false);
}
if (animating)
@@ -1778,9 +1778,9 @@ private:
, m_quadsAppended(false)
, m_quadRect(5, 5, 5, 5)
, m_quadVisibleRect(5, 5, 5, 5)
- , m_resourceId(resourceProvider->createResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny))
+ , m_resourceId(resourceProvider->CreateResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny))
{
- resourceProvider->allocateForTesting(m_resourceId);
+ resourceProvider->AllocateForTesting(m_resourceId);
setAnchorPoint(gfx::PointF(0, 0));
setBounds(gfx::Size(10, 10));
setContentBounds(gfx::Size(10, 10));
@@ -2594,16 +2594,16 @@ private:
static unsigned createResourceId(ResourceProvider* resourceProvider)
{
- return resourceProvider->createResource(
+ return resourceProvider->CreateResource(
gfx::Size(20, 12),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
}
static unsigned createTextureId(ResourceProvider* resourceProvider)
{
return ResourceProvider::ScopedReadLockGL(
- resourceProvider, createResourceId(resourceProvider)).textureId();
+ resourceProvider, createResourceId(resourceProvider)).texture_id();
}
TEST_F(LayerTreeHostImplTest, layersFreeTextures)
@@ -4027,7 +4027,7 @@ TEST_F(LayerTreeHostImplTest, testRemoveRenderPasses)
{
scoped_ptr<OutputSurface> outputSurface(createOutputSurface());
ASSERT_TRUE(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), outputSurface.get(), &m_proxy));
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 6c994a6..6dd780d 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -1524,7 +1524,7 @@ public:
virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE
{
ASSERT_TRUE(m_hasTexture);
- ASSERT_NE(0u, layerTreeImpl()->resource_provider()->numResources());
+ ASSERT_NE(0u, layerTreeImpl()->resource_provider()->num_resources());
}
void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; }
diff --git a/cc/layer_tree_host_unittest_context.cc b/cc/layer_tree_host_unittest_context.cc
index 79f1f40..2a6b2e6 100644
--- a/cc/layer_tree_host_unittest_context.cc
+++ b/cc/layer_tree_host_unittest_context.cc
@@ -430,7 +430,7 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent :
EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
cc::ContextProvider* contexts =
- host_impl->resourceProvider()->offscreenContextProvider();
+ host_impl->resourceProvider()->offscreen_context_provider();
if (use_surface_) {
EXPECT_TRUE(contexts->Context3d());
// TODO(danakj): Make a fake GrContext.
@@ -519,7 +519,7 @@ class LayerTreeHostContextTestOffscreenContextFails
virtual void drawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
cc::ContextProvider* contexts =
- host_impl->resourceProvider()->offscreenContextProvider();
+ host_impl->resourceProvider()->offscreen_context_provider();
EXPECT_FALSE(contexts);
endTest();
}
@@ -1017,14 +1017,14 @@ class LayerTreeHostContextTestDontUseLostResources :
color_video_frame_ = VideoFrame::CreateColorFrame(
gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
hw_video_frame_ = VideoFrame::WrapNativeTexture(
- resource_provider->graphicsContext3D()->createTexture(),
+ resource_provider->GraphicsContext3D()->createTexture(),
GL_TEXTURE_2D,
gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4),
base::TimeDelta(),
VideoFrame::ReadPixelsCB(),
base::Closure());
scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture(
- resource_provider->graphicsContext3D()->createTexture(),
+ resource_provider->GraphicsContext3D()->createTexture(),
GL_TEXTURE_2D,
gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4),
base::TimeDelta(),
diff --git a/cc/layer_tree_host_unittest_delegated.cc b/cc/layer_tree_host_unittest_delegated.cc
index df90a13..c44d7ed 100644
--- a/cc/layer_tree_host_unittest_delegated.cc
+++ b/cc/layer_tree_host_unittest_delegated.cc
@@ -120,7 +120,7 @@ class LayerTreeHostDelegatedTestCreateChildId
EXPECT_TRUE(delegated_impl->ChildId());
EXPECT_FALSE(did_reset_child_id_);
- host_impl->resourceProvider()->graphicsContext3D()->loseContextCHROMIUM(
+ host_impl->resourceProvider()->GraphicsContext3D()->loseContextCHROMIUM(
GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
break;
case 3:
@@ -356,7 +356,7 @@ class LayerTreeHostDelegatedTestMergeResources
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// Both frames' resources should be in the parent's resource provider.
@@ -398,7 +398,7 @@ class LayerTreeHostDelegatedTestRemapResourcesInQuads
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// The frame's resource should be in the parent's resource provider.
@@ -627,7 +627,7 @@ class LayerTreeHostDelegatedTestFrameBeforeAck
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// The bad frame should be dropped. So we should only have one quad (the
@@ -724,7 +724,7 @@ class LayerTreeHostDelegatedTestFrameBeforeTakeResources
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// The third frame has all of the resources in it again, the delegated
@@ -830,7 +830,7 @@ class LayerTreeHostDelegatedTestBadFrame
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
switch (host_impl->activeTree()->source_frame_number()) {
@@ -941,7 +941,7 @@ class LayerTreeHostDelegatedTestUnnamedResource
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// The layer only held on to the resource that was used.
@@ -1004,7 +1004,7 @@ class LayerTreeHostDelegatedTestDontLeakResource
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
// The layer only held on to the resource that was used.
@@ -1081,7 +1081,7 @@ class LayerTreeHostDelegatedTestResourceSentToParent
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
switch (host_impl->activeTree()->source_frame_number()) {
@@ -1098,7 +1098,7 @@ class LayerTreeHostDelegatedTestResourceSentToParent
ResourceProvider::ResourceIdArray resources_for_parent;
resources_for_parent.push_back(map.find(999)->second);
TransferableResourceArray transferable_resources;
- host_impl->resourceProvider()->prepareSendToParent(
+ host_impl->resourceProvider()->PrepareSendToParent(
resources_for_parent, &transferable_resources);
break;
}
@@ -1116,7 +1116,7 @@ class LayerTreeHostDelegatedTestResourceSentToParent
resource.id = map.find(999)->second;
TransferableResourceArray transferable_resources;
transferable_resources.push_back(resource);
- host_impl->resourceProvider()->receiveFromParent(
+ host_impl->resourceProvider()->ReceiveFromParent(
transferable_resources);
break;
}
@@ -1196,7 +1196,7 @@ class LayerTreeHostDelegatedTestCommitWithoutTake
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
const ResourceProvider::ResourceIdMap& map =
- host_impl->resourceProvider()->getChildToParentMap(
+ host_impl->resourceProvider()->GetChildToParentMap(
delegated_impl->ChildId());
switch (host_impl->activeTree()->source_frame_number()) {
diff --git a/cc/nine_patch_layer_unittest.cc b/cc/nine_patch_layer_unittest.cc
index b7a5bb9..8c04ea2 100644
--- a/cc/nine_patch_layer_unittest.cc
+++ b/cc/nine_patch_layer_unittest.cc
@@ -108,7 +108,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap)
DebugScopedSetImplThread implThread(proxy());
DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
outputSurface = createFakeOutputSurface();
- resourceProvider = ResourceProvider::create(outputSurface.get());
+ resourceProvider = ResourceProvider::Create(outputSurface.get());
params.texture->acquireBackingTexture(resourceProvider.get());
ASSERT_TRUE(params.texture->haveBackingTexture());
}
diff --git a/cc/picture_layer_tiling_set_unittest.cc b/cc/picture_layer_tiling_set_unittest.cc
index e3a008b..5d692a0 100644
--- a/cc/picture_layer_tiling_set_unittest.cc
+++ b/cc/picture_layer_tiling_set_unittest.cc
@@ -62,7 +62,7 @@ class PictureLayerTilingSetTestWithResources : public testing::Test {
scoped_ptr<FakeOutputSurface> output_surface =
FakeOutputSurface::Create3d();
scoped_ptr<ResourceProvider> resource_provider =
- ResourceProvider::create(output_surface.get());
+ ResourceProvider::Create(output_surface.get());
FakePictureLayerTilingClient client;
client.SetTileSize(gfx::Size(256, 256));
@@ -82,7 +82,7 @@ class PictureLayerTilingSetTestWithResources : public testing::Test {
make_scoped_ptr(new ResourcePool::Resource(
resource_provider.get(),
gfx::Size(1, 1),
- resource_provider->bestTextureFormat()));
+ resource_provider->best_texture_format()));
}
}
diff --git a/cc/prioritized_resource.cc b/cc/prioritized_resource.cc
index 4e511e4..7436a9d 100644
--- a/cc/prioritized_resource.cc
+++ b/cc/prioritized_resource.cc
@@ -95,7 +95,7 @@ void PrioritizedResource::setPixels(ResourceProvider* resourceProvider,
if (m_isAbovePriorityCutoff)
acquireBackingTexture(resourceProvider);
DCHECK(m_backing);
- resourceProvider->setPixels(resourceId(), image, imageRect, sourceRect, destOffset);
+ resourceProvider->SetPixels(resourceId(), image, imageRect, sourceRect, destOffset);
// The component order may be bgra if we uploaded bgra pixels to rgba
// texture. Mark contents as swizzled if image component order is
@@ -156,7 +156,7 @@ void PrioritizedResource::Backing::deleteResource(ResourceProvider* resourceProv
DCHECK(resourceProvider == m_resourceProvider);
#endif
- resourceProvider->deleteResource(id());
+ resourceProvider->DeleteResource(id());
set_id(0);
m_resourceHasBeenDeleted = true;
}
diff --git a/cc/prioritized_resource_manager.cc b/cc/prioritized_resource_manager.cc
index 1c5df11..009f1fc 100644
--- a/cc/prioritized_resource_manager.cc
+++ b/cc/prioritized_resource_manager.cc
@@ -219,7 +219,7 @@ void PrioritizedResourceManager::acquireBackingTextureIfNeeded(PrioritizedResour
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
if (!(*it)->canBeRecycled())
break;
- if (resourceProvider->inUseByConsumer((*it)->id()))
+ if (resourceProvider->InUseByConsumer((*it)->id()))
continue;
if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) {
backing = (*it);
@@ -413,7 +413,7 @@ PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Siz
{
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
DCHECK(resourceProvider);
- ResourceProvider::ResourceId resourceId = resourceProvider->createManagedResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceId = resourceProvider->CreateManagedResource(size, format, ResourceProvider::TextureUsageAny);
PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(resourceId, resourceProvider, size, format);
m_memoryUseBytes += backing->bytes();
return backing;
diff --git a/cc/prioritized_resource_unittest.cc b/cc/prioritized_resource_unittest.cc
index 1cc343c..79c377c 100644
--- a/cc/prioritized_resource_unittest.cc
+++ b/cc/prioritized_resource_unittest.cc
@@ -23,7 +23,7 @@ public:
, m_outputSurface(createFakeOutputSurface())
{
DebugScopedSetImplThread implThread(&m_proxy);
- m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
+ m_resourceProvider = ResourceProvider::Create(m_outputSurface.get());
}
virtual ~PrioritizedResourceTest()
diff --git a/cc/resource_pool.cc b/cc/resource_pool.cc
index 89dbb13..2b43693 100644
--- a/cc/resource_pool.cc
+++ b/cc/resource_pool.cc
@@ -11,7 +11,7 @@ namespace cc {
ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider,
const gfx::Size& size,
GLenum format)
- : cc::Resource(resource_provider->createManagedResource(
+ : cc::Resource(resource_provider->CreateManagedResource(
size,
format,
ResourceProvider::TextureUsageAny),
@@ -24,7 +24,7 @@ ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider,
ResourcePool::Resource::~Resource() {
DCHECK(id());
DCHECK(resource_provider_);
- resource_provider_->deleteResource(id());
+ resource_provider_->DeleteResource(id());
}
ResourcePool::ResourcePool(ResourceProvider* resource_provider)
@@ -46,7 +46,7 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource(
// TODO(epenner): It would be nice to DCHECK that this
// doesn't happen two frames in a row for any resource
// in this pool.
- if (!resource_provider_->canLockForWrite(resource->id()))
+ if (!resource_provider_->CanLockForWrite(resource->id()))
continue;
if (resource->size() != size)
@@ -65,7 +65,7 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource(
// Extend all read locks on all resources until the resource is
// finished being used, such that we know when resources are
// truly safe to recycle.
- resource_provider_->enableReadLockFences(resource->id(), true);
+ resource_provider_->EnableReadLockFences(resource->id(), true);
memory_usage_bytes_ += resource->bytes();
return make_scoped_ptr(resource);
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc
index 960dfaa..d556727 100644
--- a/cc/resource_provider.cc
+++ b/cc/resource_provider.cc
@@ -12,7 +12,7 @@
#include "base/string_util.h"
#include "base/strings/string_split.h"
#include "cc/context_provider.h"
-#include "cc/gl_renderer.h" // For the GLC() macro.
+#include "cc/gl_renderer.h" // For the GLC() macro.
#include "cc/platform_color.h"
#include "cc/texture_uploader.h"
#include "cc/transferable_resource.h"
@@ -27,1131 +27,1170 @@ using WebKit::WebGraphicsContext3D;
namespace cc {
-static GLenum textureToStorageFormat(GLenum textureFormat)
-{
- GLenum storageFormat = GL_RGBA8_OES;
- switch (textureFormat) {
+static GLenum TextureToStorageFormat(GLenum texture_format) {
+ GLenum storage_format = GL_RGBA8_OES;
+ switch (texture_format) {
case GL_RGBA:
- break;
+ break;
case GL_BGRA_EXT:
- storageFormat = GL_BGRA8_EXT;
- break;
+ storage_format = GL_BGRA8_EXT;
+ break;
default:
- NOTREACHED();
- break;
- }
+ NOTREACHED();
+ break;
+ }
- return storageFormat;
+ return storage_format;
}
-static bool isTextureFormatSupportedForStorage(GLenum format)
-{
- return (format == GL_RGBA || format == GL_BGRA_EXT);
+static bool IsTextureFormatSupportedForStorage(GLenum format) {
+ return (format == GL_RGBA || format == GL_BGRA_EXT);
}
-static unsigned createTextureId(WebGraphicsContext3D* context3d)
-{
- unsigned textureId = 0;
- GLC(context3d, textureId = context3d->createTexture());
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- return textureId;
+static unsigned CreateTextureId(WebGraphicsContext3D* context3d) {
+ unsigned texture_id = 0;
+ GLC(context3d, texture_id = context3d->createTexture());
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+ return texture_id;
}
ResourceProvider::Resource::Resource()
- : glId(0)
- , glPixelBufferId(0)
- , glUploadQueryId(0)
- , pixels(0)
- , pixelBuffer(0)
- , lockForReadCount(0)
- , lockedForWrite(false)
- , external(false)
- , exported(false)
- , markedForDeletion(false)
- , pendingSetPixels(false)
- , allocated(false)
- , enableReadLockFences(false)
- , readLockFence(NULL)
- , size()
- , format(0)
- , filter(0)
- , type(static_cast<ResourceType>(0))
-{
-}
-
-ResourceProvider::Resource::~Resource()
-{
-}
-
-ResourceProvider::Resource::Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter)
- : glId(textureId)
- , glPixelBufferId(0)
- , glUploadQueryId(0)
- , pixels(0)
- , pixelBuffer(0)
- , lockForReadCount(0)
- , lockedForWrite(false)
- , external(false)
- , exported(false)
- , markedForDeletion(false)
- , pendingSetPixels(false)
- , allocated(false)
- , enableReadLockFences(false)
- , readLockFence(NULL)
- , size(size)
- , format(format)
- , filter(filter)
- , type(GLTexture)
-{
-}
-
-ResourceProvider::Resource::Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum filter)
- : glId(0)
- , glPixelBufferId(0)
- , glUploadQueryId(0)
- , pixels(pixels)
- , pixelBuffer(0)
- , lockForReadCount(0)
- , lockedForWrite(false)
- , external(false)
- , exported(false)
- , markedForDeletion(false)
- , pendingSetPixels(false)
- , allocated(false)
- , enableReadLockFences(false)
- , readLockFence(NULL)
- , size(size)
- , format(format)
- , filter(filter)
- , type(Bitmap)
-{
-}
-
-ResourceProvider::Child::Child()
-{
-}
-
-ResourceProvider::Child::~Child()
-{
-}
-
-scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context)
-{
- scoped_ptr<ResourceProvider> resourceProvider(new ResourceProvider(context));
- if (!resourceProvider->initialize())
- return scoped_ptr<ResourceProvider>();
- return resourceProvider.Pass();
-}
-
-ResourceProvider::~ResourceProvider()
-{
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !context3d->makeContextCurrent())
- return;
- m_textureUploader.reset();
- m_textureCopier.reset();
-}
-
-WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- return m_outputSurface->context3d();
-}
-
-bool ResourceProvider::inUseByConsumer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- return !!resource->lockForReadCount || resource->exported;
-}
-
-ResourceProvider::ResourceId ResourceProvider::createResource(const gfx::Size& size, GLenum format, TextureUsageHint hint)
-{
- switch (m_defaultResourceType) {
+ : gl_id(0),
+ gl_pixel_buffer_id(0),
+ gl_upload_query_id(0),
+ pixels(NULL),
+ pixel_buffer(NULL),
+ lock_for_read_count(0),
+ locked_for_write(false),
+ external(false),
+ exported(false),
+ marked_for_deletion(false),
+ pending_set_pixels(false),
+ allocated(false),
+ enable_read_lock_fences(false),
+ read_lock_fence(NULL),
+ size(),
+ format(0),
+ filter(0),
+ type(static_cast<ResourceType>(0)) {}
+
+ResourceProvider::Resource::~Resource() {}
+
+ResourceProvider::Resource::Resource(
+ unsigned texture_id, gfx::Size size, GLenum format, GLenum filter)
+ : gl_id(texture_id),
+ gl_pixel_buffer_id(0),
+ gl_upload_query_id(0),
+ pixels(NULL),
+ pixel_buffer(NULL),
+ lock_for_read_count(0),
+ locked_for_write(false),
+ external(false),
+ exported(false),
+ marked_for_deletion(false),
+ pending_set_pixels(false),
+ allocated(false),
+ enable_read_lock_fences(false),
+ read_lock_fence(NULL),
+ size(size),
+ format(format),
+ filter(filter),
+ type(GLTexture) {}
+
+ResourceProvider::Resource::Resource(
+ uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter)
+ : gl_id(0),
+ gl_pixel_buffer_id(0),
+ gl_upload_query_id(0),
+ pixels(pixels),
+ pixel_buffer(NULL),
+ lock_for_read_count(0),
+ locked_for_write(false),
+ external(false),
+ exported(false),
+ marked_for_deletion(false),
+ pending_set_pixels(false),
+ allocated(false),
+ enable_read_lock_fences(false),
+ read_lock_fence(NULL),
+ size(size),
+ format(format),
+ filter(filter),
+ type(Bitmap) {}
+
+ResourceProvider::Child::Child() {}
+
+ResourceProvider::Child::~Child() {}
+
+scoped_ptr<ResourceProvider> ResourceProvider::Create(
+ OutputSurface* output_surface) {
+ scoped_ptr<ResourceProvider> resource_provider(
+ new ResourceProvider(output_surface));
+ if (!resource_provider->Initialize())
+ return scoped_ptr<ResourceProvider>();
+ return resource_provider.Pass();
+}
+
+ResourceProvider::~ResourceProvider() {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !context3d->makeContextCurrent())
+ return;
+ texture_uploader_.reset();
+ texture_copier_.reset();
+}
+
+WebGraphicsContext3D* ResourceProvider::GraphicsContext3D() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return output_surface_->context3d();
+}
+
+bool ResourceProvider::InUseByConsumer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ return !!resource->lock_for_read_count || resource->exported;
+}
+
+ResourceProvider::ResourceId ResourceProvider::CreateResource(
+ gfx::Size size, GLenum format, TextureUsageHint hint) {
+ switch (default_resource_type_) {
case GLTexture:
- return createGLTexture(size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint);
+ return CreateGLTexture(
+ size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint);
case Bitmap:
- DCHECK(format == GL_RGBA);
- return createBitmap(size);
- }
+ DCHECK(format == GL_RGBA);
+ return CreateBitmap(size);
+ }
- LOG(FATAL) << "Invalid default resource type.";
- return 0;
+ LOG(FATAL) << "Invalid default resource type.";
+ return 0;
}
-ResourceProvider::ResourceId ResourceProvider::createManagedResource(const gfx::Size& size, GLenum format, TextureUsageHint hint)
-{
- switch (m_defaultResourceType) {
+ResourceProvider::ResourceId ResourceProvider::CreateManagedResource(
+ gfx::Size size, GLenum format, TextureUsageHint hint) {
+ switch (default_resource_type_) {
case GLTexture:
- return createGLTexture(size, format, GL_TEXTURE_POOL_MANAGED_CHROMIUM, hint);
+ return CreateGLTexture(
+ size, format, GL_TEXTURE_POOL_MANAGED_CHROMIUM, hint);
case Bitmap:
- DCHECK(format == GL_RGBA);
- return createBitmap(size);
- }
-
- LOG(FATAL) << "Invalid default resource type.";
- return 0;
-}
-
-ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, GLenum texturePool, TextureUsageHint hint)
-{
- DCHECK_LE(size.width(), m_maxTextureSize);
- DCHECK_LE(size.height(), m_maxTextureSize);
-
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
+ DCHECK(format == GL_RGBA);
+ return CreateBitmap(size);
+ }
+
+ LOG(FATAL) << "Invalid default resource type.";
+ return 0;
+}
+
+ResourceProvider::ResourceId ResourceProvider::CreateGLTexture(
+ gfx::Size size, GLenum format, GLenum texture_pool, TextureUsageHint hint) {
+ DCHECK_LE(size.width(), max_texture_size_);
+ DCHECK_LE(size.height(), max_texture_size_);
+
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+
+ // Create and set texture properties. Allocation is delayed until needed.
+ unsigned texture_id = CreateTextureId(context3d);
+ GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_POOL_CHROMIUM,
+ texture_pool));
+ if (use_texture_usage_hint_ && hint == TextureUsageFramebuffer) {
+ GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_USAGE_ANGLE,
+ GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
+ }
+
+ ResourceId id = next_id_++;
+ Resource resource(texture_id, size, format, GL_LINEAR);
+ resource.allocated = false;
+ resources_[id] = resource;
+ return id;
+}
+
+ResourceProvider::ResourceId ResourceProvider::CreateBitmap(gfx::Size size) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ uint8_t* pixels = new uint8_t[size.width() * size.height() * 4];
+
+ ResourceId id = next_id_++;
+ Resource resource(pixels, size, GL_RGBA, GL_LINEAR);
+ resource.allocated = true;
+ resources_[id] = resource;
+ return id;
+}
+
+ResourceProvider::ResourceId ResourceProvider::
+ CreateResourceFromExternalTexture(unsigned texture_id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+ GLC(context3d, context3d->texParameteri(
+ GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+
+ ResourceId id = next_id_++;
+ Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR);
+ resource.external = true;
+ resource.allocated = true;
+ resources_[id] = resource;
+ return id;
+}
+
+ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
+ const TextureMailbox& mailbox) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // Just store the information. Mailbox will be consumed in LockForRead().
+ ResourceId id = next_id_++;
+ unsigned texture_id = 0;
+ Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR);
+ resource.external = true;
+ resource.allocated = true;
+ resource.mailbox = mailbox;
+ resources_[id] = resource;
+ return id;
+}
+
+void ResourceProvider::DeleteResource(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->lock_for_read_count);
+ DCHECK(!resource->marked_for_deletion);
+ DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
+
+ if (resource->exported) {
+ resource->marked_for_deletion = true;
+ return;
+ } else {
+ DeleteResourceInternal(it);
+ }
+}
+
+void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it) {
+ Resource* resource = &it->second;
+ if (resource->gl_id && !resource->external) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
DCHECK(context3d);
-
- // Create and set texture properties. Allocation is delayed until needed.
- unsigned textureId = createTextureId(context3d);
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, texturePool));
- if (m_useTextureUsageHint && hint == TextureUsageFramebuffer)
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
-
- ResourceId id = m_nextId++;
- Resource resource(textureId, size, format, GL_LINEAR);
- resource.allocated = false;
- m_resources[id] = resource;
- return id;
-}
-
-ResourceProvider::ResourceId ResourceProvider::createBitmap(const gfx::Size& size)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
-
- uint8_t* pixels = new uint8_t[size.width() * size.height() * 4];
-
- ResourceId id = m_nextId++;
- Resource resource(pixels, size, GL_RGBA, GL_LINEAR);
- resource.allocated = true;
- m_resources[id] = resource;
- return id;
-}
-
-ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture(unsigned textureId)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
-
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
+ GLC(context3d, context3d->deleteTexture(resource->gl_id));
+ }
+ if (resource->gl_upload_query_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
DCHECK(context3d);
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
-
- ResourceId id = m_nextId++;
- Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
- resource.external = true;
- resource.allocated = true;
- m_resources[id] = resource;
- return id;
-}
-
-ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox(const TextureMailbox& mailbox)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- // Just store the information. Mailbox will be consumed in lockForRead().
- ResourceId id = m_nextId++;
- unsigned textureId = 0;
- Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
- resource.external = true;
- resource.allocated = true;
- resource.mailbox = mailbox;
- m_resources[id] = resource;
- return id;
-}
-
-void ResourceProvider::deleteResource(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->lockForReadCount);
- DCHECK(!resource->markedForDeletion);
- DCHECK(resource->pendingSetPixels || !resource->lockedForWrite);
-
- if (resource->exported) {
- resource->markedForDeletion = true;
- return;
- } else
- deleteResourceInternal(it);
-}
-
-void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
-{
- Resource* resource = &it->second;
- if (resource->glId && !resource->external) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- GLC(context3d, context3d->deleteTexture(resource->glId));
- }
- if (resource->glUploadQueryId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId));
- }
- if (resource->glPixelBufferId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
- }
- if (!resource->mailbox.IsEmpty() && resource->external) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- unsigned syncPoint = resource->mailbox.sync_point();
- if (resource->glId) {
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
- GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.data()));
- GLC(context3d, context3d->deleteTexture(resource->glId));
- syncPoint = context3d->insertSyncPoint();
- }
- resource->mailbox.RunReleaseCallback(syncPoint);
- }
- if (resource->pixels)
- delete[] resource->pixels;
- if (resource->pixelBuffer)
- delete[] resource->pixelBuffer;
-
- m_resources.erase(it);
-}
-
-ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
-{
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- return resource->type;
-}
-
-void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx::Rect& imageRect, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->lockedForWrite);
- DCHECK(!resource->lockForReadCount);
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
- DCHECK(readLockFenceHasPassed(resource));
- lazyAllocate(resource);
-
- if (resource->glId) {
- DCHECK(!resource->pendingSetPixels);
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(m_textureUploader.get());
- context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
- m_textureUploader->upload(image,
- imageRect,
- sourceRect,
- destOffset,
- resource->format,
- resource->size);
- }
-
- if (resource->pixels) {
- DCHECK(resource->allocated);
- DCHECK(resource->format == GL_RGBA);
- SkBitmap srcFull;
- srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageRect.height());
- srcFull.setPixels(const_cast<uint8_t*>(image));
- SkBitmap srcSubset;
- SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height());
- skSourceRect.offset(-imageRect.x(), -imageRect.y());
- srcFull.extractSubset(&srcSubset, skSourceRect);
-
- ScopedWriteLockSoftware lock(this, id);
- SkCanvas* dest = lock.skCanvas();
- dest->writePixels(srcSubset, destOffset.x(), destOffset.y());
- }
-}
-
-size_t ResourceProvider::numBlockingUploads()
-{
- if (!m_textureUploader)
- return 0;
-
- return m_textureUploader->numBlockingUploads();
-}
-
-void ResourceProvider::markPendingUploadsAsNonBlocking()
-{
- if (!m_textureUploader)
- return;
-
- m_textureUploader->markPendingUploadsAsNonBlocking();
-}
-
-double ResourceProvider::estimatedUploadsPerSecond()
-{
- if (!m_textureUploader)
- return 0.0;
-
- return m_textureUploader->estimatedTexturesPerSecond();
-}
-
-void ResourceProvider::flushUploads()
-{
- if (!m_textureUploader)
- return;
-
- m_textureUploader->flush();
-}
-
-void ResourceProvider::releaseCachedData()
-{
- if (!m_textureUploader)
- return;
-
- m_textureUploader->releaseCachedQueries();
-}
-
-void ResourceProvider::flush()
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (context3d)
- context3d->flush();
-}
-
-bool ResourceProvider::shallowFlushIfSupported()
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !m_useShallowFlush)
- return false;
-
- context3d->shallowFlushCHROMIUM();
- return true;
-}
-
-const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->lockedForWrite);
- DCHECK(!resource->exported);
- DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrite first.
-
- if (!resource->glId && resource->external && !resource->mailbox.IsEmpty()) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- if (resource->mailbox.sync_point()) {
- GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point()));
- resource->mailbox.ResetSyncPoint();
- }
- resource->glId = context3d->createTexture();
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
- GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.data()));
+ GLC(context3d, context3d->deleteQueryEXT(resource->gl_upload_query_id));
+ }
+ if (resource->gl_pixel_buffer_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ GLC(context3d, context3d->deleteBuffer(resource->gl_pixel_buffer_id));
+ }
+ if (!resource->mailbox.IsEmpty() && resource->external) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ unsigned sync_point = resource->mailbox.sync_point();
+ if (resource->gl_id) {
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
+ GLC(context3d, context3d->produceTextureCHROMIUM(
+ GL_TEXTURE_2D, resource->mailbox.data()));
+ GLC(context3d, context3d->deleteTexture(resource->gl_id));
+ sync_point = context3d->insertSyncPoint();
}
-
- resource->lockForReadCount++;
- if (resource->enableReadLockFences)
- resource->readLockFence = m_currentReadLockFence;
-
- return resource;
-}
-
-void ResourceProvider::unlockForRead(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(resource->lockForReadCount > 0);
- DCHECK(!resource->exported);
- resource->lockForReadCount--;
-}
-
-const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->lockedForWrite);
- DCHECK(!resource->lockForReadCount);
- DCHECK(!resource->exported);
- DCHECK(!resource->external);
- DCHECK(readLockFenceHasPassed(resource));
- lazyAllocate(resource);
-
- resource->lockedForWrite = true;
- return resource;
-}
-
-bool ResourceProvider::canLockForWrite(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- return !resource->lockedForWrite &&
- !resource->lockForReadCount &&
- !resource->exported &&
- !resource->external &&
- readLockFenceHasPassed(resource);
-}
-
-void ResourceProvider::unlockForWrite(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(resource->lockedForWrite);
- DCHECK(!resource->exported);
- DCHECK(!resource->external);
- resource->lockedForWrite = false;
-}
-
-ResourceProvider::ScopedReadLockGL::ScopedReadLockGL(ResourceProvider* resourceProvider, ResourceProvider::ResourceId resourceId)
- : m_resourceProvider(resourceProvider)
- , m_resourceId(resourceId)
- , m_textureId(resourceProvider->lockForRead(resourceId)->glId)
-{
- DCHECK(m_textureId);
-}
-
-ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL()
-{
- m_resourceProvider->unlockForRead(m_resourceId);
-}
-
-ResourceProvider::ScopedSamplerGL::ScopedSamplerGL(ResourceProvider* resourceProvider, ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter)
- : ScopedReadLockGL(resourceProvider, resourceId)
-{
- resourceProvider->bindForSampling(resourceId, target, filter);
-}
-
-ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL(ResourceProvider* resourceProvider, ResourceProvider::ResourceId resourceId)
- : m_resourceProvider(resourceProvider)
- , m_resourceId(resourceId)
- , m_textureId(resourceProvider->lockForWrite(resourceId)->glId)
-{
- DCHECK(m_textureId);
-}
-
-ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL()
-{
- m_resourceProvider->unlockForWrite(m_resourceId);
-}
-
-void ResourceProvider::populateSkBitmapWithResource(SkBitmap* skBitmap, const Resource* resource)
-{
- DCHECK(resource->pixels);
+ resource->mailbox.RunReleaseCallback(sync_point);
+ }
+ if (resource->pixels)
+ delete[] resource->pixels;
+ if (resource->pixel_buffer)
+ delete[] resource->pixel_buffer;
+
+ resources_.erase(it);
+}
+
+ResourceProvider::ResourceType ResourceProvider::GetResourceType(
+ ResourceId id) {
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ return resource->type;
+}
+
+void ResourceProvider::SetPixels(ResourceId id,
+ const uint8_t* image,
+ gfx::Rect image_rect,
+ gfx::Rect source_rect,
+ gfx::Vector2d dest_offset) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->locked_for_write);
+ DCHECK(!resource->lock_for_read_count);
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+ DCHECK(ReadLockFenceHasPassed(resource));
+ LazyAllocate(resource);
+
+ if (resource->gl_id) {
+ DCHECK(!resource->pending_set_pixels);
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(texture_uploader_.get());
+ context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
+ texture_uploader_->upload(image,
+ image_rect,
+ source_rect,
+ dest_offset,
+ resource->format,
+ resource->size);
+ }
+
+ if (resource->pixels) {
+ DCHECK(resource->allocated);
DCHECK(resource->format == GL_RGBA);
- skBitmap->setConfig(SkBitmap::kARGB_8888_Config, resource->size.width(), resource->size.height());
- skBitmap->setPixels(resource->pixels);
-}
+ SkBitmap src_full;
+ src_full.setConfig(
+ SkBitmap::kARGB_8888_Config, image_rect.width(), image_rect.height());
+ src_full.setPixels(const_cast<uint8_t*>(image));
+ SkBitmap src_subset;
+ SkIRect sk_source_rect = SkIRect::MakeXYWH(source_rect.x(),
+ source_rect.y(),
+ source_rect.width(),
+ source_rect.height());
+ sk_source_rect.offset(-image_rect.x(), -image_rect.y());
+ src_full.extractSubset(&src_subset, sk_source_rect);
+
+ ScopedWriteLockSoftware lock(this, id);
+ SkCanvas* dest = lock.sk_canvas();
+ dest->writePixels(src_subset, dest_offset.x(), dest_offset.y());
+ }
+}
+
+size_t ResourceProvider::NumBlockingUploads() {
+ if (!texture_uploader_)
+ return 0;
-ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware(ResourceProvider* resourceProvider, ResourceProvider::ResourceId resourceId)
- : m_resourceProvider(resourceProvider)
- , m_resourceId(resourceId)
-{
- ResourceProvider::populateSkBitmapWithResource(&m_skBitmap, resourceProvider->lockForRead(resourceId));
+ return texture_uploader_->numBlockingUploads();
}
-ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware()
-{
- m_resourceProvider->unlockForRead(m_resourceId);
-}
+void ResourceProvider::MarkPendingUploadsAsNonBlocking() {
+ if (!texture_uploader_)
+ return;
-ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware(ResourceProvider* resourceProvider, ResourceProvider::ResourceId resourceId)
- : m_resourceProvider(resourceProvider)
- , m_resourceId(resourceId)
-{
- ResourceProvider::populateSkBitmapWithResource(&m_skBitmap, resourceProvider->lockForWrite(resourceId));
- m_skCanvas.reset(new SkCanvas(m_skBitmap));
+ texture_uploader_->markPendingUploadsAsNonBlocking();
}
-ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware()
-{
- m_resourceProvider->unlockForWrite(m_resourceId);
-}
+double ResourceProvider::EstimatedUploadsPerSecond() {
+ if (!texture_uploader_)
+ return 0.0;
-ResourceProvider::ResourceProvider(OutputSurface* context)
- : m_outputSurface(context)
- , m_nextId(1)
- , m_nextChild(1)
- , m_defaultResourceType(GLTexture)
- , m_useTextureStorageExt(false)
- , m_useTextureUsageHint(false)
- , m_useShallowFlush(false)
- , m_maxTextureSize(0)
- , m_bestTextureFormat(0)
-{
+ return texture_uploader_->estimatedTexturesPerSecond();
}
-bool ResourceProvider::initialize()
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d) {
- m_maxTextureSize = INT_MAX / 2;
- m_bestTextureFormat = GL_RGBA;
- return true;
- }
- if (!context3d->makeContextCurrent())
- return false;
-
- std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIONS));
- std::vector<std::string> extensions;
- base::SplitString(extensionsString, ' ', &extensions);
- bool useMapSub = false;
- bool useBindUniform = false;
- bool useBGRA = false;
- for (size_t i = 0; i < extensions.size(); ++i) {
- if (extensions[i] == "GL_EXT_texture_storage")
- m_useTextureStorageExt = true;
- else if (extensions[i] == "GL_ANGLE_texture_usage")
- m_useTextureUsageHint = true;
- else if (extensions[i] == "GL_CHROMIUM_map_sub")
- useMapSub = true;
- else if (extensions[i] == "GL_CHROMIUM_shallow_flush")
- m_useShallowFlush = true;
- else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location")
- useBindUniform = true;
- else if (extensions[i] == "GL_EXT_texture_format_BGRA8888")
- useBGRA = true;
- }
-
- m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform);
-
- m_textureUploader = TextureUploader::create(context3d, useMapSub, m_useShallowFlush);
- GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize));
- m_bestTextureFormat = PlatformColor::bestTextureFormat(context3d, useBGRA);
- return true;
-}
+void ResourceProvider::FlushUploads() {
+ if (!texture_uploader_)
+ return;
-int ResourceProvider::createChild()
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- Child childInfo;
- int child = m_nextChild++;
- m_children[child] = childInfo;
- return child;
+ texture_uploader_->flush();
}
-void ResourceProvider::destroyChild(int child_id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ChildMap::iterator it = m_children.find(child_id);
- DCHECK(it != m_children.end());
- Child& child = it->second;
- for (ResourceIdMap::iterator child_it = child.childToParentMap.begin(); child_it != child.childToParentMap.end(); ++child_it)
- deleteResource(child_it->second);
- m_children.erase(it);
-}
+void ResourceProvider::ReleaseCachedData() {
+ if (!texture_uploader_)
+ return;
-const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ChildMap::const_iterator it = m_children.find(child);
- DCHECK(it != m_children.end());
- return it->second.childToParentMap;
+ texture_uploader_->releaseCachedQueries();
}
-void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, TransferableResourceArray* list)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- list->clear();
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !context3d->makeContextCurrent()) {
- // FIXME: Implement this path for software compositing.
- return;
- }
- bool needSyncPoint = false;
- for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) {
- TransferableResource resource;
- if (transferResource(context3d, *it, &resource)) {
- if (!resource.sync_point)
- needSyncPoint = true;
- m_resources.find(*it)->second.exported = true;
- list->push_back(resource);
- }
- }
- if (needSyncPoint) {
- unsigned int syncPoint = context3d->insertSyncPoint();
- for (TransferableResourceArray::iterator it = list->begin(); it != list->end(); ++it) {
- if (!it->sync_point)
- it->sync_point = syncPoint;
- }
- }
+void ResourceProvider::Flush() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (context3d)
+ context3d->flush();
}
-void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources, TransferableResourceArray* list)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- list->clear();
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !context3d->makeContextCurrent()) {
- // FIXME: Implement this path for software compositing.
- return;
- }
- Child& childInfo = m_children.find(child)->second;
- bool needSyncPoint = false;
- for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) {
- TransferableResource resource;
- if (!transferResource(context3d, *it, &resource))
- NOTREACHED();
- if (!resource.sync_point)
- needSyncPoint = true;
- DCHECK(childInfo.parentToChildMap.find(*it) != childInfo.parentToChildMap.end());
- resource.id = childInfo.parentToChildMap[*it];
- childInfo.parentToChildMap.erase(*it);
- childInfo.childToParentMap.erase(resource.id);
- list->push_back(resource);
- deleteResource(*it);
- }
- if (needSyncPoint) {
- unsigned int syncPoint = context3d->insertSyncPoint();
- for (TransferableResourceArray::iterator it = list->begin(); it != list->end(); ++it) {
- if (!it->sync_point)
- it->sync_point = syncPoint;
- }
- }
-}
+bool ResourceProvider::ShallowFlushIfSupported() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !use_shallow_flush_)
+ return false;
-void ResourceProvider::receiveFromChild(int child, const TransferableResourceArray& resources)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !context3d->makeContextCurrent()) {
- // FIXME: Implement this path for software compositing.
- return;
- }
- Child& childInfo = m_children.find(child)->second;
- for (TransferableResourceArray::const_iterator it = resources.begin(); it != resources.end(); ++it) {
- unsigned textureId;
- // NOTE: If the parent is a browser and the child a renderer, the parent
- // is not supposed to have its context wait, because that could induce
- // deadlocks and/or security issues. The caller is responsible for
- // waiting asynchronously, and resetting sync_point before calling this.
- // However if the parent is a renderer (e.g. browser tag), it may be ok
- // (and is simpler) to wait.
- if (it->sync_point)
- GLC(context3d, context3d->waitSyncPoint(it->sync_point));
- GLC(context3d, textureId = context3d->createTexture());
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
- GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name));
- ResourceId id = m_nextId++;
- Resource resource(textureId, it->size, it->format, it->filter);
- resource.mailbox.SetName(it->mailbox);
- // Don't allocate a texture for a child.
- resource.allocated = true;
- m_resources[id] = resource;
- childInfo.parentToChildMap[id] = it->id;
- childInfo.childToParentMap[it->id] = id;
- }
+ context3d->shallowFlushCHROMIUM();
+ return true;
}
-void ResourceProvider::receiveFromParent(const TransferableResourceArray& resources)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- if (!context3d || !context3d->makeContextCurrent()) {
- // FIXME: Implement this path for software compositing.
- return;
- }
- for (TransferableResourceArray::const_iterator it = resources.begin(); it != resources.end(); ++it) {
- ResourceMap::iterator mapIterator = m_resources.find(it->id);
- DCHECK(mapIterator != m_resources.end());
- Resource* resource = &mapIterator->second;
- DCHECK(resource->exported);
- resource->exported = false;
- resource->filter = it->filter;
- DCHECK(resource->mailbox.Equals(it->mailbox));
- if (resource->glId) {
- if (it->sync_point)
- GLC(context3d, context3d->waitSyncPoint(it->sync_point));
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
- GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name));
- } else {
- resource->mailbox = TextureMailbox(resource->mailbox.name(), resource->mailbox.callback(), it->sync_point);
- }
- if (resource->markedForDeletion)
- deleteResourceInternal(mapIterator);
- }
-}
+const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->locked_for_write);
+ DCHECK(!resource->exported);
+ // Uninitialized! Call SetPixels or LockForWrite first.
+ DCHECK(resource->allocated);
-bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* source = &it->second;
- DCHECK(!source->lockedForWrite);
- DCHECK(!source->lockForReadCount);
- DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty()));
- DCHECK(source->allocated);
- if (source->exported)
- return false;
- resource->id = id;
- resource->format = source->format;
- resource->filter = source->filter;
- resource->size = source->size;
-
- if (source->mailbox.IsEmpty()) {
- GLC(context3d, context3d->genMailboxCHROMIUM(resource->mailbox.name));
- source->mailbox.SetName(resource->mailbox);
- } else
- resource->mailbox = source->mailbox.name();
-
- if (source->glId) {
- GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId));
- GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name));
- } else {
- resource->sync_point = source->mailbox.sync_point();
- source->mailbox.ResetSyncPoint();
+ if (!resource->gl_id && resource->external && !resource->mailbox.IsEmpty()) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ if (resource->mailbox.sync_point()) {
+ GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point()));
+ resource->mailbox.ResetSyncPoint();
}
+ resource->gl_id = context3d->createTexture();
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
+ GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D,
+ resource->mailbox.data()));
+ }
+
+ resource->lock_for_read_count++;
+ if (resource->enable_read_lock_fences)
+ resource->read_lock_fence = current_read_lock_fence_;
+
+ return resource;
+}
+
+void ResourceProvider::UnlockForRead(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(resource->lock_for_read_count > 0);
+ DCHECK(!resource->exported);
+ resource->lock_for_read_count--;
+}
+
+const ResourceProvider::Resource* ResourceProvider::LockForWrite(
+ ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->locked_for_write);
+ DCHECK(!resource->lock_for_read_count);
+ DCHECK(!resource->exported);
+ DCHECK(!resource->external);
+ DCHECK(ReadLockFenceHasPassed(resource));
+ LazyAllocate(resource);
+
+ resource->locked_for_write = true;
+ return resource;
+}
+
+bool ResourceProvider::CanLockForWrite(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ return !resource->locked_for_write &&
+ !resource->lock_for_read_count &&
+ !resource->exported &&
+ !resource->external &&
+ ReadLockFenceHasPassed(resource);
+}
+
+void ResourceProvider::UnlockForWrite(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(resource->locked_for_write);
+ DCHECK(!resource->exported);
+ DCHECK(!resource->external);
+ resource->locked_for_write = false;
+}
+
+ResourceProvider::ScopedReadLockGL::ScopedReadLockGL(
+ ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id)
+ : resource_provider_(resource_provider),
+ resource_id_(resource_id),
+ texture_id_(resource_provider->LockForRead(resource_id)->gl_id) {
+ DCHECK(texture_id_);
+}
+
+ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() {
+ resource_provider_->UnlockForRead(resource_id_);
+}
+
+ResourceProvider::ScopedSamplerGL::ScopedSamplerGL(
+ ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id,
+ GLenum target,
+ GLenum filter)
+ : ScopedReadLockGL(resource_provider, resource_id) {
+ resource_provider->BindForSampling(resource_id, target, filter);
+}
+
+ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL(
+ ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id)
+ : resource_provider_(resource_provider),
+ resource_id_(resource_id),
+ texture_id_(resource_provider->LockForWrite(resource_id)->gl_id) {
+ DCHECK(texture_id_);
+}
+
+ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() {
+ resource_provider_->UnlockForWrite(resource_id_);
+}
+
+void ResourceProvider::PopulateSkBitmapWithResource(
+ SkBitmap* sk_bitmap, const Resource* resource) {
+ DCHECK(resource->pixels);
+ DCHECK(resource->format == GL_RGBA);
+ sk_bitmap->setConfig(SkBitmap::kARGB_8888_Config,
+ resource->size.width(),
+ resource->size.height());
+ sk_bitmap->setPixels(resource->pixels);
+}
+
+ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware(
+ ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id)
+ : resource_provider_(resource_provider),
+ resource_id_(resource_id) {
+ ResourceProvider::PopulateSkBitmapWithResource(
+ &sk_bitmap_, resource_provider->LockForRead(resource_id));
+}
+
+ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() {
+ resource_provider_->UnlockForRead(resource_id_);
+}
+
+ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware(
+ ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id)
+ : resource_provider_(resource_provider),
+ resource_id_(resource_id) {
+ ResourceProvider::PopulateSkBitmapWithResource(
+ &sk_bitmap_, resource_provider->LockForWrite(resource_id));
+ sk_canvas_.reset(new SkCanvas(sk_bitmap_));
+}
+
+ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() {
+ resource_provider_->UnlockForWrite(resource_id_);
+}
+
+ResourceProvider::ResourceProvider(OutputSurface* output_surface)
+ : output_surface_(output_surface),
+ next_id_(1),
+ next_child_(1),
+ default_resource_type_(GLTexture),
+ use_texture_storage_ext_(false),
+ use_texture_usage_hint_(false),
+ use_shallow_flush_(false),
+ max_texture_size_(0),
+ best_texture_format_(0) {}
+
+bool ResourceProvider::Initialize() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d) {
+ max_texture_size_ = INT_MAX / 2;
+ best_texture_format_ = GL_RGBA;
return true;
-}
-
-void ResourceProvider::acquirePixelBuffer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- if (!resource->glPixelBufferId)
- resource->glPixelBufferId = context3d->createBuffer();
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- context3d->bufferData(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->size.width() * resource->size.height() * 4,
- NULL,
- GL_DYNAMIC_DRAW);
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+ if (!context3d->makeContextCurrent())
+ return false;
+
+ std::string extensions_string =
+ UTF16ToASCII(context3d->getString(GL_EXTENSIONS));
+ std::vector<std::string> extensions;
+ base::SplitString(extensions_string, ' ', &extensions);
+ bool use_map_sub = false;
+ bool use_bind_uniform = false;
+ bool use_b_g_r_a = false;
+ for (size_t i = 0; i < extensions.size(); ++i) {
+ if (extensions[i] == "GL_EXT_texture_storage")
+ use_texture_storage_ext_ = true;
+ else if (extensions[i] == "GL_ANGLE_texture_usage")
+ use_texture_usage_hint_ = true;
+ else if (extensions[i] == "GL_CHROMIUM_map_sub")
+ use_map_sub = true;
+ else if (extensions[i] == "GL_CHROMIUM_shallow_flush")
+ use_shallow_flush_ = true;
+ else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location")
+ use_bind_uniform = true;
+ else if (extensions[i] == "GL_EXT_texture_format_BGRA8888")
+ use_b_g_r_a = true;
+ }
+
+ texture_copier_ =
+ AcceleratedTextureCopier::create(context3d, use_bind_uniform);
+
+ texture_uploader_ =
+ TextureUploader::create(context3d, use_map_sub, use_shallow_flush_);
+ GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE,
+ &max_texture_size_));
+ best_texture_format_ =
+ PlatformColor::bestTextureFormat(context3d, use_b_g_r_a);
+ return true;
+}
+
+int ResourceProvider::CreateChild() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ Child child_info;
+ int child = next_child_++;
+ children_[child] = child_info;
+ return child;
+}
+
+void ResourceProvider::DestroyChild(int child_id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ChildMap::iterator it = children_.find(child_id);
+ DCHECK(it != children_.end());
+ Child& child = it->second;
+ for (ResourceIdMap::iterator child_it = child.child_to_parent_map.begin();
+ child_it != child.child_to_parent_map.end();
+ ++child_it)
+ DeleteResource(child_it->second);
+ children_.erase(it);
+}
+
+const ResourceProvider::ResourceIdMap& ResourceProvider::GetChildToParentMap(
+ int child) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ChildMap::const_iterator it = children_.find(child);
+ DCHECK(it != children_.end());
+ return it->second.child_to_parent_map;
+}
+
+void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources,
+ TransferableResourceArray* list) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ list->clear();
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !context3d->makeContextCurrent()) {
+ // FIXME: Implement this path for software compositing.
+ return;
+ }
+ bool need_sync_point = false;
+ for (ResourceIdArray::const_iterator it = resources.begin();
+ it != resources.end();
+ ++it) {
+ TransferableResource resource;
+ if (TransferResource(context3d, *it, &resource)) {
+ if (!resource.sync_point)
+ need_sync_point = true;
+ resources_.find(*it)->second.exported = true;
+ list->push_back(resource);
}
-
- if (resource->pixels) {
- if (resource->pixelBuffer)
- return;
-
- resource->pixelBuffer = new uint8_t[
- resource->size.width() * resource->size.height() * 4];
+ }
+ if (need_sync_point) {
+ unsigned int sync_point = context3d->insertSyncPoint();
+ for (TransferableResourceArray::iterator it = list->begin();
+ it != list->end();
+ ++it) {
+ if (!it->sync_point)
+ it->sync_point = sync_point;
}
-}
-
-void ResourceProvider::releasePixelBuffer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
-
- if (resource->glId) {
- DCHECK(resource->glPixelBufferId);
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- context3d->bufferData(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- 0,
- NULL,
- GL_DYNAMIC_DRAW);
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+}
+
+void ResourceProvider::PrepareSendToChild(int child,
+ const ResourceIdArray& resources,
+ TransferableResourceArray* list) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ list->clear();
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !context3d->makeContextCurrent()) {
+ // FIXME: Implement this path for software compositing.
+ return;
+ }
+ Child& child_info = children_.find(child)->second;
+ bool need_sync_point = false;
+ for (ResourceIdArray::const_iterator it = resources.begin();
+ it != resources.end();
+ ++it) {
+ TransferableResource resource;
+ if (!TransferResource(context3d, *it, &resource))
+ NOTREACHED();
+ if (!resource.sync_point)
+ need_sync_point = true;
+ DCHECK(child_info.parent_to_child_map.find(*it) !=
+ child_info.parent_to_child_map.end());
+ resource.id = child_info.parent_to_child_map[*it];
+ child_info.parent_to_child_map.erase(*it);
+ child_info.child_to_parent_map.erase(resource.id);
+ list->push_back(resource);
+ DeleteResource(*it);
+ }
+ if (need_sync_point) {
+ unsigned int sync_point = context3d->insertSyncPoint();
+ for (TransferableResourceArray::iterator it = list->begin();
+ it != list->end();
+ ++it) {
+ if (!it->sync_point)
+ it->sync_point = sync_point;
}
-
- if (resource->pixels) {
- if (!resource->pixelBuffer)
- return;
- delete[] resource->pixelBuffer;
- resource->pixelBuffer = 0;
- }
-}
-
-uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glPixelBufferId);
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- uint8_t* image = static_cast<uint8_t*>(
- context3d->mapBufferCHROMIUM(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY));
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
- DCHECK(image);
- return image;
- }
-
- if (resource->pixels)
- return resource->pixelBuffer;
-
- return NULL;
-}
-
-void ResourceProvider::unmapPixelBuffer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glPixelBufferId);
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- context3d->unmapBufferCHROMIUM(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
- }
-}
-
-void ResourceProvider::setPixelsFromBuffer(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->lockedForWrite);
- DCHECK(!resource->lockForReadCount);
- DCHECK(!resource->external);
- DCHECK(!resource->exported);
- DCHECK(readLockFenceHasPassed(resource));
- lazyAllocate(resource);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glPixelBufferId);
- context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- context3d->texSubImage2D(GL_TEXTURE_2D,
- 0, /* level */
- 0, /* x */
- 0, /* y */
- resource->size.width(),
- resource->size.height(),
- resource->format,
- GL_UNSIGNED_BYTE,
- NULL);
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
- }
-
- if (resource->pixels) {
- DCHECK(resource->pixelBuffer);
- DCHECK(resource->format == GL_RGBA);
- SkBitmap src;
- src.setConfig(SkBitmap::kARGB_8888_Config,
- resource->size.width(),
- resource->size.height());
- src.setPixels(resource->pixelBuffer);
-
- ScopedWriteLockSoftware lock(this, id);
- SkCanvas* dest = lock.skCanvas();
- dest->writePixels(src, 0, 0);
- }
-}
-
-void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- ResourceMap::iterator it = m_resources.find(resourceId);
- DCHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(resource->lockForReadCount);
- DCHECK(!resource->lockedForWrite);
-
- GLC(context3d, context3d->bindTexture(target, resource->glId));
- if (filter != resource->filter) {
- GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MIN_FILTER, filter));
- GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MAG_FILTER, filter));
- resource->filter = filter;
- }
-}
-
-void ResourceProvider::beginSetPixels(ResourceId id)
-{
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(!resource->pendingSetPixels);
- DCHECK(resource->glId || resource->allocated);
- DCHECK(readLockFenceHasPassed(resource));
-
- bool allocate = !resource->allocated;
- resource->allocated = true;
- lockForWrite(id);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glPixelBufferId);
- context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
- context3d->bindBuffer(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->glPixelBufferId);
- if (!resource->glUploadQueryId)
- resource->glUploadQueryId = context3d->createQueryEXT();
- context3d->beginQueryEXT(
- GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM,
- resource->glUploadQueryId);
- if (allocate) {
- context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D,
- 0, /* level */
- resource->format,
- resource->size.width(),
- resource->size.height(),
- 0, /* border */
- resource->format,
- GL_UNSIGNED_BYTE,
- NULL);
- } else {
- context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
- 0, /* level */
- 0, /* x */
- 0, /* y */
- resource->size.width(),
- resource->size.height(),
- resource->format,
- GL_UNSIGNED_BYTE,
- NULL);
- }
- context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM);
- context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
- }
-
- if (resource->pixels)
- setPixelsFromBuffer(id);
-
- resource->pendingSetPixels = true;
-}
-
-bool ResourceProvider::didSetPixelsComplete(ResourceId id) {
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(resource->lockedForWrite);
- DCHECK(resource->pendingSetPixels);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glUploadQueryId);
- unsigned complete = 1;
- context3d->getQueryObjectuivEXT(
- resource->glUploadQueryId,
- GL_QUERY_RESULT_AVAILABLE_EXT,
- &complete);
- if (!complete)
- return false;
+ }
+}
+
+void ResourceProvider::ReceiveFromChild(
+ int child, const TransferableResourceArray& resources) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !context3d->makeContextCurrent()) {
+ // FIXME: Implement this path for software compositing.
+ return;
+ }
+ Child& child_info = children_.find(child)->second;
+ for (TransferableResourceArray::const_iterator it = resources.begin();
+ it != resources.end();
+ ++it) {
+ unsigned texture_id;
+ // NOTE: If the parent is a browser and the child a renderer, the parent
+ // is not supposed to have its context wait, because that could induce
+ // deadlocks and/or security issues. The caller is responsible for
+ // waiting asynchronously, and resetting sync_point before calling this.
+ // However if the parent is a renderer (e.g. browser tag), it may be ok
+ // (and is simpler) to wait.
+ if (it->sync_point)
+ GLC(context3d, context3d->waitSyncPoint(it->sync_point));
+ GLC(context3d, texture_id = context3d->createTexture());
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D,
+ it->mailbox.name));
+ ResourceId id = next_id_++;
+ Resource resource(texture_id, it->size, it->format, it->filter);
+ resource.mailbox.SetName(it->mailbox);
+ // Don't allocate a texture for a child.
+ resource.allocated = true;
+ resources_[id] = resource;
+ child_info.parent_to_child_map[id] = it->id;
+ child_info.child_to_parent_map[it->id] = id;
+ }
+}
+
+void ResourceProvider::ReceiveFromParent(
+ const TransferableResourceArray& resources) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ if (!context3d || !context3d->makeContextCurrent()) {
+ // FIXME: Implement this path for software compositing.
+ return;
+ }
+ for (TransferableResourceArray::const_iterator it = resources.begin();
+ it != resources.end();
+ ++it) {
+ ResourceMap::iterator map_iterator = resources_.find(it->id);
+ DCHECK(map_iterator != resources_.end());
+ Resource* resource = &map_iterator->second;
+ DCHECK(resource->exported);
+ resource->exported = false;
+ resource->filter = it->filter;
+ DCHECK(resource->mailbox.Equals(it->mailbox));
+ if (resource->gl_id) {
+ if (it->sync_point)
+ GLC(context3d, context3d->waitSyncPoint(it->sync_point));
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
+ GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D,
+ it->mailbox.name));
+ } else {
+ resource->mailbox = TextureMailbox(resource->mailbox.name(),
+ resource->mailbox.callback(),
+ it->sync_point);
}
-
- resource->pendingSetPixels = false;
- unlockForWrite(id);
-
- return true;
-}
-
-void ResourceProvider::abortSetPixels(ResourceId id) {
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- DCHECK(resource->lockedForWrite);
- DCHECK(resource->pendingSetPixels);
-
- if (resource->glId) {
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- DCHECK(context3d);
- DCHECK(resource->glUploadQueryId);
- // CHROMIUM_async_pixel_transfers currently doesn't have a way to
- // abort an upload. The best we can do is delete the query and
- // the texture.
- context3d->deleteQueryEXT(resource->glUploadQueryId);
- resource->glUploadQueryId = 0;
- context3d->deleteTexture(resource->glId);
- resource->glId = createTextureId(context3d);
- resource->allocated = false;
+ if (resource->marked_for_deletion)
+ DeleteResourceInternal(map_iterator);
+ }
+}
+
+bool ResourceProvider::TransferResource(WebGraphicsContext3D* context,
+ ResourceId id,
+ TransferableResource* resource) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* source = &it->second;
+ DCHECK(!source->locked_for_write);
+ DCHECK(!source->lock_for_read_count);
+ DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty()));
+ DCHECK(source->allocated);
+ if (source->exported)
+ return false;
+ resource->id = id;
+ resource->format = source->format;
+ resource->filter = source->filter;
+ resource->size = source->size;
+
+ if (source->mailbox.IsEmpty()) {
+ GLC(context3d, context3d->genMailboxCHROMIUM(resource->mailbox.name));
+ source->mailbox.SetName(resource->mailbox);
+ } else {
+ resource->mailbox = source->mailbox.name();
+ }
+
+ if (source->gl_id) {
+ GLC(context, context->bindTexture(GL_TEXTURE_2D, source->gl_id));
+ GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D,
+ resource->mailbox.name));
+ } else {
+ resource->sync_point = source->mailbox.sync_point();
+ source->mailbox.ResetSyncPoint();
+ }
+ return true;
+}
+
+void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ if (!resource->gl_pixel_buffer_id)
+ resource->gl_pixel_buffer_id = context3d->createBuffer();
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ context3d->bufferData(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->size.width() * resource->size.height() * 4,
+ NULL,
+ GL_DYNAMIC_DRAW);
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+
+ if (resource->pixels) {
+ if (resource->pixel_buffer)
+ return;
+
+ resource->pixel_buffer = new uint8_t[
+ resource->size.width() * resource->size.height() * 4];
+ }
+}
+
+void ResourceProvider::ReleasePixelBuffer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+
+ if (resource->gl_id) {
+ DCHECK(resource->gl_pixel_buffer_id);
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ context3d->bufferData(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ 0,
+ NULL,
+ GL_DYNAMIC_DRAW);
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+
+ if (resource->pixels) {
+ if (!resource->pixel_buffer)
+ return;
+ delete[] resource->pixel_buffer;
+ resource->pixel_buffer = NULL;
+ }
+}
+
+uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_pixel_buffer_id);
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ uint8_t* image = static_cast<uint8_t*>(
+ context3d->mapBufferCHROMIUM(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY));
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ DCHECK(image);
+ return image;
+ }
+
+ if (resource->pixels)
+ return resource->pixel_buffer;
+
+ return NULL;
+}
+
+void ResourceProvider::UnmapPixelBuffer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_pixel_buffer_id);
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ context3d->unmapBufferCHROMIUM(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+}
+
+void ResourceProvider::SetPixelsFromBuffer(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->locked_for_write);
+ DCHECK(!resource->lock_for_read_count);
+ DCHECK(!resource->external);
+ DCHECK(!resource->exported);
+ DCHECK(ReadLockFenceHasPassed(resource));
+ LazyAllocate(resource);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_pixel_buffer_id);
+ context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ context3d->texSubImage2D(GL_TEXTURE_2D,
+ 0, /* level */
+ 0, /* x */
+ 0, /* y */
+ resource->size.width(),
+ resource->size.height(),
+ resource->format,
+ GL_UNSIGNED_BYTE,
+ NULL);
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
+
+ if (resource->pixels) {
+ DCHECK(resource->pixel_buffer);
+ DCHECK(resource->format == GL_RGBA);
+ SkBitmap src;
+ src.setConfig(SkBitmap::kARGB_8888_Config,
+ resource->size.width(),
+ resource->size.height());
+ src.setPixels(resource->pixel_buffer);
+
+ ScopedWriteLockSoftware lock(this, id);
+ SkCanvas* dest = lock.sk_canvas();
+ dest->writePixels(src, 0, 0);
+ }
+}
+
+void ResourceProvider::BindForSampling(ResourceProvider::ResourceId resource_id,
+ GLenum target, GLenum filter) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ ResourceMap::iterator it = resources_.find(resource_id);
+ DCHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(resource->lock_for_read_count);
+ DCHECK(!resource->locked_for_write);
+
+ GLC(context3d, context3d->bindTexture(target, resource->gl_id));
+ if (filter != resource->filter) {
+ GLC(context3d, context3d->texParameteri(target,
+ GL_TEXTURE_MIN_FILTER,
+ filter));
+ GLC(context3d, context3d->texParameteri(target,
+ GL_TEXTURE_MAG_FILTER,
+ filter));
+ resource->filter = filter;
+ }
+}
+
+void ResourceProvider::BeginSetPixels(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(!resource->pending_set_pixels);
+ DCHECK(resource->gl_id || resource->allocated);
+ DCHECK(ReadLockFenceHasPassed(resource));
+
+ bool allocate = !resource->allocated;
+ resource->allocated = true;
+ LockForWrite(id);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_pixel_buffer_id);
+ context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
+ context3d->bindBuffer(
+ GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ resource->gl_pixel_buffer_id);
+ if (!resource->gl_upload_query_id)
+ resource->gl_upload_query_id = context3d->createQueryEXT();
+ context3d->beginQueryEXT(
+ GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM,
+ resource->gl_upload_query_id);
+ if (allocate) {
+ context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D,
+ 0, /* level */
+ resource->format,
+ resource->size.width(),
+ resource->size.height(),
+ 0, /* border */
+ resource->format,
+ GL_UNSIGNED_BYTE,
+ NULL);
+ } else {
+ context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
+ 0, /* level */
+ 0, /* x */
+ 0, /* y */
+ resource->size.width(),
+ resource->size.height(),
+ resource->format,
+ GL_UNSIGNED_BYTE,
+ NULL);
}
+ context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM);
+ context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ }
- resource->pendingSetPixels = false;
- unlockForWrite(id);
-}
+ if (resource->pixels)
+ SetPixelsFromBuffer(id);
-void ResourceProvider::allocateForTesting(ResourceId id) {
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- lazyAllocate(resource);
+ resource->pending_set_pixels = true;
}
-void ResourceProvider::lazyAllocate(Resource* resource) {
- DCHECK(resource);
- DCHECK(resource->glId || resource->allocated);
-
- if (resource->allocated || !resource->glId)
- return;
- resource->allocated = true;
- WebGraphicsContext3D* context3d = m_outputSurface->context3d();
- gfx::Size& size = resource->size;
- GLenum format = resource->format;
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
- if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
- GLenum storageFormat = textureToStorageFormat(format);
- GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageFormat, size.width(), size.height()));
- } else
- GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
-}
-
-void ResourceProvider::enableReadLockFences(ResourceProvider::ResourceId id, bool enable) {
- DCHECK(m_threadChecker.CalledOnValidThread());
- ResourceMap::iterator it = m_resources.find(id);
- CHECK(it != m_resources.end());
- Resource* resource = &it->second;
- resource->enableReadLockFences = enable;
-}
+bool ResourceProvider::DidSetPixelsComplete(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(resource->locked_for_write);
+ DCHECK(resource->pending_set_pixels);
-void ResourceProvider::setOffscreenContextProvider(scoped_refptr<cc::ContextProvider> offscreenContextProvider) {
- if (offscreenContextProvider)
- offscreenContextProvider->BindToCurrentThread();
- m_offscreenContextProvider = offscreenContextProvider;
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_upload_query_id);
+ unsigned complete = 1;
+ context3d->getQueryObjectuivEXT(
+ resource->gl_upload_query_id,
+ GL_QUERY_RESULT_AVAILABLE_EXT,
+ &complete);
+ if (!complete)
+ return false;
+ }
+
+ resource->pending_set_pixels = false;
+ UnlockForWrite(id);
+
+ return true;
+}
+
+void ResourceProvider::AbortSetPixels(ResourceId id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ DCHECK(resource->locked_for_write);
+ DCHECK(resource->pending_set_pixels);
+
+ if (resource->gl_id) {
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ DCHECK(context3d);
+ DCHECK(resource->gl_upload_query_id);
+ // CHROMIUM_async_pixel_transfers currently doesn't have a way to
+ // abort an upload. The best we can do is delete the query and
+ // the texture.
+ context3d->deleteQueryEXT(resource->gl_upload_query_id);
+ resource->gl_upload_query_id = 0;
+ context3d->deleteTexture(resource->gl_id);
+ resource->gl_id = CreateTextureId(context3d);
+ resource->allocated = false;
+ }
+
+ resource->pending_set_pixels = false;
+ UnlockForWrite(id);
+}
+
+void ResourceProvider::AllocateForTesting(ResourceId id) {
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ LazyAllocate(resource);
+}
+
+void ResourceProvider::LazyAllocate(Resource* resource) {
+ DCHECK(resource);
+ DCHECK(resource->gl_id || resource->allocated);
+
+ if (resource->allocated || !resource->gl_id)
+ return;
+ resource->allocated = true;
+ WebGraphicsContext3D* context3d = output_surface_->context3d();
+ gfx::Size& size = resource->size;
+ GLenum format = resource->format;
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
+ if (use_texture_storage_ext_ && IsTextureFormatSupportedForStorage(format)) {
+ GLenum storage_format = TextureToStorageFormat(format);
+ GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D,
+ 1,
+ storage_format,
+ size.width(),
+ size.height()));
+ } else
+ GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D,
+ 0,
+ format,
+ size.width(),
+ size.height(),
+ 0,
+ format,
+ GL_UNSIGNED_BYTE,
+ NULL));
+}
+
+void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
+ bool enable) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+ Resource* resource = &it->second;
+ resource->enable_read_lock_fences = enable;
+}
+
+void ResourceProvider::SetOffscreenContextProvider(
+ scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
+ if (offscreen_context_provider)
+ offscreen_context_provider->BindToCurrentThread();
+ offscreen_context_provider_ = offscreen_context_provider;
}
} // namespace cc
diff --git a/cc/resource_provider.h b/cc/resource_provider.h
index dab3896..1cc4f27 100644
--- a/cc/resource_provider.h
+++ b/cc/resource_provider.h
@@ -42,311 +42,354 @@ class TextureUploader;
// This class is not thread-safe and can only be called from the thread it was
// created on (in practice, the impl thread).
class CC_EXPORT ResourceProvider {
-public:
- typedef unsigned ResourceId;
- typedef std::vector<ResourceId> ResourceIdArray;
- typedef std::set<ResourceId> ResourceIdSet;
- typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
- enum TextureUsageHint {
- TextureUsageAny,
- TextureUsageFramebuffer,
- };
- enum ResourceType {
- GLTexture = 1,
- Bitmap,
- };
-
- static scoped_ptr<ResourceProvider> create(OutputSurface*);
-
- virtual ~ResourceProvider();
-
- WebKit::WebGraphicsContext3D* graphicsContext3D();
- TextureCopier* textureCopier() const { return m_textureCopier.get(); }
- int maxTextureSize() const { return m_maxTextureSize; }
- GLenum bestTextureFormat() const { return m_bestTextureFormat; }
- unsigned numResources() const { return m_resources.size(); }
-
- // Checks whether a resource is in use by a consumer.
- bool inUseByConsumer(ResourceId);
-
-
- // Producer interface.
-
- void setDefaultResourceType(ResourceType type) { m_defaultResourceType = type; }
- ResourceType defaultResourceType() const { return m_defaultResourceType; }
- ResourceType resourceType(ResourceId);
-
- // Creates a resource of the default resource type.
- ResourceId createResource(const gfx::Size&, GLenum format, TextureUsageHint);
-
- // Creates a resource which is tagged as being managed for GPU memory accounting purposes.
- ResourceId createManagedResource(const gfx::Size&, GLenum format, TextureUsageHint);
-
- // You can also explicitly create a specific resource type.
- ResourceId createGLTexture(const gfx::Size&, GLenum format, GLenum texturePool, TextureUsageHint);
-
- ResourceId createBitmap(const gfx::Size&);
- // Wraps an external texture into a GL resource.
- ResourceId createResourceFromExternalTexture(unsigned textureId);
-
- // Wraps an external texture mailbox into a GL resource.
- ResourceId createResourceFromTextureMailbox(const TextureMailbox&);
-
- void deleteResource(ResourceId);
-
- // Update pixels from image, copying sourceRect (in image) into destRect (in the resource).
- void setPixels(ResourceId, const uint8_t* image, const gfx::Rect& imageRect, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset);
-
- // Check upload status.
- size_t numBlockingUploads();
- void markPendingUploadsAsNonBlocking();
- double estimatedUploadsPerSecond();
- void flushUploads();
- void releaseCachedData();
-
- // Flush all context operations, kicking uploads and ensuring ordering with
- // respect to other contexts.
- void flush();
-
- // Only flush the command buffer if supported.
- // Returns true if the shallow flush occurred, false otherwise.
- bool shallowFlushIfSupported();
-
- // Creates accounting for a child. Returns a child ID.
- int createChild();
-
- // Destroys accounting for the child, deleting all accounted resources.
- void destroyChild(int child);
-
- // Gets the child->parent resource ID map.
- const ResourceIdMap& getChildToParentMap(int child) const;
-
- // Prepares resources to be transfered to the parent, moving them to
- // mailboxes and serializing meta-data into TransferableResources.
- // Resources are not removed from the ResourceProvider, but are marked as
- // "in use".
- void prepareSendToParent(const ResourceIdArray& resources, TransferableResourceArray* transferableResources);
-
- // Prepares resources to be transfered back to the child, moving them to
- // mailboxes and serializing meta-data into TransferableResources.
- // Resources are removed from the ResourceProvider. Note: the resource IDs
- // passed are in the parent namespace and will be translated to the child
- // namespace when returned.
- void prepareSendToChild(int child, const ResourceIdArray& resources, TransferableResourceArray* transferableResources);
-
- // Receives resources from a child, moving them from mailboxes. Resource IDs
- // passed are in the child namespace, and will be translated to the parent
- // namespace, added to the child->parent map.
- // NOTE: if the sync_point is set on any TransferableResource, this will
- // wait on it.
- void receiveFromChild(int child, const TransferableResourceArray& transferableResources);
-
- // Receives resources from the parent, moving them from mailboxes. Resource IDs
- // passed are in the child namespace.
- // NOTE: if the sync_point is set on any TransferableResource, this will
- // wait on it.
- void receiveFromParent(const TransferableResourceArray& transferableResources);
-
- // Bind the given GL resource to a texture target for sampling using the
- // specified filter for both minification and magnification. The resource
- // must be locked for reading.
- void bindForSampling(ResourceProvider::ResourceId, GLenum target, GLenum filter);
-
- // The following lock classes are part of the ResourceProvider API and are
- // needed to read and write the resource contents. The user must ensure
- // that they only use GL locks on GL resources, etc, and this is enforced
- // by assertions.
- class CC_EXPORT ScopedReadLockGL {
- public:
- ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId);
- ~ScopedReadLockGL();
-
- unsigned textureId() const { return m_textureId; }
-
- private:
- ResourceProvider* m_resourceProvider;
- ResourceProvider::ResourceId m_resourceId;
- unsigned m_textureId;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL);
- };
-
- class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL {
- public:
- ScopedSamplerGL(ResourceProvider*, ResourceProvider::ResourceId, GLenum target, GLenum filter);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScopedSamplerGL);
- };
-
- class CC_EXPORT ScopedWriteLockGL {
- public:
- ScopedWriteLockGL(ResourceProvider*, ResourceProvider::ResourceId);
- ~ScopedWriteLockGL();
-
- unsigned textureId() const { return m_textureId; }
-
- private:
- ResourceProvider* m_resourceProvider;
- ResourceProvider::ResourceId m_resourceId;
- unsigned m_textureId;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
- };
-
- class CC_EXPORT ScopedReadLockSoftware {
- public:
- ScopedReadLockSoftware(ResourceProvider*, ResourceProvider::ResourceId);
- ~ScopedReadLockSoftware();
-
- const SkBitmap* skBitmap() const { return &m_skBitmap; }
-
- private:
- ResourceProvider* m_resourceProvider;
- ResourceProvider::ResourceId m_resourceId;
- SkBitmap m_skBitmap;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware);
- };
-
- class CC_EXPORT ScopedWriteLockSoftware {
- public:
- ScopedWriteLockSoftware(ResourceProvider*, ResourceProvider::ResourceId);
- ~ScopedWriteLockSoftware();
-
- SkCanvas* skCanvas() { return m_skCanvas.get(); }
-
- private:
- ResourceProvider* m_resourceProvider;
- ResourceProvider::ResourceId m_resourceId;
- SkBitmap m_skBitmap;
- scoped_ptr<SkCanvas> m_skCanvas;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
- };
-
- class Fence : public base::RefCounted<Fence> {
- public:
- virtual bool hasPassed() = 0;
- protected:
- friend class base::RefCounted<Fence>;
- virtual ~Fence() {}
- };
-
- // Acquire pixel buffer for resource. The pixel buffer can be used to
- // set resource pixels without performing unnecessary copying.
- void acquirePixelBuffer(ResourceId id);
- void releasePixelBuffer(ResourceId id);
-
- // Map/unmap the acquired pixel buffer.
- uint8_t* mapPixelBuffer(ResourceId id);
- void unmapPixelBuffer(ResourceId id);
-
- // Update pixels from acquired pixel buffer.
- void setPixelsFromBuffer(ResourceId id);
-
- // Asynchronously update pixels from acquired pixel buffer.
- void beginSetPixels(ResourceId id);
- bool didSetPixelsComplete(ResourceId id);
- void abortSetPixels(ResourceId id);
-
- // For tests only! This prevents detecting uninitialized reads.
- // Use setPixels or lockForWrite to allocate implicitly.
- void allocateForTesting(ResourceId id);
-
- // Sets the current read fence. If a resource is locked for read
- // and has read fences enabled, the resource will not allow writes
- // until this fence has passed.
- void setReadLockFence(scoped_refptr<Fence> fence) { m_currentReadLockFence = fence; }
- Fence* getReadLockFence() { return m_currentReadLockFence; }
-
- // Enable read lock fences for a specific resource.
- void enableReadLockFences(ResourceProvider::ResourceId, bool enable);
-
- // Indicates if we can currently lock this resource for write.
- bool canLockForWrite(ResourceId);
-
- cc::ContextProvider* offscreenContextProvider() { return m_offscreenContextProvider.get(); }
- void setOffscreenContextProvider(scoped_refptr<cc::ContextProvider> offscreenContextProvider);
-
-private:
- struct Resource {
- Resource();
- ~Resource();
- Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter);
- Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum filter);
-
- unsigned glId;
- // Pixel buffer used for set pixels without unnecessary copying.
- unsigned glPixelBufferId;
- // Query used to determine when asynchronous set pixels complete.
- unsigned glUploadQueryId;
- TextureMailbox mailbox;
- uint8_t* pixels;
- uint8_t* pixelBuffer;
- int lockForReadCount;
- bool lockedForWrite;
- bool external;
- bool exported;
- bool markedForDeletion;
- bool pendingSetPixels;
- bool allocated;
- bool enableReadLockFences;
- scoped_refptr<Fence> readLockFence;
- gfx::Size size;
- GLenum format;
- // TODO(skyostil): Use a separate sampler object for filter state.
- GLenum filter;
- ResourceType type;
- };
- typedef base::hash_map<ResourceId, Resource> ResourceMap;
- struct Child {
- Child();
- ~Child();
-
- ResourceIdMap childToParentMap;
- ResourceIdMap parentToChildMap;
- };
- typedef base::hash_map<int, Child> ChildMap;
-
- bool readLockFenceHasPassed(Resource* resource) { return !resource->readLockFence ||
- resource->readLockFence->hasPassed(); }
-
- explicit ResourceProvider(OutputSurface*);
- bool initialize();
-
- const Resource* lockForRead(ResourceId);
- void unlockForRead(ResourceId);
- const Resource* lockForWrite(ResourceId);
- void unlockForWrite(ResourceId);
- static void populateSkBitmapWithResource(SkBitmap*, const Resource*);
-
- bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, TransferableResource*);
- void deleteResourceInternal(ResourceMap::iterator it);
- void lazyAllocate(Resource*);
-
- OutputSurface* m_outputSurface;
- ResourceId m_nextId;
- ResourceMap m_resources;
- int m_nextChild;
- ChildMap m_children;
-
- ResourceType m_defaultResourceType;
- bool m_useTextureStorageExt;
- bool m_useTextureUsageHint;
- bool m_useShallowFlush;
- scoped_ptr<TextureUploader> m_textureUploader;
- scoped_ptr<AcceleratedTextureCopier> m_textureCopier;
- int m_maxTextureSize;
- GLenum m_bestTextureFormat;
-
- scoped_refptr<cc::ContextProvider> m_offscreenContextProvider;
-
- base::ThreadChecker m_threadChecker;
-
- scoped_refptr<Fence> m_currentReadLockFence;
-
- DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
+ public:
+ typedef unsigned ResourceId;
+ typedef std::vector<ResourceId> ResourceIdArray;
+ typedef std::set<ResourceId> ResourceIdSet;
+ typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
+ enum TextureUsageHint {
+ TextureUsageAny,
+ TextureUsageFramebuffer,
+ };
+ enum ResourceType {
+ GLTexture = 1,
+ Bitmap,
+ };
+
+ static scoped_ptr<ResourceProvider> Create(OutputSurface* output_surface);
+
+ virtual ~ResourceProvider();
+
+ WebKit::WebGraphicsContext3D* GraphicsContext3D();
+ TextureCopier* texture_copier() const { return texture_copier_.get(); }
+ int max_texture_size() const { return max_texture_size_; }
+ GLenum best_texture_format() const { return best_texture_format_; }
+ unsigned num_resources() const { return resources_.size(); }
+
+ // Checks whether a resource is in use by a consumer.
+ bool InUseByConsumer(ResourceId id);
+
+
+ // Producer interface.
+
+ void set_default_resource_type(ResourceType type) {
+ default_resource_type_ = type;
+ }
+ ResourceType default_resource_type() const { return default_resource_type_; }
+ ResourceType GetResourceType(ResourceId id);
+
+ // Creates a resource of the default resource type.
+ ResourceId CreateResource(gfx::Size size,
+ GLenum format,
+ TextureUsageHint hint);
+
+ // Creates a resource which is tagged as being managed for GPU memory
+ // accounting purposes.
+ ResourceId CreateManagedResource(gfx::Size size,
+ GLenum format,
+ TextureUsageHint hint);
+
+ // You can also explicitly create a specific resource type.
+ ResourceId CreateGLTexture(gfx::Size size,
+ GLenum format,
+ GLenum texture_pool,
+ TextureUsageHint hint);
+
+ ResourceId CreateBitmap(gfx::Size size);
+ // Wraps an external texture into a GL resource.
+ ResourceId CreateResourceFromExternalTexture(unsigned texture_id);
+
+ // Wraps an external texture mailbox into a GL resource.
+ ResourceId CreateResourceFromTextureMailbox(const TextureMailbox& mailbox);
+
+ void DeleteResource(ResourceId id);
+
+ // Update pixels from image, copying source_rect (in image) to dest_offset (in
+ // the resource).
+ void SetPixels(ResourceId id,
+ const uint8_t* image,
+ gfx::Rect image_rect,
+ gfx::Rect source_rect,
+ gfx::Vector2d dest_offset);
+
+ // Check upload status.
+ size_t NumBlockingUploads();
+ void MarkPendingUploadsAsNonBlocking();
+ double EstimatedUploadsPerSecond();
+ void FlushUploads();
+ void ReleaseCachedData();
+
+ // Flush all context operations, kicking uploads and ensuring ordering with
+ // respect to other contexts.
+ void Flush();
+
+ // Only flush the command buffer if supported.
+ // Returns true if the shallow flush occurred, false otherwise.
+ bool ShallowFlushIfSupported();
+
+ // Creates accounting for a child. Returns a child ID.
+ int CreateChild();
+
+ // Destroys accounting for the child, deleting all accounted resources.
+ void DestroyChild(int child);
+
+ // Gets the child->parent resource ID map.
+ const ResourceIdMap& GetChildToParentMap(int child) const;
+
+ // Prepares resources to be transfered to the parent, moving them to
+ // mailboxes and serializing meta-data into TransferableResources.
+ // Resources are not removed from the ResourceProvider, but are marked as
+ // "in use".
+ void PrepareSendToParent(const ResourceIdArray& resources,
+ TransferableResourceArray* transferable_resources);
+
+ // Prepares resources to be transfered back to the child, moving them to
+ // mailboxes and serializing meta-data into TransferableResources.
+ // Resources are removed from the ResourceProvider. Note: the resource IDs
+ // passed are in the parent namespace and will be translated to the child
+ // namespace when returned.
+ void PrepareSendToChild(int child,
+ const ResourceIdArray& resources,
+ TransferableResourceArray* transferable_resources);
+
+ // Receives resources from a child, moving them from mailboxes. Resource IDs
+ // passed are in the child namespace, and will be translated to the parent
+ // namespace, added to the child->parent map.
+ // NOTE: if the sync_point is set on any TransferableResource, this will
+ // wait on it.
+ void ReceiveFromChild(
+ int child, const TransferableResourceArray& transferable_resources);
+
+ // Receives resources from the parent, moving them from mailboxes. Resource
+ // IDs passed are in the child namespace.
+ // NOTE: if the sync_point is set on any TransferableResource, this will
+ // wait on it.
+ void ReceiveFromParent(
+ const TransferableResourceArray& transferable_resources);
+
+ // Bind the given GL resource to a texture target for sampling using the
+ // specified filter for both minification and magnification. The resource
+ // must be locked for reading.
+ void BindForSampling(ResourceProvider::ResourceId resource_id,
+ GLenum target,
+ GLenum filter);
+
+ // The following lock classes are part of the ResourceProvider API and are
+ // needed to read and write the resource contents. The user must ensure
+ // that they only use GL locks on GL resources, etc, and this is enforced
+ // by assertions.
+ class CC_EXPORT ScopedReadLockGL {
+ public:
+ ScopedReadLockGL(ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id);
+ ~ScopedReadLockGL();
+
+ unsigned texture_id() const { return texture_id_; }
+
+ private:
+ ResourceProvider* resource_provider_;
+ ResourceProvider::ResourceId resource_id_;
+ unsigned texture_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL);
+ };
+
+ class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL {
+ public:
+ ScopedSamplerGL(ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id,
+ GLenum target,
+ GLenum filter);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedSamplerGL);
+ };
+
+ class CC_EXPORT ScopedWriteLockGL {
+ public:
+ ScopedWriteLockGL(ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id);
+ ~ScopedWriteLockGL();
+
+ unsigned texture_id() const { return texture_id_; }
+
+ private:
+ ResourceProvider* resource_provider_;
+ ResourceProvider::ResourceId resource_id_;
+ unsigned texture_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
+ };
+
+ class CC_EXPORT ScopedReadLockSoftware {
+ public:
+ ScopedReadLockSoftware(ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id);
+ ~ScopedReadLockSoftware();
+
+ const SkBitmap* sk_bitmap() const { return &sk_bitmap_; }
+
+ private:
+ ResourceProvider* resource_provider_;
+ ResourceProvider::ResourceId resource_id_;
+ SkBitmap sk_bitmap_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware);
+ };
+
+ class CC_EXPORT ScopedWriteLockSoftware {
+ public:
+ ScopedWriteLockSoftware(ResourceProvider* resource_provider,
+ ResourceProvider::ResourceId resource_id);
+ ~ScopedWriteLockSoftware();
+
+ SkCanvas* sk_canvas() { return sk_canvas_.get(); }
+
+ private:
+ ResourceProvider* resource_provider_;
+ ResourceProvider::ResourceId resource_id_;
+ SkBitmap sk_bitmap_;
+ scoped_ptr<SkCanvas> sk_canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
+ };
+
+ class Fence : public base::RefCounted<Fence> {
+ public:
+ Fence() {}
+ virtual bool HasPassed() = 0;
+
+ protected:
+ friend class base::RefCounted<Fence>;
+ virtual ~Fence() {}
+
+ DISALLOW_COPY_AND_ASSIGN(Fence);
+ };
+
+ // Acquire pixel buffer for resource. The pixel buffer can be used to
+ // set resource pixels without performing unnecessary copying.
+ void AcquirePixelBuffer(ResourceId id);
+ void ReleasePixelBuffer(ResourceId id);
+
+ // Map/unmap the acquired pixel buffer.
+ uint8_t* MapPixelBuffer(ResourceId id);
+ void UnmapPixelBuffer(ResourceId id);
+
+ // Update pixels from acquired pixel buffer.
+ void SetPixelsFromBuffer(ResourceId id);
+
+ // Asynchronously update pixels from acquired pixel buffer.
+ void BeginSetPixels(ResourceId id);
+ bool DidSetPixelsComplete(ResourceId id);
+ void AbortSetPixels(ResourceId id);
+
+ // For tests only! This prevents detecting uninitialized reads.
+ // Use SetPixels or LockForWrite to allocate implicitly.
+ void AllocateForTesting(ResourceId id);
+
+ // Sets the current read fence. If a resource is locked for read
+ // and has read fences enabled, the resource will not allow writes
+ // until this fence has passed.
+ void SetReadLockFence(scoped_refptr<Fence> fence) {
+ current_read_lock_fence_ = fence;
+ }
+ Fence* GetReadLockFence() { return current_read_lock_fence_; }
+
+ // Enable read lock fences for a specific resource.
+ void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable);
+
+ // Indicates if we can currently lock this resource for write.
+ bool CanLockForWrite(ResourceId id);
+
+ cc::ContextProvider* offscreen_context_provider() {
+ return offscreen_context_provider_.get();
+ }
+ void SetOffscreenContextProvider(
+ scoped_refptr<cc::ContextProvider> offscreen_context_provider);
+
+ private:
+ struct Resource {
+ Resource();
+ ~Resource();
+ Resource(unsigned texture_id, gfx::Size size, GLenum format, GLenum filter);
+ Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter);
+
+ unsigned gl_id;
+ // Pixel buffer used for set pixels without unnecessary copying.
+ unsigned gl_pixel_buffer_id;
+ // Query used to determine when asynchronous set pixels complete.
+ unsigned gl_upload_query_id;
+ TextureMailbox mailbox;
+ uint8_t* pixels;
+ uint8_t* pixel_buffer;
+ int lock_for_read_count;
+ bool locked_for_write;
+ bool external;
+ bool exported;
+ bool marked_for_deletion;
+ bool pending_set_pixels;
+ bool allocated;
+ bool enable_read_lock_fences;
+ scoped_refptr<Fence> read_lock_fence;
+ gfx::Size size;
+ GLenum format;
+ // TODO(skyostil): Use a separate sampler object for filter state.
+ GLenum filter;
+ ResourceType type;
+ };
+ typedef base::hash_map<ResourceId, Resource> ResourceMap;
+ struct Child {
+ Child();
+ ~Child();
+
+ ResourceIdMap child_to_parent_map;
+ ResourceIdMap parent_to_child_map;
+ };
+ typedef base::hash_map<int, Child> ChildMap;
+
+ bool ReadLockFenceHasPassed(Resource* resource) {
+ return !resource->read_lock_fence ||
+ resource->read_lock_fence->HasPassed();
+ }
+
+ explicit ResourceProvider(OutputSurface* output_surface);
+ bool Initialize();
+
+ const Resource* LockForRead(ResourceId id);
+ void UnlockForRead(ResourceId id);
+ const Resource* LockForWrite(ResourceId id);
+ void UnlockForWrite(ResourceId id);
+ static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
+ const Resource* resource);
+
+ bool TransferResource(WebKit::WebGraphicsContext3D* context,
+ ResourceId id,
+ TransferableResource* resource);
+ void DeleteResourceInternal(ResourceMap::iterator it);
+ void LazyAllocate(Resource* resource);
+
+ OutputSurface* output_surface_;
+ ResourceId next_id_;
+ ResourceMap resources_;
+ int next_child_;
+ ChildMap children_;
+
+ ResourceType default_resource_type_;
+ bool use_texture_storage_ext_;
+ bool use_texture_usage_hint_;
+ bool use_shallow_flush_;
+ scoped_ptr<TextureUploader> texture_uploader_;
+ scoped_ptr<AcceleratedTextureCopier> texture_copier_;
+ int max_texture_size_;
+ GLenum best_texture_format_;
+
+ scoped_refptr<cc::ContextProvider> offscreen_context_provider_;
+
+ base::ThreadChecker thread_checker_;
+
+ scoped_refptr<Fence> current_read_lock_fence_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
};
}
diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc
index 1925f88..7f4f1df 100644
--- a/cc/resource_provider_unittest.cc
+++ b/cc/resource_provider_unittest.cc
@@ -310,9 +310,9 @@ public:
ResourceProviderTest()
: m_sharedData(ContextSharedData::create())
, m_outputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>().PassAs<WebKit::WebGraphicsContext3D>()))
- , m_resourceProvider(ResourceProvider::create(m_outputSurface.get()))
+ , m_resourceProvider(ResourceProvider::Create(m_outputSurface.get()))
{
- m_resourceProvider->setDefaultResourceType(GetParam());
+ m_resourceProvider->set_default_resource_type(GetParam());
}
ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_outputSurface->context3d()); }
@@ -321,12 +321,12 @@ public:
{
if (GetParam() == ResourceProvider::GLTexture) {
ResourceProvider::ScopedReadLockGL lockGL(m_resourceProvider.get(), id);
- ASSERT_NE(0U, lockGL.textureId());
- context()->bindTexture(GL_TEXTURE_2D, lockGL.textureId());
+ ASSERT_NE(0U, lockGL.texture_id());
+ context()->bindTexture(GL_TEXTURE_2D, lockGL.texture_id());
context()->getPixels(size, format, pixels);
} else if (GetParam() == ResourceProvider::Bitmap) {
ResourceProvider::ScopedReadLockSoftware lockSoftware(m_resourceProvider.get(), id);
- memcpy(pixels, lockSoftware.skBitmap()->getPixels(), lockSoftware.skBitmap()->getSize());
+ memcpy(pixels, lockSoftware.sk_bitmap()->getPixels(), lockSoftware.sk_bitmap()->getSize());
}
}
@@ -339,15 +339,15 @@ public:
{
DCHECK_EQ(GetParam(), ResourceProvider::GLTexture);
ResourceProvider::ScopedReadLockGL lockGL(resourceProvider, id);
- EXPECT_NE(0u, lockGL.textureId());
- ResourceProviderContext* context = static_cast<ResourceProviderContext*>(resourceProvider->graphicsContext3D());
- context->bindTexture(GL_TEXTURE_2D, lockGL.textureId());
+ EXPECT_NE(0u, lockGL.texture_id());
+ ResourceProviderContext* context = static_cast<ResourceProviderContext*>(resourceProvider->GraphicsContext3D());
+ context->bindTexture(GL_TEXTURE_2D, lockGL.texture_id());
return context->getTextureFilter();
}
void expectNumResources(int count)
{
- EXPECT_EQ(count, static_cast<int>(m_resourceProvider->numResources()));
+ EXPECT_EQ(count, static_cast<int>(m_resourceProvider->num_resources()));
if (GetParam() == ResourceProvider::GLTexture)
EXPECT_EQ(count, context()->textureCount());
}
@@ -365,18 +365,18 @@ TEST_P(ResourceProviderTest, Basic)
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id = m_resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = m_resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
expectNumResources(1);
uint8_t data[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
- m_resourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
+ m_resourceProvider->SetPixels(id, data, rect, rect, gfx::Vector2d());
uint8_t result[4] = {0};
getResourcePixels(id, size, format, result);
EXPECT_EQ(0, memcmp(data, result, pixelSize));
- m_resourceProvider->deleteResource(id);
+ m_resourceProvider->DeleteResource(id);
expectNumResources(0);
}
@@ -387,11 +387,11 @@ TEST_P(ResourceProviderTest, Upload)
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(16U, pixelSize);
- ResourceProvider::ResourceId id = m_resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = m_resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t image[16] = {0};
gfx::Rect imageRect(gfx::Point(), size);
- m_resourceProvider->setPixels(id, image, imageRect, imageRect, gfx::Vector2d());
+ m_resourceProvider->SetPixels(id, image, imageRect, imageRect, gfx::Vector2d());
for (uint8_t i = 0 ; i < pixelSize; ++i)
image[i] = i;
@@ -400,7 +400,7 @@ TEST_P(ResourceProviderTest, Upload)
{
gfx::Rect sourceRect(0, 0, 1, 1);
gfx::Vector2d destOffset(0, 0);
- m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffset);
+ m_resourceProvider->SetPixels(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
@@ -410,7 +410,7 @@ TEST_P(ResourceProviderTest, Upload)
{
gfx::Rect sourceRect(0, 0, 1, 1);
gfx::Vector2d destOffset(1, 1);
- m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffset);
+ m_resourceProvider->SetPixels(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 2, 3};
@@ -420,7 +420,7 @@ TEST_P(ResourceProviderTest, Upload)
{
gfx::Rect sourceRect(1, 0, 1, 1);
gfx::Vector2d destOffset(0, 1);
- m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffset);
+ m_resourceProvider->SetPixels(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
4, 5, 6, 7, 0, 1, 2, 3};
@@ -431,7 +431,7 @@ TEST_P(ResourceProviderTest, Upload)
gfx::Rect offsetImageRect(gfx::Point(100, 100), size);
gfx::Rect sourceRect(100, 100, 1, 1);
gfx::Vector2d destOffset(1, 0);
- m_resourceProvider->setPixels(id, image, offsetImageRect, sourceRect, destOffset);
+ m_resourceProvider->SetPixels(id, image, offsetImageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 1, 2, 3,
4, 5, 6, 7, 0, 1, 2, 3};
@@ -440,7 +440,7 @@ TEST_P(ResourceProviderTest, Upload)
}
- m_resourceProvider->deleteResource(id);
+ m_resourceProvider->DeleteResource(id);
}
TEST_P(ResourceProviderTest, TransferResources)
@@ -450,23 +450,23 @@ TEST_P(ResourceProviderTest, TransferResources)
return;
scoped_ptr<OutputSurface> childOutputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
- scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get()));
+ scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::Create(childOutputSurface.get()));
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id1 = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id1 = childResourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data1[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
- childResourceProvider->setPixels(id1, data1, rect, rect, gfx::Vector2d());
+ childResourceProvider->SetPixels(id1, data1, rect, rect, gfx::Vector2d());
- ResourceProvider::ResourceId id2 = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id2 = childResourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data2[4] = {5, 5, 5, 5};
- childResourceProvider->setPixels(id2, data2, rect, rect, gfx::Vector2d());
+ childResourceProvider->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
- int childId = m_resourceProvider->createChild();
+ int childId = m_resourceProvider->CreateChild();
{
// Transfer some resources to the parent.
@@ -474,23 +474,23 @@ TEST_P(ResourceProviderTest, TransferResources)
resourceIdsToTransfer.push_back(id1);
resourceIdsToTransfer.push_back(id2);
TransferableResourceArray list;
- childResourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ childResourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(2u, list.size());
EXPECT_NE(0u, list[0].sync_point);
EXPECT_NE(0u, list[1].sync_point);
- EXPECT_TRUE(childResourceProvider->inUseByConsumer(id1));
- EXPECT_TRUE(childResourceProvider->inUseByConsumer(id2));
- m_resourceProvider->receiveFromChild(childId, list);
+ EXPECT_TRUE(childResourceProvider->InUseByConsumer(id1));
+ EXPECT_TRUE(childResourceProvider->InUseByConsumer(id2));
+ m_resourceProvider->ReceiveFromChild(childId, list);
}
- EXPECT_EQ(2u, m_resourceProvider->numResources());
- ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->getChildToParentMap(childId);
+ EXPECT_EQ(2u, m_resourceProvider->num_resources());
+ ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->GetChildToParentMap(childId);
ResourceProvider::ResourceId mappedId1 = resourceMap[id1];
ResourceProvider::ResourceId mappedId2 = resourceMap[id2];
EXPECT_NE(0u, mappedId1);
EXPECT_NE(0u, mappedId2);
- EXPECT_FALSE(m_resourceProvider->inUseByConsumer(id1));
- EXPECT_FALSE(m_resourceProvider->inUseByConsumer(id2));
+ EXPECT_FALSE(m_resourceProvider->InUseByConsumer(id1));
+ EXPECT_FALSE(m_resourceProvider->InUseByConsumer(id2));
uint8_t result[4] = {0};
getResourcePixels(mappedId1, size, format, result);
@@ -505,7 +505,7 @@ TEST_P(ResourceProviderTest, TransferResources)
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(id1);
TransferableResourceArray list;
- childResourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ childResourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
EXPECT_EQ(0u, list.size());
}
@@ -515,27 +515,27 @@ TEST_P(ResourceProviderTest, TransferResources)
resourceIdsToTransfer.push_back(mappedId1);
resourceIdsToTransfer.push_back(mappedId2);
TransferableResourceArray list;
- m_resourceProvider->prepareSendToChild(childId, resourceIdsToTransfer, &list);
+ m_resourceProvider->PrepareSendToChild(childId, resourceIdsToTransfer, &list);
ASSERT_EQ(2u, list.size());
EXPECT_NE(0u, list[0].sync_point);
EXPECT_NE(0u, list[1].sync_point);
- childResourceProvider->receiveFromParent(list);
+ childResourceProvider->ReceiveFromParent(list);
}
- EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1));
- EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2));
+ EXPECT_FALSE(childResourceProvider->InUseByConsumer(id1));
+ EXPECT_FALSE(childResourceProvider->InUseByConsumer(id2));
ResourceProviderContext* childContext3D = static_cast<ResourceProviderContext*>(childOutputSurface->context3d());
{
ResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), id1);
- ASSERT_NE(0U, lock.textureId());
- childContext3D->bindTexture(GL_TEXTURE_2D, lock.textureId());
+ ASSERT_NE(0U, lock.texture_id());
+ childContext3D->bindTexture(GL_TEXTURE_2D, lock.texture_id());
childContext3D->getPixels(size, format, result);
EXPECT_EQ(0, memcmp(data1, result, pixelSize));
}
{
ResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), id2);
- ASSERT_NE(0U, lock.textureId());
- childContext3D->bindTexture(GL_TEXTURE_2D, lock.textureId());
+ ASSERT_NE(0U, lock.texture_id());
+ childContext3D->bindTexture(GL_TEXTURE_2D, lock.texture_id());
childContext3D->getPixels(size, format, result);
EXPECT_EQ(0, memcmp(data2, result, pixelSize));
}
@@ -546,18 +546,18 @@ TEST_P(ResourceProviderTest, TransferResources)
resourceIdsToTransfer.push_back(id1);
resourceIdsToTransfer.push_back(id2);
TransferableResourceArray list;
- childResourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ childResourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(2u, list.size());
EXPECT_NE(0u, list[0].sync_point);
EXPECT_NE(0u, list[1].sync_point);
- EXPECT_TRUE(childResourceProvider->inUseByConsumer(id1));
- EXPECT_TRUE(childResourceProvider->inUseByConsumer(id2));
- m_resourceProvider->receiveFromChild(childId, list);
+ EXPECT_TRUE(childResourceProvider->InUseByConsumer(id1));
+ EXPECT_TRUE(childResourceProvider->InUseByConsumer(id2));
+ m_resourceProvider->ReceiveFromChild(childId, list);
}
- EXPECT_EQ(2u, m_resourceProvider->numResources());
- m_resourceProvider->destroyChild(childId);
- EXPECT_EQ(0u, m_resourceProvider->numResources());
+ EXPECT_EQ(2u, m_resourceProvider->num_resources());
+ m_resourceProvider->DestroyChild(childId);
+ EXPECT_EQ(0u, m_resourceProvider->num_resources());
}
TEST_P(ResourceProviderTest, DeleteTransferredResources)
@@ -567,50 +567,50 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
return;
scoped_ptr<OutputSurface> childOutputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
- scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get()));
+ scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::Create(childOutputSurface.get()));
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = childResourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
- childResourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
+ childResourceProvider->SetPixels(id, data, rect, rect, gfx::Vector2d());
- int childId = m_resourceProvider->createChild();
+ int childId = m_resourceProvider->CreateChild();
{
// Transfer some resource to the parent.
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(id);
TransferableResourceArray list;
- childResourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ childResourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_NE(0u, list[0].sync_point);
- EXPECT_TRUE(childResourceProvider->inUseByConsumer(id));
- m_resourceProvider->receiveFromChild(childId, list);
+ EXPECT_TRUE(childResourceProvider->InUseByConsumer(id));
+ m_resourceProvider->ReceiveFromChild(childId, list);
}
// Delete textures in the child, while they are transfered.
- childResourceProvider->deleteResource(id);
- EXPECT_EQ(1u, childResourceProvider->numResources());
+ childResourceProvider->DeleteResource(id);
+ EXPECT_EQ(1u, childResourceProvider->num_resources());
{
// Transfer resources back from the parent to the child.
- ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->getChildToParentMap(childId);
+ ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->GetChildToParentMap(childId);
ResourceProvider::ResourceId mappedId = resourceMap[id];
EXPECT_NE(0u, mappedId);
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(mappedId);
TransferableResourceArray list;
- m_resourceProvider->prepareSendToChild(childId, resourceIdsToTransfer, &list);
+ m_resourceProvider->PrepareSendToChild(childId, resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_NE(0u, list[0].sync_point);
- childResourceProvider->receiveFromParent(list);
+ childResourceProvider->ReceiveFromParent(list);
}
- EXPECT_EQ(0u, childResourceProvider->numResources());
+ EXPECT_EQ(0u, childResourceProvider->num_resources());
}
TEST_P(ResourceProviderTest, TextureFilters)
@@ -620,34 +620,34 @@ TEST_P(ResourceProviderTest, TextureFilters)
return;
scoped_ptr<OutputSurface> childOutputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
- scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get()));
+ scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::Create(childOutputSurface.get()));
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = childResourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
- childResourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
+ childResourceProvider->SetPixels(id, data, rect, rect, gfx::Vector2d());
EXPECT_EQ(GL_LINEAR, getResourceFilter(childResourceProvider.get(), id));
setResourceFilter(childResourceProvider.get(), id, GL_NEAREST);
EXPECT_EQ(GL_NEAREST, getResourceFilter(childResourceProvider.get(), id));
- int childId = m_resourceProvider->createChild();
+ int childId = m_resourceProvider->CreateChild();
{
// Transfer some resource to the parent.
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(id);
TransferableResourceArray list;
- childResourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ childResourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_EQ(GL_NEAREST, list[0].filter);
- m_resourceProvider->receiveFromChild(childId, list);
+ m_resourceProvider->ReceiveFromChild(childId, list);
}
- ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->getChildToParentMap(childId);
+ ResourceProvider::ResourceIdMap resourceMap = m_resourceProvider->GetChildToParentMap(childId);
ResourceProvider::ResourceId mappedId = resourceMap[id];
EXPECT_NE(0u, mappedId);
EXPECT_EQ(GL_NEAREST, getResourceFilter(m_resourceProvider.get(), mappedId));
@@ -658,10 +658,10 @@ TEST_P(ResourceProviderTest, TextureFilters)
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(mappedId);
TransferableResourceArray list;
- m_resourceProvider->prepareSendToChild(childId, resourceIdsToTransfer, &list);
+ m_resourceProvider->PrepareSendToChild(childId, resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_EQ(GL_LINEAR, list[0].filter);
- childResourceProvider->receiveFromParent(list);
+ childResourceProvider->ReceiveFromParent(list);
}
EXPECT_EQ(GL_LINEAR, getResourceFilter(childResourceProvider.get(), id));
setResourceFilter(childResourceProvider.get(), id, GL_NEAREST);
@@ -691,7 +691,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
unsigned releaseSyncPoint = 0;
TextureMailbox::ReleaseCallback callback = base::Bind(ReleaseTextureMailbox, &releaseSyncPoint);
- ResourceProvider::ResourceId resource = m_resourceProvider->createResourceFromTextureMailbox(TextureMailbox(mailbox, callback, syncPoint));
+ ResourceProvider::ResourceId resource = m_resourceProvider->CreateResourceFromTextureMailbox(TextureMailbox(mailbox, callback, syncPoint));
EXPECT_EQ(1u, context()->textureCount());
EXPECT_EQ(0u, releaseSyncPoint);
@@ -700,7 +700,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(resource);
TransferableResourceArray list;
- m_resourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ m_resourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_LE(syncPoint, list[0].sync_point);
EXPECT_EQ(0u, memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name)));
@@ -719,11 +719,11 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
EXPECT_LT(0u, list[0].sync_point);
// Receive the resource, then delete it, expect the sync points to be consistent.
- m_resourceProvider->receiveFromParent(list);
+ m_resourceProvider->ReceiveFromParent(list);
EXPECT_EQ(1u, context()->textureCount());
EXPECT_EQ(0u, releaseSyncPoint);
- m_resourceProvider->deleteResource(resource);
+ m_resourceProvider->DeleteResource(resource);
EXPECT_LE(list[0].sync_point, releaseSyncPoint);
}
@@ -733,7 +733,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
syncPoint = releaseSyncPoint;
EXPECT_LT(0u, syncPoint);
releaseSyncPoint = 0;
- resource = m_resourceProvider->createResourceFromTextureMailbox(TextureMailbox(mailbox, callback, syncPoint));
+ resource = m_resourceProvider->CreateResourceFromTextureMailbox(TextureMailbox(mailbox, callback, syncPoint));
EXPECT_EQ(1u, context()->textureCount());
EXPECT_EQ(0u, releaseSyncPoint);
@@ -742,7 +742,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(resource);
TransferableResourceArray list;
- m_resourceProvider->prepareSendToParent(resourceIdsToTransfer, &list);
+ m_resourceProvider->PrepareSendToParent(resourceIdsToTransfer, &list);
ASSERT_EQ(1u, list.size());
EXPECT_LE(syncPoint, list[0].sync_point);
EXPECT_EQ(0u, memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name)));
@@ -761,12 +761,12 @@ TEST_P(ResourceProviderTest, TransferMailboxResources)
EXPECT_LT(0u, list[0].sync_point);
// Delete the resource, which shouldn't do anything.
- m_resourceProvider->deleteResource(resource);
+ m_resourceProvider->DeleteResource(resource);
EXPECT_EQ(1u, context()->textureCount());
EXPECT_EQ(0u, releaseSyncPoint);
// Then receive the resource which should release the mailbox, expect the sync points to be consistent.
- m_resourceProvider->receiveFromParent(list);
+ m_resourceProvider->ReceiveFromParent(list);
EXPECT_LE(list[0].sync_point, releaseSyncPoint);
}
@@ -793,7 +793,7 @@ TEST_P(ResourceProviderTest, ScopedSampler)
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
@@ -807,8 +807,8 @@ TEST_P(ResourceProviderTest, ScopedSampler)
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM));
- ResourceProvider::ResourceId id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(id);
+ ResourceProvider::ResourceId id = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceProvider->AllocateForTesting(id);
// Creating a sampler with the default filter should not change any texture
// parameters.
@@ -844,7 +844,7 @@ TEST_P(ResourceProviderTest, ManagedResource)
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
@@ -857,7 +857,7 @@ TEST_P(ResourceProviderTest, ManagedResource)
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_MANAGED_CHROMIUM));
- ResourceProvider::ResourceId id = resourceProvider->createManagedResource(size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = resourceProvider->CreateManagedResource(size, format, ResourceProvider::TextureUsageAny);
Mock::VerifyAndClearExpectations(context);
}
@@ -899,7 +899,7 @@ TEST_P(ResourceProviderTest, TextureAllocation)
int textureId = 123;
AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext3D*>(outputSurface->context3d());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outputSurface.get()));
// Lazy allocation. Don't allocate when creating the resource.
EXPECT_CALL(*context, createTexture()).WillOnce(Return(textureId));
@@ -907,8 +907,8 @@ TEST_P(ResourceProviderTest, TextureAllocation)
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(1);
EXPECT_CALL(*context, texImage2D(_,_,_,_,_,_,_,_,_)).Times(0);
EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,_,_,_,_,_,_)).Times(0);
- id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
- resourceProvider->deleteResource(id);
+ id = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceProvider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
// Do allocate when we set the pixels.
@@ -917,9 +917,9 @@ TEST_P(ResourceProviderTest, TextureAllocation)
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(3);
EXPECT_CALL(*context, texImage2D(_,_,_,2,2,_,_,_,_)).Times(1);
EXPECT_CALL(*context, texSubImage2D(_,_,_,_,2,2,_,_,_)).Times(1);
- id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
- resourceProvider->setPixels(id, pixels, rect, rect, offset);
- resourceProvider->deleteResource(id);
+ id = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceProvider->SetPixels(id, pixels, rect, rect, offset);
+ resourceProvider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
// Same for setPixelsFromBuffer
@@ -928,11 +928,11 @@ TEST_P(ResourceProviderTest, TextureAllocation)
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(3);
EXPECT_CALL(*context, texImage2D(_,_,_,2,2,_,_,_,_)).Times(1);
EXPECT_CALL(*context, texSubImage2D(_,_,_,_,2,2,_,_,_)).Times(1);
- id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
- resourceProvider->acquirePixelBuffer(id);
- resourceProvider->setPixelsFromBuffer(id);
- resourceProvider->releasePixelBuffer(id);
- resourceProvider->deleteResource(id);
+ id = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceProvider->AcquirePixelBuffer(id);
+ resourceProvider->SetPixelsFromBuffer(id);
+ resourceProvider->ReleasePixelBuffer(id);
+ resourceProvider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
// Same for async version.
@@ -940,11 +940,11 @@ TEST_P(ResourceProviderTest, TextureAllocation)
EXPECT_CALL(*context, deleteTexture(textureId)).Times(1);
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(2);
EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1);
- id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
- resourceProvider->acquirePixelBuffer(id);
- resourceProvider->beginSetPixels(id);
- resourceProvider->releasePixelBuffer(id);
- resourceProvider->deleteResource(id);
+ id = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceProvider->AcquirePixelBuffer(id);
+ resourceProvider->BeginSetPixels(id);
+ resourceProvider->ReleasePixelBuffer(id);
+ resourceProvider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
}
diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
index f305946..14b5008 100644
--- a/cc/resource_update_controller.cc
+++ b/cc/resource_update_controller.cc
@@ -61,7 +61,7 @@ size_t ResourceUpdateController::maxPartialTextureUpdates()
size_t ResourceUpdateController::maxFullUpdatesPerTick(
ResourceProvider* resourceProvider)
{
- double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond();
+ double texturesPerSecond = resourceProvider->EstimatedUploadsPerSecond();
size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond);
return texturesPerTick ? texturesPerTick : 1;
}
@@ -125,10 +125,10 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
texture->acquireBackingTexture(m_resourceProvider);
DCHECK(texture->haveBackingTexture());
- DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
+ DCHECK(m_resourceProvider->GetResourceType(texture->resourceId()) ==
ResourceProvider::GLTexture);
- cc::ContextProvider* offscreenContexts = m_resourceProvider->offscreenContextProvider();
+ cc::ContextProvider* offscreenContexts = m_resourceProvider->offscreen_context_provider();
ResourceProvider::ScopedWriteLockGL lock(
m_resourceProvider, texture->resourceId());
@@ -136,14 +136,14 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
// Flush the compositor context to ensure that textures there are available
// in the shared context. Do this after locking/creating the compositor
// texture.
- m_resourceProvider->flush();
+ m_resourceProvider->Flush();
// Make sure skia uses the correct GL context.
offscreenContexts->Context3d()->makeContextCurrent();
// Create an accelerated canvas to draw on.
skia::RefPtr<SkCanvas> canvas = createAcceleratedCanvas(
- offscreenContexts->GrContext(), texture->size(), lock.textureId());
+ offscreenContexts->GrContext(), texture->size(), lock.texture_id());
// The compositor expects the textures to be upside-down so it can flip
// the final composited image. Ganesh renders the image upright so we
@@ -171,7 +171,7 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
offscreenContexts->Context3d()->flush();
// Use the compositor's GL context again.
- m_resourceProvider->graphicsContext3D()->makeContextCurrent();
+ m_resourceProvider->GraphicsContext3D()->makeContextCurrent();
}
if (update.bitmap) {
@@ -194,10 +194,10 @@ void ResourceUpdateController::finalize()
while (m_queue->partialUploadSize())
updateTexture(m_queue->takeFirstPartialUpload());
- m_resourceProvider->flushUploads();
+ m_resourceProvider->FlushUploads();
if (m_queue->copySize()) {
- TextureCopier* copier = m_resourceProvider->textureCopier();
+ TextureCopier* copier = m_resourceProvider->texture_copier();
while (m_queue->copySize())
copier->copyTexture(m_queue->takeFirstCopy());
@@ -240,12 +240,12 @@ base::TimeDelta ResourceUpdateController::pendingUpdateTime() const
{
base::TimeDelta updateOneResourceTime =
updateMoreTexturesTime() / updateMoreTexturesSize();
- return updateOneResourceTime * m_resourceProvider->numBlockingUploads();
+ return updateOneResourceTime * m_resourceProvider->NumBlockingUploads();
}
bool ResourceUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
{
- while (m_resourceProvider->numBlockingUploads() < maxBlockingUpdates()) {
+ while (m_resourceProvider->NumBlockingUploads() < maxBlockingUpdates()) {
if (!m_queue->fullUploadSize())
return false;
@@ -282,7 +282,7 @@ void ResourceUpdateController::updateMoreTexturesNow()
while (m_queue->fullUploadSize() && uploads--)
updateTexture(m_queue->takeFirstFullUpload());
- m_resourceProvider->flushUploads();
+ m_resourceProvider->FlushUploads();
}
} // namespace cc
diff --git a/cc/resource_update_controller_unittest.cc b/cc/resource_update_controller_unittest.cc
index b9c0f66..148d45a 100644
--- a/cc/resource_update_controller_unittest.cc
+++ b/cc/resource_update_controller_unittest.cc
@@ -133,7 +133,7 @@ protected:
}
m_resourceManager->prioritizeTextures();
- m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
+ m_resourceProvider = ResourceProvider::Create(m_outputSurface.get());
}
diff --git a/cc/scoped_resource.cc b/cc/scoped_resource.cc
index c5894aa..709c73d 100644
--- a/cc/scoped_resource.cc
+++ b/cc/scoped_resource.cc
@@ -21,7 +21,7 @@ bool ScopedResource::Allocate(const gfx::Size& size, GLenum format,
DCHECK(!size.IsEmpty());
set_dimensions(size, format);
- set_id(resource_provider_->createResource(size, format, hint));
+ set_id(resource_provider_->CreateResource(size, format, hint));
#ifndef NDEBUG
allocate_thread_id_ = base::PlatformThread::CurrentId();
@@ -35,7 +35,7 @@ void ScopedResource::Free() {
#ifndef NDEBUG
DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId());
#endif
- resource_provider_->deleteResource(id());
+ resource_provider_->DeleteResource(id());
}
set_id(0);
}
diff --git a/cc/scoped_resource_unittest.cc b/cc/scoped_resource_unittest.cc
index 902052c..6c985f6 100644
--- a/cc/scoped_resource_unittest.cc
+++ b/cc/scoped_resource_unittest.cc
@@ -18,7 +18,7 @@ namespace {
TEST(ScopedResourceTest, NewScopedResource)
{
scoped_ptr<OutputSurface> context(createFakeOutputSurface());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(context.get()));
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
// New scoped textures do not hold a texture yet.
@@ -32,7 +32,7 @@ TEST(ScopedResourceTest, NewScopedResource)
TEST(ScopedResourceTest, CreateScopedResource)
{
scoped_ptr<OutputSurface> context(createFakeOutputSurface());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(context.get()));
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
@@ -48,53 +48,53 @@ TEST(ScopedResourceTest, CreateScopedResource)
TEST(ScopedResourceTest, ScopedResourceIsDeleted)
{
scoped_ptr<OutputSurface> context(createFakeOutputSurface());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(context.get()));
{
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
- EXPECT_EQ(0u, resourceProvider->numResources());
+ EXPECT_EQ(0u, resourceProvider->num_resources());
texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
}
- EXPECT_EQ(0u, resourceProvider->numResources());
+ EXPECT_EQ(0u, resourceProvider->num_resources());
{
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
- EXPECT_EQ(0u, resourceProvider->numResources());
+ EXPECT_EQ(0u, resourceProvider->num_resources());
texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
texture->Free();
- EXPECT_EQ(0u, resourceProvider->numResources());
+ EXPECT_EQ(0u, resourceProvider->num_resources());
}
}
TEST(ScopedResourceTest, LeakScopedResource)
{
scoped_ptr<OutputSurface> context(createFakeOutputSurface());
- scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(context.get()));
{
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
- EXPECT_EQ(0u, resourceProvider->numResources());
+ EXPECT_EQ(0u, resourceProvider->num_resources());
texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
texture->Leak();
EXPECT_EQ(0u, texture->id());
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
texture->Free();
EXPECT_EQ(0u, texture->id());
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
}
- EXPECT_EQ(1u, resourceProvider->numResources());
+ EXPECT_EQ(1u, resourceProvider->num_resources());
}
} // namespace
diff --git a/cc/single_thread_proxy.cc b/cc/single_thread_proxy.cc
index 2807c2b..fda04ad 100644
--- a/cc/single_thread_proxy.cc
+++ b/cc/single_thread_proxy.cc
@@ -156,7 +156,7 @@ bool SingleThreadProxy::recreateOutputSurface()
initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
if (initialized) {
m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities();
- m_layerTreeHostImpl->resourceProvider()->setOffscreenContextProvider(offscreenContextProvider);
+ m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(offscreenContextProvider);
} else if (offscreenContextProvider) {
offscreenContextProvider->VerifyContexts();
}
@@ -419,7 +419,7 @@ bool SingleThreadProxy::doComposite(scoped_refptr<cc::ContextProvider> offscreen
DebugScopedSetImplThread impl(this);
base::AutoReset<bool> markInside(&m_insideDraw, true);
- m_layerTreeHostImpl->resourceProvider()->setOffscreenContextProvider(offscreenContextProvider);
+ m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(offscreenContextProvider);
if (!m_layerTreeHostImpl->visible())
return false;
@@ -442,7 +442,7 @@ bool SingleThreadProxy::doComposite(scoped_refptr<cc::ContextProvider> offscreen
}
if (m_outputSurfaceLost) {
- if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resourceProvider()->offscreenContextProvider())
+ if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resourceProvider()->offscreen_context_provider())
offscreenContexts->VerifyContexts();
m_layerTreeHost->didLoseOutputSurface();
return false;
diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc
index 9b025c8..3613a4c 100644
--- a/cc/software_renderer.cc
+++ b/cc/software_renderer.cc
@@ -71,10 +71,10 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client,
, m_outputDevice(outputSurface->software_device())
, m_skCurrentCanvas(0)
{
- m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap);
+ m_resourceProvider->set_default_resource_type(ResourceProvider::Bitmap);
- m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize();
- m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat();
+ m_capabilities.maxTextureSize = m_resourceProvider->max_texture_size();
+ m_capabilities.bestTextureFormat = m_resourceProvider->best_texture_format();
m_capabilities.usingSetVisibility = true;
// The updater can access bitmaps while the SoftwareRenderer is using them.
m_capabilities.allowPartialTextureUpdates = true;
@@ -170,7 +170,7 @@ void SoftwareRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame)
bool SoftwareRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResource* texture, const gfx::Rect& framebufferRect)
{
m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWriteLockSoftware(m_resourceProvider, texture->id()));
- m_skCurrentCanvas = m_currentFramebufferLock->skCanvas();
+ m_skCurrentCanvas = m_currentFramebufferLock->sk_canvas();
initializeMatrices(frame, framebufferRect, false);
setDrawViewportSize(framebufferRect.size());
@@ -221,7 +221,7 @@ void SoftwareRenderer::setDrawViewportSize(const gfx::Size& viewportSize)
bool SoftwareRenderer::isSoftwareResource(ResourceProvider::ResourceId id) const
{
- switch (m_resourceProvider->resourceType(id)) {
+ switch (m_resourceProvider->GetResourceType(id)) {
case ResourceProvider::GLTexture:
return false;
case ResourceProvider::Bitmap:
@@ -312,7 +312,7 @@ void SoftwareRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureD
// FIXME: Add support for non-premultiplied alpha.
ResourceProvider::ScopedReadLockSoftware lock(m_resourceProvider, quad->resource_id);
- const SkBitmap* bitmap = lock.skBitmap();
+ const SkBitmap* bitmap = lock.sk_bitmap();
gfx::RectF uvRect = gfx::ScaleRect(gfx::BoundingRect(quad->uv_top_left, quad->uv_bottom_right),
bitmap->width(),
bitmap->height());
@@ -331,7 +331,7 @@ void SoftwareRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQua
SkRect uvRect = gfx::RectFToSkRect(quad->tex_coord_rect);
m_skCurrentPaint.setFilterBitmap(true);
- m_skCurrentCanvas->drawBitmapRectToRect(*lock.skBitmap(), &uvRect,
+ m_skCurrentCanvas->drawBitmapRectToRect(*lock.sk_bitmap(), &uvRect,
gfx::RectFToSkRect(quadVertexRect()),
&m_skCurrentPaint);
}
@@ -351,7 +351,7 @@ void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const Rende
SkMatrix contentMat;
contentMat.setRectToRect(contentRect, destRect, SkMatrix::kFill_ScaleToFit);
- const SkBitmap* content = lock.skBitmap();
+ const SkBitmap* content = lock.sk_bitmap();
skia::RefPtr<SkShader> shader = skia::AdoptRef(
SkShader::CreateBitmapShader(*content,
SkShader::kClamp_TileMode,
@@ -366,7 +366,7 @@ void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const Rende
if (quad->mask_resource_id) {
ResourceProvider::ScopedReadLockSoftware maskLock(m_resourceProvider, quad->mask_resource_id);
- const SkBitmap* mask = maskLock.skBitmap();
+ const SkBitmap* mask = maskLock.sk_bitmap();
SkRect maskRect = SkRect::MakeXYWH(
quad->mask_uv_rect.x() * mask->width(),
diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc
index bacea0c..1f79bba 100644
--- a/cc/software_renderer_unittest.cc
+++ b/cc/software_renderer_unittest.cc
@@ -33,7 +33,7 @@ public:
void initializeRenderer() {
m_outputSurface = FakeOutputSurface::CreateSoftware(make_scoped_ptr(new SoftwareOutputDevice));
- m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
+ m_resourceProvider = ResourceProvider::Create(m_outputSurface.get());
m_renderer = SoftwareRenderer::create(this, m_outputSurface.get(), resourceProvider());
}
@@ -117,8 +117,8 @@ TEST_F(SoftwareRendererTest, tileQuad)
setViewportSize(outerSize);
initializeRenderer();
- ResourceProvider::ResourceId resourceYellow = resourceProvider()->createResource(outerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
- ResourceProvider::ResourceId resourceCyan = resourceProvider()->createResource(innerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceYellow = resourceProvider()->CreateResource(outerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceCyan = resourceProvider()->CreateResource(innerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
SkColor yellow = SK_ColorYELLOW;
SkColor cyan = SK_ColorCYAN;
@@ -129,8 +129,8 @@ TEST_F(SoftwareRendererTest, tileQuad)
for (int i = 0; i < innerPixels; i++)
cyanPixels[i] = cyan;
- resourceProvider()->setPixels(resourceYellow, reinterpret_cast<uint8_t*>(yellowPixels.get()), gfx::Rect(outerSize), gfx::Rect(outerSize), gfx::Vector2d());
- resourceProvider()->setPixels(resourceCyan, reinterpret_cast<uint8_t*>(cyanPixels.get()), gfx::Rect(innerSize), gfx::Rect(innerSize), gfx::Vector2d());
+ resourceProvider()->SetPixels(resourceYellow, reinterpret_cast<uint8_t*>(yellowPixels.get()), gfx::Rect(outerSize), gfx::Rect(outerSize), gfx::Vector2d());
+ resourceProvider()->SetPixels(resourceCyan, reinterpret_cast<uint8_t*>(cyanPixels.get()), gfx::Rect(innerSize), gfx::Rect(innerSize), gfx::Vector2d());
gfx::Rect rootRect = gfx::Rect(deviceViewportSize());
diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc
index 4a2de14..a63d619 100644
--- a/cc/test/render_pass_test_common.cc
+++ b/cc/test/render_pass_test_common.cc
@@ -34,43 +34,43 @@ void TestRenderPass::AppendOneOfEveryQuadType(
gfx::Rect opaque_rect(10, 10, 80, 80);
const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
cc::ResourceProvider::ResourceId texture_resource =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(20, 12),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(texture_resource);
+ resourceProvider->AllocateForTesting(texture_resource);
unsigned texture_id = ResourceProvider::ScopedReadLockGL(
- resourceProvider, texture_resource).textureId();
+ resourceProvider, texture_resource).texture_id();
cc::ResourceProvider::ResourceId resource1 =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(45, 5),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource1);
+ resourceProvider->AllocateForTesting(resource1);
cc::ResourceProvider::ResourceId resource2 =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(346, 61),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource2);
+ resourceProvider->AllocateForTesting(resource2);
cc::ResourceProvider::ResourceId resource3 =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(12, 134),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource3);
+ resourceProvider->AllocateForTesting(resource3);
cc::ResourceProvider::ResourceId resource4 =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(56, 12),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource4);
+ resourceProvider->AllocateForTesting(resource4);
cc::ResourceProvider::ResourceId resource5 =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(73, 26),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(resource5);
+ resourceProvider->AllocateForTesting(resource5);
scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create();
shared_state->SetAll(gfx::Transform(),
@@ -204,11 +204,11 @@ void TestRenderPass::AppendOneOfEveryQuadType(
cc::VideoLayerImpl::FramePlane planes[3];
for (int i = 0; i < 3; ++i) {
planes[i].resourceId =
- resourceProvider->createResource(
+ resourceProvider->CreateResource(
gfx::Size(20, 12),
- resourceProvider->bestTextureFormat(),
+ resourceProvider->best_texture_format(),
ResourceProvider::TextureUsageAny);
- resourceProvider->allocateForTesting(planes[i].resourceId);
+ resourceProvider->AllocateForTesting(planes[i].resourceId);
planes[i].size = gfx::Size(100, 100);
planes[i].format = GL_LUMINANCE;
}
diff --git a/cc/texture_layer_impl.cc b/cc/texture_layer_impl.cc
index 5a6f9cf..f8eca45 100644
--- a/cc/texture_layer_impl.cc
+++ b/cc/texture_layer_impl.cc
@@ -72,7 +72,7 @@ void TextureLayerImpl::willDraw(ResourceProvider* resourceProvider)
if (m_usesMailbox || !m_textureId)
return;
DCHECK(!m_externalTextureResource);
- m_externalTextureResource = resourceProvider->createResourceFromExternalTexture(m_textureId);
+ m_externalTextureResource = resourceProvider->CreateResourceFromExternalTexture(m_textureId);
}
void TextureLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData)
@@ -102,8 +102,8 @@ void TextureLayerImpl::didDraw(ResourceProvider* resourceProvider)
// FIXME: the following assert will not be true when sending resources to a
// parent compositor. A synchronization scheme (double-buffering or
// pipelining of updates) for the client will need to exist to solve this.
- DCHECK(!resourceProvider->inUseByConsumer(m_externalTextureResource));
- resourceProvider->deleteResource(m_externalTextureResource);
+ DCHECK(!resourceProvider->InUseByConsumer(m_externalTextureResource));
+ resourceProvider->DeleteResource(m_externalTextureResource);
m_externalTextureResource = 0;
}
@@ -144,7 +144,7 @@ void TextureLayerImpl::didBecomeActive()
DCHECK(!m_externalTextureResource);
ResourceProvider* resourceProvider = layerTreeImpl()->resource_provider();
if (!m_textureMailbox.IsEmpty())
- m_externalTextureResource = resourceProvider->createResourceFromTextureMailbox(m_textureMailbox);
+ m_externalTextureResource = resourceProvider->CreateResourceFromTextureMailbox(m_textureMailbox);
m_ownMailbox = false;
}
@@ -158,7 +158,7 @@ void TextureLayerImpl::freeTextureMailbox()
} else if (m_externalTextureResource) {
DCHECK(!m_ownMailbox);
ResourceProvider* resourceProvider = layerTreeImpl()->resource_provider();
- resourceProvider->deleteResource(m_externalTextureResource);
+ resourceProvider->DeleteResource(m_externalTextureResource);
m_externalTextureResource = 0;
}
}
diff --git a/cc/texture_layer_unittest.cc b/cc/texture_layer_unittest.cc
index 7ebdac6..b89f945 100644
--- a/cc/texture_layer_unittest.cc
+++ b/cc/texture_layer_unittest.cc
@@ -476,21 +476,21 @@ TEST_F(TextureLayerImplWithMailboxTest, testCallbackOnInUseResource)
{
ResourceProvider *provider = m_hostImpl.activeTree()->resource_provider();
ResourceProvider::ResourceId id =
- provider->createResourceFromTextureMailbox(m_testData.m_mailbox1);
- provider->allocateForTesting(id);
+ provider->CreateResourceFromTextureMailbox(m_testData.m_mailbox1);
+ provider->AllocateForTesting(id);
// Transfer some resources to the parent.
ResourceProvider::ResourceIdArray resourceIdsToTransfer;
resourceIdsToTransfer.push_back(id);
TransferableResourceArray list;
- provider->prepareSendToParent(resourceIdsToTransfer, &list);
- EXPECT_TRUE(provider->inUseByConsumer(id));
+ provider->PrepareSendToParent(resourceIdsToTransfer, &list);
+ EXPECT_TRUE(provider->InUseByConsumer(id));
EXPECT_CALL(m_testData.m_mockCallback, Release(_, _)).Times(0);
- provider->deleteResource(id);
+ provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
EXPECT_CALL(m_testData.m_mockCallback,
Release(m_testData.m_mailboxName1, _)).Times(1);
- provider->receiveFromParent(list);
+ provider->ReceiveFromParent(list);
}
} // namespace
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index 8c4adc3..c311b2c 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -317,7 +317,7 @@ void ThreadProxy::checkOutputSurfaceStatusOnImplThread()
TRACE_EVENT0("cc", "ThreadProxy::checkOutputSurfaceStatusOnImplThread");
if (!m_layerTreeHostImpl->isContextLost())
return;
- if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resourceProvider()->offscreenContextProvider())
+ if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resourceProvider()->offscreen_context_provider())
offscreenContexts->VerifyContexts();
m_schedulerOnImplThread->didLoseOutputSurface();
}
@@ -721,7 +721,7 @@ void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re
return;
}
- m_layerTreeHostImpl->resourceProvider()->setOffscreenContextProvider(offscreenContextProvider);
+ m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(offscreenContextProvider);
if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist()) {
// Clear any uploads we were making to textures linked to evicted
@@ -1080,7 +1080,7 @@ void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion,
*recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
if (*recreateSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities();
- m_layerTreeHostImpl->resourceProvider()->setOffscreenContextProvider(offscreenContextProvider);
+ m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(offscreenContextProvider);
m_schedulerOnImplThread->didRecreateOutputSurface();
} else if (offscreenContextProvider) {
offscreenContextProvider->VerifyContexts();
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 054b5e5..d06e18d 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -399,7 +399,7 @@ void TileManager::CheckForCompletedTileUploads() {
DCHECK(tile->managed_state().resource);
// Set pixel tasks complete in the order they are posted.
- if (!resource_pool_->resource_provider()->didSetPixelsComplete(
+ if (!resource_pool_->resource_provider()->DidSetPixelsComplete(
tile->managed_state().resource->id())) {
break;
}
@@ -409,7 +409,7 @@ void TileManager::CheckForCompletedTileUploads() {
client_->DidUploadVisibleHighResolutionTile();
// It's now safe to release the pixel buffer.
- resource_pool_->resource_provider()->releasePixelBuffer(
+ resource_pool_->resource_provider()->ReleasePixelBuffer(
tile->managed_state().resource->id());
DidFinishTileInitialization(tile);
@@ -428,9 +428,9 @@ void TileManager::AbortPendingTileUploads() {
ManagedTileState& managed_tile_state = tile->managed_state();
DCHECK(managed_tile_state.resource);
- resource_pool_->resource_provider()->abortSetPixels(
+ resource_pool_->resource_provider()->AbortSetPixels(
managed_tile_state.resource->id());
- resource_pool_->resource_provider()->releasePixelBuffer(
+ resource_pool_->resource_provider()->ReleasePixelBuffer(
managed_tile_state.resource->id());
managed_tile_state.resource_is_being_initialized = false;
@@ -549,7 +549,7 @@ bool TileManager::HasPendingWorkScheduled(WhichTree tree) const {
void TileManager::DidFinishDispatchingWorkerPoolCompletionCallbacks() {
// If a flush is needed, do it now before starting to dispatch more tasks.
if (has_performed_uploads_since_last_flush_) {
- resource_pool_->resource_provider()->shallowFlushIfSupported();
+ resource_pool_->resource_provider()->ShallowFlushIfSupported();
has_performed_uploads_since_last_flush_ = false;
}
@@ -778,7 +778,7 @@ scoped_ptr<ResourcePool::Resource> TileManager::PrepareTileForRaster(
DCHECK(managed_tile_state.can_use_gpu_memory);
scoped_ptr<ResourcePool::Resource> resource =
resource_pool_->AcquireResource(tile->tile_size_.size(), tile->format_);
- resource_pool_->resource_provider()->acquirePixelBuffer(resource->id());
+ resource_pool_->resource_provider()->AcquirePixelBuffer(resource->id());
managed_tile_state.resource_is_being_initialized = true;
managed_tile_state.can_be_freed = false;
@@ -792,7 +792,7 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(tile);
ResourceProvider::ResourceId resource_id = resource->id();
uint8* buffer =
- resource_pool_->resource_provider()->mapPixelBuffer(resource_id);
+ resource_pool_->resource_provider()->MapPixelBuffer(resource_id);
bool is_cheap = use_cheapness_estimator_ && allow_cheap_tasks_ &&
tile->picture_pile()->IsCheapInRect(tile->content_rect_,
@@ -832,7 +832,7 @@ void TileManager::OnRasterTaskCompleted(
TRACE_EVENT0("cc", "TileManager::OnRasterTaskCompleted");
// Release raster resources.
- resource_pool_->resource_provider()->unmapPixelBuffer(resource->id());
+ resource_pool_->resource_provider()->UnmapPixelBuffer(resource->id());
ManagedTileState& managed_tile_state = tile->managed_state();
managed_tile_state.can_be_freed = true;
@@ -857,7 +857,7 @@ void TileManager::OnRasterTaskCompleted(
// Tile resources can't be freed until upload has completed.
managed_tile_state.can_be_freed = false;
- resource_pool_->resource_provider()->beginSetPixels(resource->id());
+ resource_pool_->resource_provider()->BeginSetPixels(resource->id());
has_performed_uploads_since_last_flush_ = true;
managed_tile_state.resource = resource.Pass();
@@ -866,7 +866,7 @@ void TileManager::OnRasterTaskCompleted(
DidTileRasterStateChange(tile, UPLOAD_STATE);
tiles_with_pending_upload_.push(tile);
} else {
- resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
+ resource_pool_->resource_provider()->ReleasePixelBuffer(resource->id());
resource_pool_->ReleaseResource(resource.Pass());
managed_tile_state.resource_is_being_initialized = false;
DidTileRasterStateChange(tile, IDLE_STATE);
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index ea34f37..93a86b3 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -63,7 +63,7 @@ public:
m_layerTreeHost->setRootLayer(Layer::create());
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
- m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
+ m_resourceProvider = ResourceProvider::Create(m_outputSurface.get());
m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy));
}
diff --git a/cc/video_layer_impl.cc b/cc/video_layer_impl.cc
index c5cef47..c455d9a 100644
--- a/cc/video_layer_impl.cc
+++ b/cc/video_layer_impl.cc
@@ -169,7 +169,7 @@ void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider)
// conversion here. That involves an extra copy of each frame to a bitmap.
// Obviously, this is suboptimal and should be addressed once ubercompositor
// starts shaping up.
- m_convertYUV = resourceProvider->defaultResourceType() == ResourceProvider::Bitmap &&
+ m_convertYUV = resourceProvider->default_resource_type() == ResourceProvider::Bitmap &&
(m_frame->format() == media::VideoFrame::YV12 ||
m_frame->format() == media::VideoFrame::YV16);
@@ -189,7 +189,7 @@ void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider)
}
if (m_format == GL_TEXTURE_2D)
- m_externalTextureResource = resourceProvider->createResourceFromExternalTexture(m_frame->texture_id());
+ m_externalTextureResource = resourceProvider->CreateResourceFromExternalTexture(m_frame->texture_id());
}
void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData)
@@ -306,8 +306,8 @@ void VideoLayerImpl::didDraw(ResourceProvider* resourceProvider)
// FIXME: the following assert will not be true when sending resources to a
// parent compositor. We will probably need to hold on to m_frame for
// longer, and have several "current frames" in the pipeline.
- DCHECK(!resourceProvider->inUseByConsumer(m_externalTextureResource));
- resourceProvider->deleteResource(m_externalTextureResource);
+ DCHECK(!resourceProvider->InUseByConsumer(m_externalTextureResource));
+ resourceProvider->DeleteResource(m_externalTextureResource);
m_externalTextureResource = 0;
}
@@ -343,7 +343,7 @@ bool VideoLayerImpl::FramePlane::allocateData(
if (resourceId)
return true;
- resourceId = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
+ resourceId = resourceProvider->CreateResource(size, format, ResourceProvider::TextureUsageAny);
return resourceId;
}
@@ -352,13 +352,13 @@ void VideoLayerImpl::FramePlane::freeData(ResourceProvider* resourceProvider)
if (!resourceId)
return;
- resourceProvider->deleteResource(resourceId);
+ resourceProvider->DeleteResource(resourceId);
resourceId = 0;
}
bool VideoLayerImpl::allocatePlaneData(ResourceProvider* resourceProvider)
{
- const int maxTextureSize = resourceProvider->maxTextureSize();
+ const int maxTextureSize = resourceProvider->max_texture_size();
const size_t planeCount = numPlanes();
for (unsigned planeIdx = 0; planeIdx < planeCount; ++planeIdx) {
VideoLayerImpl::FramePlane& plane = m_framePlanes[planeIdx];
@@ -394,7 +394,7 @@ bool VideoLayerImpl::copyPlaneData(ResourceProvider* resourceProvider)
m_videoRenderer.reset(new media::SkCanvasVideoRenderer);
VideoLayerImpl::FramePlane& plane = m_framePlanes[media::VideoFrame::kRGBPlane];
ResourceProvider::ScopedWriteLockSoftware lock(resourceProvider, plane.resourceId);
- m_videoRenderer->Paint(m_frame, lock.skCanvas(), m_frame->visible_rect(), 0xFF);
+ m_videoRenderer->Paint(m_frame, lock.sk_canvas(), m_frame->visible_rect(), 0xFF);
return true;
}
@@ -405,7 +405,7 @@ bool VideoLayerImpl::copyPlaneData(ResourceProvider* resourceProvider)
const uint8_t* softwarePlanePixels = m_frame->data(planeIndex);
gfx::Rect imageRect(0, 0, m_frame->stride(planeIndex), plane.size.height());
gfx::Rect sourceRect(gfx::Point(), plane.size);
- resourceProvider->setPixels(plane.resourceId, softwarePlanePixels, imageRect, sourceRect, gfx::Vector2d());
+ resourceProvider->SetPixels(plane.resourceId, softwarePlanePixels, imageRect, sourceRect, gfx::Vector2d());
}
return true;
}