A speculative Revert for r165872 - Remove static thread pointers from CC, attempt 2
BUG=152904 Review URL: https://chromiumcodereview.appspot.com/11232051 TBR=aelias@chromium.org Review URL: https://codereview.chromium.org/11369071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165907 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
cc
cc_tests.gypdamage_tracker_unittest.ccdelegated_renderer_layer_impl_unittest.ccfont_atlas.ccfont_atlas.hframe_rate_counter.ccframe_rate_counter.hgl_renderer.ccgl_renderer.hgl_renderer_unittest.cclayer_impl.cclayer_impl_unittest.cclayer_sorter_unittest.cclayer_tree_host.cclayer_tree_host.hlayer_tree_host_common_unittest.cclayer_tree_host_impl.cclayer_tree_host_impl.hlayer_tree_host_impl_unittest.cclayer_tree_host_unittest.cclayer_unittest.ccocclusion_tracker_unittest.ccprioritized_texture.ccprioritized_texture.hprioritized_texture_manager.ccprioritized_texture_manager.hprioritized_texture_unittest.ccproxy.ccproxy.hquad_culler_unittest.ccrate_limiter.ccrate_limiter.hrender_surface_unittest.ccrenderer.hresource_provider.ccresource_provider.hresource_provider_unittest.ccresource_update_controller.ccresource_update_controller.hresource_update_controller_unittest.ccscoped_texture_unittest.ccscrollbar_animation_controller_linear_fade_unittest.ccscrollbar_layer_unittest.ccsingle_thread_proxy.ccsingle_thread_proxy.hsoftware_renderer.ccsoftware_renderer_unittest.ccsolid_color_layer_impl_unittest.cc
test
texture_layer_unittest.ccthread_proxy.ccthread_proxy.htiled_layer_impl_unittest.cctiled_layer_unittest.cctree_synchronizer_unittest.ccvideo_layer_impl.ccwebkit/compositor_bindings
@ -59,8 +59,6 @@
|
||||
'test/fake_graphics_context_3d_unittest.cc',
|
||||
'test/fake_layer_tree_host_client.cc',
|
||||
'test/fake_layer_tree_host_client.h',
|
||||
'test/fake_proxy.cc',
|
||||
'test/fake_proxy.h',
|
||||
'test/fake_web_compositor_output_surface.h',
|
||||
'test/fake_web_compositor_software_output_device.h',
|
||||
'test/fake_web_graphics_context_3d.h',
|
||||
|
@ -165,6 +165,9 @@ scoped_ptr<LayerImpl> createAndSetUpTestTreeWithTwoSurfaces()
|
||||
}
|
||||
|
||||
class DamageTrackerTest : public testing::Test {
|
||||
private:
|
||||
// For testing purposes, fake that we are on the impl thread.
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
};
|
||||
|
||||
TEST_F(DamageTrackerTest, sanityCheckTestTreeWithOneSurface)
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/solid_color_draw_quad.h"
|
||||
#include "cc/solid_color_layer_impl.h"
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
#include "cc/test/fake_web_graphics_context_3d.h"
|
||||
#include "cc/test/geometry_test_utils.h"
|
||||
@ -35,13 +34,11 @@ namespace {
|
||||
class DelegatedRendererLayerImplTest : public testing::Test, public LayerTreeHostImplClient {
|
||||
public:
|
||||
DelegatedRendererLayerImplTest()
|
||||
: m_proxy(scoped_ptr<Thread>(NULL))
|
||||
, m_alwaysImplThreadAndMainThreadBlocked(&m_proxy)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
m_hostImpl->initializeRenderer(createContext());
|
||||
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
|
||||
}
|
||||
@ -63,8 +60,9 @@ protected:
|
||||
return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>();
|
||||
}
|
||||
|
||||
FakeProxy m_proxy;
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThreadBlocked;
|
||||
DebugScopedSetImplThread m_alwaysImplThread;
|
||||
DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
|
||||
|
||||
scoped_ptr<LayerTreeHostImpl> m_hostImpl;
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,7 @@ FontAtlas::~FontAtlas()
|
||||
|
||||
void FontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::string& text, const gfx::Point& destPosition, const gfx::Size& clip) const
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
std::vector<std::string> lines;
|
||||
base::SplitString(text, '\n', &lines);
|
||||
@ -44,7 +44,7 @@ void FontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::stri
|
||||
|
||||
void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint, const std::string& textLine, const gfx::Point& destPosition) const
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
gfx::Point position = destPosition;
|
||||
for (unsigned i = 0; i < textLine.length(); ++i) {
|
||||
@ -59,7 +59,7 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint
|
||||
|
||||
void FontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPosition) const
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
SkIRect source = SkIRect::MakeWH(m_atlas.width(), m_atlas.height());
|
||||
canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(destPosition.x(), destPosition.y(), m_atlas.width(), m_atlas.height()));
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/threading/thread_checker.h"
|
||||
#include "cc/cc_export.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
@ -56,8 +55,6 @@ private:
|
||||
|
||||
int m_fontHeight;
|
||||
|
||||
base::ThreadChecker m_threadChecker;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FontAtlas);
|
||||
};
|
||||
|
||||
|
@ -24,8 +24,8 @@ static inline int safeMod(int number, int modulus)
|
||||
}
|
||||
|
||||
// static
|
||||
scoped_ptr<FrameRateCounter> FrameRateCounter::create(bool hasImplThread) {
|
||||
return make_scoped_ptr(new FrameRateCounter(hasImplThread));
|
||||
scoped_ptr<FrameRateCounter> FrameRateCounter::create() {
|
||||
return make_scoped_ptr(new FrameRateCounter());
|
||||
}
|
||||
|
||||
inline base::TimeDelta FrameRateCounter::frameInterval(int frameNumber) const
|
||||
@ -39,9 +39,8 @@ inline int FrameRateCounter::frameIndex(int frameNumber) const
|
||||
return safeMod(frameNumber, kTimeStampHistorySize);
|
||||
}
|
||||
|
||||
FrameRateCounter::FrameRateCounter(bool hasImplThread)
|
||||
: m_hasImplThread(hasImplThread)
|
||||
, m_currentFrameNumber(1)
|
||||
FrameRateCounter::FrameRateCounter()
|
||||
: m_currentFrameNumber(1)
|
||||
, m_droppedFrameCount(0)
|
||||
{
|
||||
m_timeStampHistory[0] = base::TimeTicks::Now();
|
||||
@ -55,7 +54,7 @@ void FrameRateCounter::markBeginningOfFrame(base::TimeTicks timestamp)
|
||||
m_timeStampHistory[frameIndex(m_currentFrameNumber)] = timestamp;
|
||||
base::TimeDelta frameIntervalSeconds = frameInterval(m_currentFrameNumber);
|
||||
|
||||
if (m_hasImplThread && m_currentFrameNumber > 0) {
|
||||
if (Proxy::hasImplThread() && m_currentFrameNumber > 0) {
|
||||
HISTOGRAM_CUSTOM_COUNTS("Renderer4.CompositorThreadImplDrawDelay", frameIntervalSeconds.InMilliseconds(), 1, 120, 60);
|
||||
}
|
||||
|
||||
@ -71,7 +70,7 @@ void FrameRateCounter::markEndOfFrame()
|
||||
|
||||
bool FrameRateCounter::isBadFrameInterval(base::TimeDelta intervalBetweenConsecutiveFrames) const
|
||||
{
|
||||
bool schedulerAllowsDoubleFrames = !m_hasImplThread;
|
||||
bool schedulerAllowsDoubleFrames = !Proxy::hasImplThread();
|
||||
bool intervalTooFast = schedulerAllowsDoubleFrames && intervalBetweenConsecutiveFrames.InSecondsF() < kFrameTooFast;
|
||||
bool intervalTooSlow = intervalBetweenConsecutiveFrames.InSecondsF() > kFrameTooSlow;
|
||||
return intervalTooFast || intervalTooSlow;
|
||||
@ -133,3 +132,4 @@ base::TimeTicks FrameRateCounter::timeStampOfRecentFrame(int n)
|
||||
}
|
||||
|
||||
} // namespace cc
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace cc {
|
||||
// intelligently compute average frames per second (and standard deviation).
|
||||
class FrameRateCounter {
|
||||
public:
|
||||
static scoped_ptr<FrameRateCounter> create(bool hasImplThread);
|
||||
static scoped_ptr<FrameRateCounter> create();
|
||||
|
||||
void markBeginningOfFrame(base::TimeTicks timestamp);
|
||||
void markEndOfFrame();
|
||||
@ -34,7 +34,7 @@ public:
|
||||
int droppedFrameCount() const { return m_droppedFrameCount; }
|
||||
|
||||
private:
|
||||
explicit FrameRateCounter(bool hasImplThread);
|
||||
FrameRateCounter();
|
||||
|
||||
base::TimeDelta frameInterval(int frameNumber) const;
|
||||
int frameIndex(int frameNumber) const;
|
||||
@ -53,8 +53,6 @@ private:
|
||||
|
||||
static const int kTimeStampHistorySize = 120;
|
||||
|
||||
bool m_hasImplThread;
|
||||
|
||||
int m_currentFrameNumber;
|
||||
base::TimeTicks m_timeStampHistory[kTimeStampHistorySize];
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool GLRenderer::initialize()
|
||||
m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensions.count("GL_CHROMIUM_post_sub_buffer");
|
||||
|
||||
// Use the swapBuffers callback only with the threaded proxy.
|
||||
if (m_client->hasImplThread())
|
||||
if (Proxy::hasImplThread())
|
||||
m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM_swapbuffers_complete_callback");
|
||||
if (m_capabilities.usingSwapCompleteCallback)
|
||||
m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
|
||||
@ -144,6 +144,7 @@ bool GLRenderer::initialize()
|
||||
|
||||
GLRenderer::~GLRenderer()
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
|
||||
m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
|
||||
m_context->setContextLostCallback(0);
|
||||
@ -341,29 +342,29 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
|
||||
GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
|
||||
}
|
||||
|
||||
static WebGraphicsContext3D* getFilterContext(bool hasImplThread)
|
||||
static WebGraphicsContext3D* getFilterContext()
|
||||
{
|
||||
if (hasImplThread)
|
||||
if (Proxy::hasImplThread())
|
||||
return WebSharedGraphicsContext3D::compositorThreadContext();
|
||||
else
|
||||
return WebSharedGraphicsContext3D::mainThreadContext();
|
||||
}
|
||||
|
||||
static GrContext* getFilterGrContext(bool hasImplThread)
|
||||
static GrContext* getFilterGrContext()
|
||||
{
|
||||
if (hasImplThread)
|
||||
if (Proxy::hasImplThread())
|
||||
return WebSharedGraphicsContext3D::compositorThreadGrContext();
|
||||
else
|
||||
return WebSharedGraphicsContext3D::mainThreadGrContext();
|
||||
}
|
||||
|
||||
static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread)
|
||||
static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture)
|
||||
{
|
||||
if (filters.isEmpty())
|
||||
return SkBitmap();
|
||||
|
||||
WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread);
|
||||
GrContext* filterGrContext = getFilterGrContext(hasImplThread);
|
||||
WebGraphicsContext3D* filterContext = getFilterContext();
|
||||
GrContext* filterGrContext = getFilterGrContext();
|
||||
|
||||
if (!filterContext || !filterGrContext)
|
||||
return SkBitmap();
|
||||
@ -375,13 +376,13 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
|
||||
return source;
|
||||
}
|
||||
|
||||
static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture, bool hasImplThread)
|
||||
static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture)
|
||||
{
|
||||
if (!filter)
|
||||
return SkBitmap();
|
||||
|
||||
WebGraphicsContext3D* context3d = getFilterContext(hasImplThread);
|
||||
GrContext* grContext = getFilterGrContext(hasImplThread);
|
||||
WebGraphicsContext3D* context3d = getFilterContext();
|
||||
GrContext* grContext = getFilterGrContext();
|
||||
|
||||
if (!context3d || !grContext)
|
||||
return SkBitmap();
|
||||
@ -467,7 +468,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame,
|
||||
if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
|
||||
return scoped_ptr<ScopedTexture>();
|
||||
|
||||
SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
|
||||
SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get());
|
||||
if (!filteredDeviceBackground.getTexture())
|
||||
return scoped_ptr<ScopedTexture>();
|
||||
|
||||
@ -522,9 +523,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
|
||||
// Apply filters to the contents texture.
|
||||
SkBitmap filterBitmap;
|
||||
if (renderPass->filter()) {
|
||||
filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture, m_client->hasImplThread());
|
||||
filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture);
|
||||
} else {
|
||||
filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture, m_client->hasImplThread());
|
||||
filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture);
|
||||
}
|
||||
scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
|
||||
unsigned contentsTextureId = 0;
|
||||
@ -952,6 +953,8 @@ struct TexTransformTextureProgramBinding : TextureProgramBinding {
|
||||
|
||||
void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQuad* quad)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
TexTransformTextureProgramBinding binding;
|
||||
if (quad->flipped())
|
||||
binding.set(textureProgramFlip());
|
||||
@ -994,6 +997,7 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua
|
||||
|
||||
void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDrawQuad* quad)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
TexTransformTextureProgramBinding binding;
|
||||
binding.set(textureIOSurfaceProgram());
|
||||
|
||||
@ -1134,6 +1138,35 @@ void GLRenderer::onSwapBuffersComplete()
|
||||
}
|
||||
|
||||
void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocation)
|
||||
{
|
||||
// FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
|
||||
if (!Proxy::hasImplThread()) {
|
||||
DCHECK(Proxy::isMainThread());
|
||||
DebugScopedSetImplThread impl;
|
||||
onMemoryAllocationChangedOnImplThread(allocation);
|
||||
} else {
|
||||
DCHECK(Proxy::isImplThread());
|
||||
onMemoryAllocationChangedOnImplThread(allocation);
|
||||
}
|
||||
}
|
||||
|
||||
int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priorityCutoff)
|
||||
{
|
||||
switch (priorityCutoff) {
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
|
||||
return PriorityCalculator::allowNothingCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
|
||||
return PriorityCalculator::allowVisibleOnlyCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby:
|
||||
return PriorityCalculator::allowVisibleAndNearbyCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
|
||||
return PriorityCalculator::allowEverythingCutoff();
|
||||
}
|
||||
NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation allocation)
|
||||
{
|
||||
// Just ignore the memory manager when it says to set the limit to zero
|
||||
// bytes. This will happen when the memory manager thinks that the renderer
|
||||
@ -1158,22 +1191,6 @@ void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
|
||||
m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible;
|
||||
}
|
||||
|
||||
int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priorityCutoff)
|
||||
{
|
||||
switch (priorityCutoff) {
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
|
||||
return PriorityCalculator::allowNothingCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
|
||||
return PriorityCalculator::allowVisibleOnlyCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby:
|
||||
return PriorityCalculator::allowVisibleAndNearbyCutoff();
|
||||
case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
|
||||
return PriorityCalculator::allowEverythingCutoff();
|
||||
}
|
||||
NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GLRenderer::enforceMemoryPolicy()
|
||||
{
|
||||
if (!m_visible) {
|
||||
|
@ -118,6 +118,7 @@ private:
|
||||
|
||||
// WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
|
||||
virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation) OVERRIDE;
|
||||
void onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation);
|
||||
void discardFramebuffer();
|
||||
void ensureFramebuffer();
|
||||
void enforceMemoryPolicy();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
#include "cc/test/fake_web_graphics_context_3d.h"
|
||||
#include "cc/test/test_common.h"
|
||||
@ -41,6 +42,9 @@ public:
|
||||
int frameCount() { return m_frame; }
|
||||
void setMemoryAllocation(WebGraphicsMemoryAllocation allocation)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
// In single threaded mode we expect this callback on main thread.
|
||||
DebugScopedSetMainThread main;
|
||||
m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation);
|
||||
}
|
||||
|
||||
@ -72,7 +76,6 @@ public:
|
||||
virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCount++; }
|
||||
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; }
|
||||
virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; }
|
||||
virtual bool hasImplThread() const OVERRIDE { return false; }
|
||||
|
||||
// Methods added for test.
|
||||
int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCount; }
|
||||
@ -87,6 +90,7 @@ public:
|
||||
private:
|
||||
int m_setFullRootLayerDamageCount;
|
||||
bool* m_lastCallWasSetVisibility;
|
||||
DebugScopedSetImplThread m_implThread;
|
||||
scoped_ptr<LayerImpl> m_rootLayer;
|
||||
RenderPassList m_renderPassesInDrawOrder;
|
||||
RenderPassIdHashMap m_renderPasses;
|
||||
|
@ -65,11 +65,13 @@ LayerImpl::LayerImpl(int id)
|
||||
#endif
|
||||
, m_layerAnimationController(LayerAnimationController::create(this))
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(m_layerId > 0);
|
||||
}
|
||||
|
||||
LayerImpl::~LayerImpl()
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!m_betweenWillDrawAndDidDraw);
|
||||
#endif
|
||||
|
@ -58,6 +58,8 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
|
||||
//
|
||||
|
||||
// The constructor on this will fake that we are on the correct thread.
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
|
||||
// Create a simple LayerImpl tree:
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
|
||||
root->addChild(LayerImpl::create(2));
|
||||
|
@ -189,6 +189,8 @@ TEST(LayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
|
||||
|
||||
TEST(LayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
// If there is no reason to re-sort the layers (i.e. no 3d z difference), then the
|
||||
// existing ordering provided on input should be retained. This test covers the fix in
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=75046. Before this fix, ordering was
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "cc/overdraw_metrics.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/thread.h"
|
||||
#include "cc/thread_proxy.h"
|
||||
#include "cc/tree_synchronizer.h"
|
||||
|
||||
@ -84,10 +83,10 @@ bool LayerTreeHost::anyLayerTreeHostInstanceExists()
|
||||
return numLayerTreeInstances > 0;
|
||||
}
|
||||
|
||||
scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr<Thread> implThread)
|
||||
scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, const LayerTreeSettings& settings)
|
||||
{
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings));
|
||||
if (!layerTreeHost->initialize(implThread.Pass()))
|
||||
if (!layerTreeHost->initialize())
|
||||
return scoped_ptr<LayerTreeHost>();
|
||||
return layerTreeHost.Pass();
|
||||
}
|
||||
@ -113,15 +112,16 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
|
||||
, m_hasTransparentBackground(false)
|
||||
, m_partialTextureUpdateRequests(0)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
numLayerTreeInstances++;
|
||||
}
|
||||
|
||||
bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread)
|
||||
bool LayerTreeHost::initialize()
|
||||
{
|
||||
TRACE_EVENT0("cc", "LayerTreeHost::initialize");
|
||||
|
||||
if (implThread)
|
||||
m_proxy = ThreadProxy::create(this, implThread.Pass());
|
||||
if (Proxy::hasImplThread())
|
||||
m_proxy = ThreadProxy::create(this);
|
||||
else
|
||||
m_proxy = SingleThreadProxy::create(this);
|
||||
m_proxy->start();
|
||||
@ -133,10 +133,11 @@ LayerTreeHost::~LayerTreeHost()
|
||||
{
|
||||
if (m_rootLayer)
|
||||
m_rootLayer->setLayerTreeHost(0);
|
||||
DCHECK(m_proxy);
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
|
||||
DCHECK(m_proxy.get());
|
||||
m_proxy->stop();
|
||||
m_proxy.reset();
|
||||
numLayerTreeInstances--;
|
||||
RateLimiterMap::iterator it = m_rateLimiters.begin();
|
||||
if (it != m_rateLimiters.end())
|
||||
@ -163,7 +164,7 @@ void LayerTreeHost::initializeRenderer()
|
||||
// Update m_settings based on partial update capability.
|
||||
m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates());
|
||||
|
||||
m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool, m_proxy.get());
|
||||
m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool);
|
||||
m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Size(), GL_RGBA);
|
||||
|
||||
m_rendererInitialized = true;
|
||||
@ -198,7 +199,7 @@ LayerTreeHost::RecreateResult LayerTreeHost::recreateContext()
|
||||
// FIXME: The single thread does not self-schedule context
|
||||
// recreation. So force another recreation attempt to happen by requesting
|
||||
// another commit.
|
||||
if (!m_proxy->hasImplThread())
|
||||
if (!Proxy::hasImplThread())
|
||||
setNeedsCommit();
|
||||
return RecreateFailedButTryAgain;
|
||||
}
|
||||
@ -211,14 +212,14 @@ LayerTreeHost::RecreateResult LayerTreeHost::recreateContext()
|
||||
|
||||
void LayerTreeHost::deleteContentsTexturesOnImplThread(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
if (m_rendererInitialized)
|
||||
m_contentsTextureManager->clearAllMemory(resourceProvider);
|
||||
}
|
||||
|
||||
void LayerTreeHost::acquireLayerTextures()
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
m_proxy->acquireLayerTextures();
|
||||
}
|
||||
|
||||
@ -239,7 +240,7 @@ void LayerTreeHost::layout()
|
||||
|
||||
void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
TRACE_EVENT0("cc", "LayerTreeHost::commitTo");
|
||||
}
|
||||
|
||||
@ -250,7 +251,7 @@ void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
||||
// after the commit, but on the main thread.
|
||||
void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
m_contentsTextureManager->updateBackingsInDrawingImplTree();
|
||||
ResourceProvider::debugNotifyEnterZone(0xA000000);
|
||||
@ -317,13 +318,13 @@ scoped_ptr<InputHandler> LayerTreeHost::createInputHandler()
|
||||
|
||||
scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHostImplClient* client)
|
||||
{
|
||||
return LayerTreeHostImpl::create(m_settings, client, m_proxy.get());
|
||||
return LayerTreeHostImpl::create(m_settings, client);
|
||||
}
|
||||
|
||||
void LayerTreeHost::didLoseContext()
|
||||
{
|
||||
TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext");
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
m_contextLost = true;
|
||||
m_numFailedRecreateAttempts = 0;
|
||||
setNeedsCommit();
|
||||
@ -366,7 +367,7 @@ const RendererCapabilities& LayerTreeHost::rendererCapabilities() const
|
||||
|
||||
void LayerTreeHost::setNeedsAnimate()
|
||||
{
|
||||
DCHECK(m_proxy->hasImplThread());
|
||||
DCHECK(Proxy::hasImplThread());
|
||||
m_proxy->setNeedsAnimate();
|
||||
}
|
||||
|
||||
@ -382,7 +383,7 @@ void LayerTreeHost::setNeedsCommit()
|
||||
void LayerTreeHost::setNeedsRedraw()
|
||||
{
|
||||
m_proxy->setNeedsRedraw();
|
||||
if (!m_proxy->implThread())
|
||||
if (!ThreadProxy::implThread())
|
||||
m_client->scheduleComposite();
|
||||
}
|
||||
|
||||
@ -393,7 +394,7 @@ bool LayerTreeHost::commitRequested() const
|
||||
|
||||
void LayerTreeHost::setAnimationEvents(scoped_ptr<AnimationEventsVector> events, base::Time wallClockTime)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(ThreadProxy::isMainThread());
|
||||
setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime);
|
||||
}
|
||||
|
||||
@ -469,7 +470,7 @@ PrioritizedTextureManager* LayerTreeHost::contentsTextureManager() const
|
||||
|
||||
void LayerTreeHost::composite()
|
||||
{
|
||||
DCHECK(!m_proxy->implThread());
|
||||
DCHECK(!ThreadProxy::implThread());
|
||||
static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately();
|
||||
}
|
||||
|
||||
@ -744,7 +745,7 @@ void LayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context)
|
||||
if (it != m_rateLimiters.end())
|
||||
it->second->start();
|
||||
else {
|
||||
scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, this, m_proxy->mainThread());
|
||||
scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, this);
|
||||
m_rateLimiters[context] = rateLimiter;
|
||||
rateLimiter->start();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ struct CC_EXPORT LayerTreeSettings {
|
||||
};
|
||||
|
||||
// Provides information on an Impl's rendering capabilities back to the LayerTreeHost
|
||||
struct CC_EXPORT RendererCapabilities {
|
||||
struct RendererCapabilities {
|
||||
RendererCapabilities();
|
||||
~RendererCapabilities();
|
||||
|
||||
@ -93,7 +93,7 @@ struct CC_EXPORT RendererCapabilities {
|
||||
|
||||
class CC_EXPORT LayerTreeHost : public RateLimiterClient {
|
||||
public:
|
||||
static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTreeSettings&, scoped_ptr<Thread> implThread);
|
||||
static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTreeSettings&);
|
||||
virtual ~LayerTreeHost();
|
||||
|
||||
void setSurfaceReady();
|
||||
@ -212,11 +212,9 @@ public:
|
||||
|
||||
HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); }
|
||||
|
||||
Proxy* proxy() const { return m_proxy.get(); }
|
||||
|
||||
protected:
|
||||
LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&);
|
||||
bool initialize(scoped_ptr<Thread> implThread);
|
||||
bool initialize();
|
||||
|
||||
private:
|
||||
typedef std::vector<scoped_refptr<Layer> > LayerList;
|
||||
@ -245,11 +243,11 @@ private:
|
||||
base::CancelableClosure m_prepaintCallback;
|
||||
|
||||
LayerTreeHostClient* m_client;
|
||||
scoped_ptr<Proxy> m_proxy;
|
||||
|
||||
int m_commitNumber;
|
||||
RenderingStats m_renderingStats;
|
||||
|
||||
scoped_ptr<Proxy> m_proxy;
|
||||
bool m_rendererInitialized;
|
||||
bool m_contextLost;
|
||||
int m_numTimesRecreateShouldFail;
|
||||
|
@ -791,6 +791,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
|
||||
{
|
||||
// This test checks for correct scroll compensation when the fixed-position container
|
||||
// is the direct parent of the fixed-position layer.
|
||||
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -830,6 +832,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
|
||||
// Transforms are in general non-commutative; using something like a non-uniform scale
|
||||
// helps to verify that translations and non-uniform scales are applied in the correct
|
||||
// order.
|
||||
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -871,6 +875,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
|
||||
{
|
||||
// This test checks for correct scroll compensation when the fixed-position container
|
||||
// is NOT the direct parent of the fixed-position layer.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -913,6 +919,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
|
||||
// This test checks for correct scroll compensation when the fixed-position container
|
||||
// is NOT the direct parent of the fixed-position layer, and the hierarchy has various
|
||||
// transforms that have to be processed in the correct order.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -973,6 +981,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
|
||||
// This test checks for correct scroll compensation when the fixed-position container
|
||||
// is NOT the direct parent of the fixed-position layer, and the hierarchy has various
|
||||
// transforms that have to be processed in the correct order.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -1033,6 +1043,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
|
||||
// contributes to a different renderSurface than the fixed-position layer. In this
|
||||
// case, the surface drawTransforms also have to be accounted for when checking the
|
||||
// scrollDelta.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -1104,6 +1116,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
|
||||
// contributes to a different renderSurface than the fixed-position layer, with
|
||||
// additional renderSurfaces in-between. This checks that the conversion to ancestor
|
||||
// surfaces is accumulated properly in the final matrix transform.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -1213,6 +1227,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
|
||||
// itself has a renderSurface. In this case, the container layer should be treated
|
||||
// like a layer that contributes to a renderTarget, and that renderTarget
|
||||
// is completely irrelevant; it should not affect the scroll compensation.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -1258,6 +1274,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
|
||||
// This test checks the scenario where a fixed-position layer also happens to be a
|
||||
// container itself for a descendant fixed position layer. In particular, the layer
|
||||
// should not accidentally be fixed to itself.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -1293,6 +1311,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
|
||||
// This test checks scroll compensation when a fixed-position layer does not find any
|
||||
// ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should
|
||||
// be fixed to the viewport -- not the rootLayer, which may have transforms of its own.
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
|
||||
LayerImpl* child = root->children()[0];
|
||||
LayerImpl* grandChild = child->children()[0];
|
||||
@ -2664,6 +2684,8 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList)
|
||||
{
|
||||
// Hit testing on an empty renderSurfaceLayerList should return a null pointer.
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
std::vector<LayerImpl*> renderSurfaceLayerList;
|
||||
|
||||
gfx::Point testPoint(0, 0);
|
||||
@ -2677,6 +2699,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -2717,6 +2741,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
|
||||
|
||||
WebTransformationMatrix uninvertibleTransform;
|
||||
@ -2776,6 +2802,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -2817,6 +2845,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -2866,6 +2896,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -2926,6 +2958,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents)
|
||||
// contentsScale is ignored, then hit testing will mis-interpret the visibleContentRect
|
||||
// as being larger than the actual bounds of the layer.
|
||||
//
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -2987,6 +3021,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
|
||||
{
|
||||
// Test that hit-testing will only work for the visible portion of a layer, and not
|
||||
// the entire layer bounds. Here we just test the simple axis-aligned case.
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
gfx::PointF anchor(0, 0);
|
||||
|
||||
@ -3053,6 +3089,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
|
||||
// combined create a triangle. The rotatedLeaf will only be visible where it overlaps
|
||||
// this triangle.
|
||||
//
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(123);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -3151,6 +3189,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
|
||||
{
|
||||
// This test checks that hit testing code does not accidentally clip to layer
|
||||
// bounds for a layer that actually does not clip.
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
gfx::PointF anchor(0, 0);
|
||||
|
||||
@ -3210,6 +3250,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
|
||||
{
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
@ -3313,6 +3355,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
|
||||
// The geometry is set up similarly to the previous case, but
|
||||
// all layers are forced to be renderSurfaces now.
|
||||
//
|
||||
DebugScopedSetImplThread thisScopeIsOnImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
|
||||
|
||||
WebTransformationMatrix identityMatrix;
|
||||
|
@ -197,14 +197,13 @@ LayerTreeHostImpl::FrameData::~FrameData()
|
||||
{
|
||||
}
|
||||
|
||||
scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
|
||||
scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client)
|
||||
{
|
||||
return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy));
|
||||
return make_scoped_ptr(new LayerTreeHostImpl(settings, client));
|
||||
}
|
||||
|
||||
LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
|
||||
LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTreeHostImplClient* client)
|
||||
: m_client(client)
|
||||
, m_proxy(proxy)
|
||||
, m_sourceFrameNumber(-1)
|
||||
, m_rootScrollLayerImpl(0)
|
||||
, m_currentlyScrollingLayerImpl(0)
|
||||
@ -223,18 +222,18 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
|
||||
, m_hasTransparentBackground(false)
|
||||
, m_needsAnimateLayers(false)
|
||||
, m_pinchGestureActive(false)
|
||||
, m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
|
||||
, m_fpsCounter(FrameRateCounter::create())
|
||||
, m_debugRectHistory(DebugRectHistory::create())
|
||||
, m_numImplThreadScrolls(0)
|
||||
, m_numMainThreadScrolls(0)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
didVisibilityChange(this, m_visible);
|
||||
}
|
||||
|
||||
LayerTreeHostImpl::~LayerTreeHostImpl()
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
|
||||
|
||||
if (m_rootLayerImpl)
|
||||
@ -501,7 +500,7 @@ void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled)
|
||||
{
|
||||
// Lazily create the timeSource adapter so that we can vary the interval for testing.
|
||||
if (!m_timeSourceClientAdapter)
|
||||
m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(this, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->currentThread()));
|
||||
m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(this, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), Proxy::currentThread()));
|
||||
|
||||
m_timeSourceClientAdapter->setActive(enabled);
|
||||
}
|
||||
@ -646,20 +645,10 @@ void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po
|
||||
m_client->sendManagedMemoryStats();
|
||||
}
|
||||
|
||||
bool LayerTreeHostImpl::hasImplThread() const
|
||||
{
|
||||
return m_proxy->hasImplThread();
|
||||
}
|
||||
|
||||
void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
|
||||
{
|
||||
if (m_managedMemoryPolicy == policy)
|
||||
return;
|
||||
|
||||
// FIXME: In single-thread mode, this can be called on the main thread
|
||||
// by GLRenderer::onMemoryAllocationChanged.
|
||||
DebugScopedSetImplThread implThread(m_proxy);
|
||||
|
||||
m_managedMemoryPolicy = policy;
|
||||
enforceManagedMemoryPolicy(m_managedMemoryPolicy);
|
||||
// We always need to commit after changing the memory policy because the new
|
||||
@ -826,7 +815,7 @@ scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree()
|
||||
|
||||
void LayerTreeHostImpl::setVisible(bool visible)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
if (m_visible == visible)
|
||||
return;
|
||||
|
@ -107,7 +107,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
|
||||
typedef std::vector<LayerImpl*> LayerList;
|
||||
|
||||
public:
|
||||
static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy*);
|
||||
static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerTreeHostImplClient*);
|
||||
virtual ~LayerTreeHostImpl();
|
||||
|
||||
// InputHandlerClient implementation
|
||||
@ -156,7 +156,6 @@ public:
|
||||
virtual void setFullRootLayerDamage() OVERRIDE;
|
||||
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
|
||||
virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
|
||||
virtual bool hasImplThread() const OVERRIDE;
|
||||
|
||||
// WebCompositorOutputSurfaceClient implementation.
|
||||
virtual void onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) OVERRIDE;
|
||||
@ -234,7 +233,6 @@ public:
|
||||
FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); }
|
||||
DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get(); }
|
||||
ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); }
|
||||
Proxy* proxy() const { return m_proxy; }
|
||||
|
||||
class CC_EXPORT CullRenderPassesWithCachedTextures {
|
||||
public:
|
||||
@ -267,7 +265,7 @@ public:
|
||||
static void removeRenderPasses(RenderPassCuller, FrameData&);
|
||||
|
||||
protected:
|
||||
LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy*);
|
||||
LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*);
|
||||
|
||||
void animatePageScale(base::TimeTicks monotonicTime);
|
||||
void animateScrollbars(base::TimeTicks monotonicTime);
|
||||
@ -282,7 +280,6 @@ protected:
|
||||
virtual base::TimeDelta lowFrequencyAnimationInterval() const;
|
||||
|
||||
LayerTreeHostImplClient* m_client;
|
||||
Proxy* m_proxy;
|
||||
int m_sourceFrameNumber;
|
||||
|
||||
private:
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/solid_color_draw_quad.h"
|
||||
#include "cc/test/animation_test_common.h"
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
#include "cc/test/fake_web_graphics_context_3d.h"
|
||||
#include "cc/test/fake_web_scrollbar_theme_geometry.h"
|
||||
@ -64,10 +63,7 @@ class LayerTreeHostImplTest : public testing::TestWithParam<bool>,
|
||||
public LayerTreeHostImplClient {
|
||||
public:
|
||||
LayerTreeHostImplTest()
|
||||
: m_proxy(scoped_ptr<Thread>(NULL))
|
||||
, m_alwaysImplThread(&m_proxy)
|
||||
, m_alwaysMainThreadBlocked(&m_proxy)
|
||||
, m_onCanDrawStateChangedCalled(false)
|
||||
: m_onCanDrawStateChangedCalled(false)
|
||||
, m_didRequestCommit(false)
|
||||
, m_didRequestRedraw(false)
|
||||
, m_reduceMemoryResult(true)
|
||||
@ -81,7 +77,7 @@ public:
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
m_hostImpl->initializeRenderer(createContext());
|
||||
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
|
||||
}
|
||||
@ -109,7 +105,7 @@ public:
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
myHostImpl->initializeRenderer(graphicsContext.Pass());
|
||||
myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
|
||||
@ -193,7 +189,6 @@ protected:
|
||||
return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>();
|
||||
}
|
||||
|
||||
FakeProxy m_proxy;
|
||||
DebugScopedSetImplThread m_alwaysImplThread;
|
||||
DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
|
||||
|
||||
@ -357,7 +352,7 @@ TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer)
|
||||
TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Initialization will fail here.
|
||||
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<GraphicsContext>());
|
||||
@ -1953,7 +1948,7 @@ TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
|
||||
// that we can force partial swap enabled.
|
||||
LayerTreeSettings settings;
|
||||
Settings::setPartialSwapEnabled(true);
|
||||
scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
|
||||
layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500));
|
||||
|
||||
@ -2233,14 +2228,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy)
|
||||
static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client)
|
||||
{
|
||||
Settings::setPartialSwapEnabled(partialSwap);
|
||||
|
||||
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>();
|
||||
|
||||
LayerTreeSettings settings;
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, client, proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, client);
|
||||
myHostImpl->initializeRenderer(context.Pass());
|
||||
myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
|
||||
|
||||
@ -2303,7 +2298,7 @@ static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
|
||||
|
||||
TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
|
||||
{
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this);
|
||||
|
||||
{
|
||||
LayerTreeHostImpl::FrameData frame;
|
||||
@ -2324,7 +2319,7 @@ TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
|
||||
|
||||
TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
|
||||
{
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this);
|
||||
|
||||
{
|
||||
LayerTreeHostImpl::FrameData frame;
|
||||
@ -2390,7 +2385,7 @@ TEST_P(LayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers)
|
||||
TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects.
|
||||
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<GraphicsContext>());
|
||||
@ -2414,7 +2409,7 @@ private:
|
||||
TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
m_hostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Initialize into a known successful state.
|
||||
EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext()));
|
||||
@ -3025,7 +3020,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
LayerImpl* rootPtr;
|
||||
LayerImpl* surfaceLayerPtr;
|
||||
@ -3122,7 +3117,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Layers are structure as follows:
|
||||
//
|
||||
@ -3238,7 +3233,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Layers are structure as follows:
|
||||
//
|
||||
@ -3354,7 +3349,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Layers are structured as follows:
|
||||
//
|
||||
@ -3442,7 +3437,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
|
||||
Settings::setPartialSwapEnabled(false);
|
||||
|
||||
LayerTreeSettings settings;
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Layers are structured as follows:
|
||||
//
|
||||
@ -3517,7 +3512,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
// Layers are structure as follows:
|
||||
//
|
||||
@ -3630,7 +3625,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithScissor)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
/*
|
||||
Layers are created as follows:
|
||||
@ -3737,7 +3732,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
LayerImpl* rootPtr;
|
||||
LayerImpl* intermediateLayerPtr;
|
||||
@ -3898,7 +3893,7 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
|
||||
|
||||
LayerTreeSettings settings;
|
||||
settings.minimumOcclusionTrackingSize = gfx::Size();
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this);
|
||||
|
||||
LayerImpl* rootPtr;
|
||||
LayerImpl* intermediateLayerPtr;
|
||||
@ -4090,9 +4085,9 @@ struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData {
|
||||
|
||||
class TestRenderer : public GLRenderer, public RendererClient {
|
||||
public:
|
||||
static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider, Proxy* proxy)
|
||||
static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider)
|
||||
{
|
||||
scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, proxy));
|
||||
scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider));
|
||||
if (!renderer->initialize())
|
||||
return scoped_ptr<TestRenderer>();
|
||||
|
||||
@ -4112,10 +4107,9 @@ public:
|
||||
virtual void setFullRootLayerDamage() OVERRIDE { }
|
||||
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { }
|
||||
virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { }
|
||||
virtual bool hasImplThread() const OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(this, resourceProvider) { }
|
||||
TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resourceProvider) { }
|
||||
|
||||
private:
|
||||
LayerTreeSettings m_settings;
|
||||
@ -4399,7 +4393,7 @@ TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses)
|
||||
ASSERT_TRUE(context->context3D());
|
||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||
|
||||
scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), &m_proxy));
|
||||
scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get()));
|
||||
|
||||
int testCaseIndex = 0;
|
||||
while (removeRenderPassesCases[testCaseIndex].name) {
|
||||
|
@ -2861,7 +2861,7 @@ public:
|
||||
implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfterEvictTextures::evictTexturesOnImplThread,
|
||||
base::Unretained(this)));
|
||||
} else {
|
||||
DebugScopedSetImplThread impl(proxy());
|
||||
DebugScopedSetImplThread impl;
|
||||
evictTexturesOnImplThread();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/thread.h"
|
||||
#include "cc/test/fake_layer_tree_host_client.h"
|
||||
#include "cc/test/geometry_test_utils.h"
|
||||
#include "cc/test/test_common.h"
|
||||
@ -41,7 +40,7 @@ public:
|
||||
MockLayerImplTreeHost()
|
||||
: LayerTreeHost(&m_fakeClient, LayerTreeSettings())
|
||||
{
|
||||
initialize(scoped_ptr<Thread>(NULL));
|
||||
initialize();
|
||||
}
|
||||
|
||||
MOCK_METHOD0(setNeedsCommit, void());
|
||||
@ -529,6 +528,8 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
|
||||
|
||||
TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect)
|
||||
{
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
|
||||
scoped_refptr<Layer> testLayer = Layer::create();
|
||||
scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1);
|
||||
|
||||
@ -554,7 +555,7 @@ public:
|
||||
{
|
||||
scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost);
|
||||
// The initialize call will fail, since our client doesn't provide a valid GraphicsContext3D, but it doesn't matter in the tests that use this fake so ignore the return value.
|
||||
host->initialize(scoped_ptr<Thread>(NULL));
|
||||
host->initialize();
|
||||
return host.Pass();
|
||||
}
|
||||
|
||||
|
@ -425,12 +425,14 @@ private:
|
||||
|
||||
#define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
|
||||
class ClassName##ImplThreadOpaqueLayers : public ClassName<OcclusionTrackerTestImplThreadTypes> { \
|
||||
DebugScopedSetImplThread impl; \
|
||||
public: \
|
||||
ClassName##ImplThreadOpaqueLayers() : ClassName<OcclusionTrackerTestImplThreadTypes>(true) { } \
|
||||
}; \
|
||||
TEST_F(ClassName##ImplThreadOpaqueLayers, runTest) { runMyTest(); }
|
||||
#define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \
|
||||
class ClassName##ImplThreadOpaquePaints : public ClassName<OcclusionTrackerTestImplThreadTypes> { \
|
||||
DebugScopedSetImplThread impl; \
|
||||
public: \
|
||||
ClassName##ImplThreadOpaquePaints() : ClassName<OcclusionTrackerTestImplThreadTypes>(false) { } \
|
||||
}; \
|
||||
|
@ -153,7 +153,7 @@ PrioritizedTexture::Backing::~Backing()
|
||||
|
||||
void PrioritizedTexture::Backing::deleteResource(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(!m_resourceHasBeenDeleted);
|
||||
#ifndef NDEBUG
|
||||
DCHECK(resourceProvider == m_resourceProvider);
|
||||
@ -166,19 +166,19 @@ void PrioritizedTexture::Backing::deleteResource(ResourceProvider* resourceProvi
|
||||
|
||||
bool PrioritizedTexture::Backing::resourceHasBeenDeleted() const
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_resourceHasBeenDeleted;
|
||||
}
|
||||
|
||||
bool PrioritizedTexture::Backing::canBeRecycled() const
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return !m_wasAbovePriorityCutoffAtLastPriorityUpdate && !m_inDrawingImplTree;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::Backing::updatePriority()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isImplThread() && proxy()->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
if (m_owner) {
|
||||
m_priorityAtLastPriorityUpdate = m_owner->requestPriority();
|
||||
m_wasAbovePriorityCutoffAtLastPriorityUpdate = m_owner->isAbovePriorityCutoff();
|
||||
@ -190,7 +190,7 @@ void PrioritizedTexture::Backing::updatePriority()
|
||||
|
||||
void PrioritizedTexture::Backing::updateInDrawingImplTree()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isImplThread() && proxy()->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
m_inDrawingImplTree = !!owner();
|
||||
if (!m_inDrawingImplTree)
|
||||
DCHECK(m_priorityAtLastPriorityUpdate == PriorityCalculator::lowestPriority());
|
||||
@ -203,11 +203,4 @@ void PrioritizedTexture::returnBackingTexture()
|
||||
m_manager->returnBackingTexture(this);
|
||||
}
|
||||
|
||||
const Proxy* PrioritizedTexture::Backing::proxy() const
|
||||
{
|
||||
if (!m_owner || !m_owner->textureManager())
|
||||
return 0;
|
||||
return m_owner->textureManager()->proxyForDebug();
|
||||
}
|
||||
|
||||
} // namespace cc
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace cc {
|
||||
|
||||
class PrioritizedTextureManager;
|
||||
class Proxy;
|
||||
|
||||
class CC_EXPORT PrioritizedTexture {
|
||||
public:
|
||||
@ -109,8 +108,6 @@ private:
|
||||
bool resourceHasBeenDeleted() const;
|
||||
|
||||
private:
|
||||
const Proxy* proxy() const;
|
||||
|
||||
friend class PrioritizedTexture;
|
||||
PrioritizedTexture* m_owner;
|
||||
int m_priorityAtLastPriorityUpdate;
|
||||
@ -123,6 +120,7 @@ private:
|
||||
#ifndef NDEBUG
|
||||
ResourceProvider* m_resourceProvider;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Backing);
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,8 @@ using namespace std;
|
||||
|
||||
namespace cc {
|
||||
|
||||
PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes, int, int pool, const Proxy* proxy)
|
||||
: m_proxy(proxy)
|
||||
, m_maxMemoryLimitBytes(maxMemoryLimitBytes)
|
||||
PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes, int, int pool)
|
||||
: m_maxMemoryLimitBytes(maxMemoryLimitBytes)
|
||||
, m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff())
|
||||
, m_memoryUseBytes(0)
|
||||
, m_memoryAboveCutoffBytes(0)
|
||||
@ -47,20 +46,20 @@ PrioritizedTextureManager::~PrioritizedTextureManager()
|
||||
|
||||
size_t PrioritizedTextureManager::memoryVisibleBytes() const
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_memoryVisibleLastPushedBytes;
|
||||
}
|
||||
|
||||
size_t PrioritizedTextureManager::memoryVisibleAndNearbyBytes() const
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_memoryVisibleAndNearbyLastPushedBytes;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::prioritizeTextures()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::prioritizeTextures");
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
// Sorting textures in this function could be replaced by a slightly
|
||||
// modified O(n) quick-select to partition textures rather than
|
||||
@ -136,7 +135,7 @@ void PrioritizedTextureManager::prioritizeTextures()
|
||||
void PrioritizedTextureManager::pushTexturePrioritiesToBackings()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::pushTexturePrioritiesToBackings");
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
assertInvariants();
|
||||
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
|
||||
@ -152,7 +151,7 @@ void PrioritizedTextureManager::pushTexturePrioritiesToBackings()
|
||||
void PrioritizedTextureManager::updateBackingsInDrawingImplTree()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::updateBackingsInDrawingImplTree");
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
assertInvariants();
|
||||
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
|
||||
@ -166,7 +165,7 @@ void PrioritizedTextureManager::updateBackingsInDrawingImplTree()
|
||||
void PrioritizedTextureManager::sortBackings()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::sortBackings");
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
// Put backings in eviction/recycling order.
|
||||
m_backings.sort(compareBackings);
|
||||
@ -175,7 +174,7 @@ void PrioritizedTextureManager::sortBackings()
|
||||
|
||||
void PrioritizedTextureManager::clearPriorities()
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
|
||||
// FIXME: We should remove this and just set all priorities to
|
||||
// PriorityCalculator::lowestPriority() once we have priorities
|
||||
@ -187,7 +186,7 @@ void PrioritizedTextureManager::clearPriorities()
|
||||
|
||||
bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
// This is already above cutoff, so don't double count it's memory below.
|
||||
if (texture->isAbovePriorityCutoff())
|
||||
@ -212,7 +211,7 @@ bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture)
|
||||
|
||||
void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture* texture, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(!texture->isSelfManaged());
|
||||
DCHECK(texture->isAbovePriorityCutoff());
|
||||
if (texture->backing() || !texture->isAbovePriorityCutoff())
|
||||
@ -252,7 +251,7 @@ void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture
|
||||
|
||||
bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy evictionPolicy, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
if (memoryUseBytes() <= limitBytes && PriorityCalculator::allowEverythingCutoff() == priorityCutoff)
|
||||
return false;
|
||||
|
||||
@ -272,7 +271,7 @@ bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, i
|
||||
|
||||
void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
// Note that it will not always be the case that memoryUseBytes() <= maxMemoryLimitBytes(),
|
||||
// because we are not at liberty to delete textures that are referenced by the impl tree to
|
||||
@ -307,14 +306,14 @@ void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider)
|
||||
|
||||
void PrioritizedTextureManager::clearAllMemory(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(resourceProvider);
|
||||
evictBackingsToReduceMemory(0, PriorityCalculator::allowEverythingCutoff(), EvictAnything, resourceProvider);
|
||||
}
|
||||
|
||||
bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(resourceProvider);
|
||||
// If we are in the process of uploading a new frame then the backings at the very end of
|
||||
// the list are not sorted by priority. Sort them before doing the eviction.
|
||||
@ -325,14 +324,14 @@ bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int
|
||||
|
||||
void PrioritizedTextureManager::getEvictedBackings(BackingList& evictedBackings)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
evictedBackings.clear();
|
||||
evictedBackings.insert(evictedBackings.begin(), m_evictedBackings.begin(), m_evictedBackings.end());
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evictedBackings)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
for (BackingList::const_iterator it = evictedBackings.begin(); it != evictedBackings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = (*it);
|
||||
if (backing->owner())
|
||||
@ -342,7 +341,7 @@ void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evicted
|
||||
|
||||
void PrioritizedTextureManager::deleteUnlinkedEvictedBackings()
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()));
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
BackingList newEvictedBackings;
|
||||
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = (*it);
|
||||
@ -365,7 +364,7 @@ bool PrioritizedTextureManager::linkedEvictedBackingsExist() const
|
||||
|
||||
void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
DCHECK(texture);
|
||||
DCHECK(!texture->textureManager());
|
||||
DCHECK(!texture->backing());
|
||||
@ -378,7 +377,7 @@ void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture)
|
||||
|
||||
void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()));
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
DCHECK(texture);
|
||||
DCHECK(ContainsKey(m_textures, texture));
|
||||
|
||||
@ -390,14 +389,14 @@ void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture)
|
||||
|
||||
void PrioritizedTextureManager::returnBackingTexture(PrioritizedTexture* texture)
|
||||
{
|
||||
DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()));
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
if (texture->backing())
|
||||
texture->unlink();
|
||||
}
|
||||
|
||||
PrioritizedTexture::Backing* PrioritizedTextureManager::createBacking(gfx::Size size, GLenum format, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(resourceProvider);
|
||||
ResourceProvider::ResourceId resourceId = resourceProvider->createResource(m_pool, size, format, ResourceProvider::TextureUsageAny);
|
||||
PrioritizedTexture::Backing* backing = new PrioritizedTexture::Backing(resourceId, resourceProvider, size, format);
|
||||
@ -407,7 +406,7 @@ PrioritizedTexture::Backing* PrioritizedTextureManager::createBacking(gfx::Size
|
||||
|
||||
void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_proxy->isImplThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(resourceProvider);
|
||||
DCHECK(!m_backings.empty());
|
||||
PrioritizedTexture::Backing* backing = m_backings.front();
|
||||
@ -425,7 +424,7 @@ void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* reso
|
||||
void PrioritizedTextureManager::assertInvariants()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
// If we hit any of these asserts, there is a bug in this class. To see
|
||||
// where the bug is, call this function at the beginning and end of
|
||||
@ -473,9 +472,4 @@ void PrioritizedTextureManager::assertInvariants()
|
||||
#endif
|
||||
}
|
||||
|
||||
const Proxy* PrioritizedTextureManager::proxyForDebug() const
|
||||
{
|
||||
return m_proxy;
|
||||
}
|
||||
|
||||
} // namespace cc
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "base/hash_tables.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "cc/cc_export.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/priority_calculator.h"
|
||||
#include "cc/texture.h"
|
||||
@ -33,13 +32,12 @@ struct hash<cc::PrioritizedTexture*> {
|
||||
namespace cc {
|
||||
|
||||
class PriorityCalculator;
|
||||
class Proxy;
|
||||
|
||||
class CC_EXPORT PrioritizedTextureManager {
|
||||
public:
|
||||
static scoped_ptr<PrioritizedTextureManager> create(size_t maxMemoryLimitBytes, int maxTextureSize, int pool, const Proxy* proxy)
|
||||
static scoped_ptr<PrioritizedTextureManager> create(size_t maxMemoryLimitBytes, int maxTextureSize, int pool)
|
||||
{
|
||||
return make_scoped_ptr(new PrioritizedTextureManager(maxMemoryLimitBytes, maxTextureSize, pool, proxy));
|
||||
return make_scoped_ptr(new PrioritizedTextureManager(maxMemoryLimitBytes, maxTextureSize, pool));
|
||||
}
|
||||
scoped_ptr<PrioritizedTexture> createTexture(gfx::Size size, GLenum format)
|
||||
{
|
||||
@ -110,8 +108,6 @@ public:
|
||||
// Mark all textures' backings as being in the drawing impl tree.
|
||||
void updateBackingsInDrawingImplTree();
|
||||
|
||||
const Proxy* proxyForDebug() const;
|
||||
|
||||
private:
|
||||
friend class PrioritizedTextureTest;
|
||||
|
||||
@ -146,7 +142,7 @@ private:
|
||||
return a < b;
|
||||
}
|
||||
|
||||
PrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool, const Proxy* proxy);
|
||||
PrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool);
|
||||
|
||||
bool evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy, ResourceProvider*);
|
||||
PrioritizedTexture::Backing* createBacking(gfx::Size, GLenum format, ResourceProvider*);
|
||||
@ -172,8 +168,6 @@ private:
|
||||
typedef base::hash_set<PrioritizedTexture*> TextureSet;
|
||||
typedef std::vector<PrioritizedTexture*> TextureVector;
|
||||
|
||||
const Proxy* m_proxy;
|
||||
|
||||
TextureSet m_textures;
|
||||
// This list is always sorted in eviction order, with the exception the
|
||||
// newly-allocated or recycled textures at the very end of the tail that
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/test/fake_graphics_context.h"
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "cc/test/tiled_layer_test_common.h"
|
||||
#include "cc/texture.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -22,18 +21,17 @@ namespace cc {
|
||||
class PrioritizedTextureTest : public testing::Test {
|
||||
public:
|
||||
PrioritizedTextureTest()
|
||||
: m_proxy(scoped_ptr<Thread>(NULL))
|
||||
, m_textureSize(256, 256)
|
||||
: m_textureSize(256, 256)
|
||||
, m_textureFormat(GL_RGBA)
|
||||
, m_context(WebKit::createFakeGraphicsContext())
|
||||
{
|
||||
DebugScopedSetImplThread implThread(&m_proxy);
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_resourceProvider = ResourceProvider::create(m_context.get());
|
||||
}
|
||||
|
||||
virtual ~PrioritizedTextureTest()
|
||||
{
|
||||
DebugScopedSetImplThread implThread(&m_proxy);
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_resourceProvider.reset();
|
||||
}
|
||||
|
||||
@ -44,7 +42,7 @@ public:
|
||||
|
||||
scoped_ptr<PrioritizedTextureManager> createManager(size_t maxTextures)
|
||||
{
|
||||
return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0, &m_proxy);
|
||||
return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0);
|
||||
}
|
||||
|
||||
bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLate)
|
||||
@ -53,7 +51,7 @@ public:
|
||||
if (requestLate)
|
||||
texture->requestLate();
|
||||
textureManagerAssertInvariants(texture->textureManager());
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
bool success = texture->canAcquireBackingTexture();
|
||||
if (success)
|
||||
texture->acquireBackingTexture(resourceProvider());
|
||||
@ -68,7 +66,7 @@ public:
|
||||
|
||||
void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textureManager)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->pushTexturePrioritiesToBackings();
|
||||
}
|
||||
|
||||
@ -80,7 +78,7 @@ public:
|
||||
void textureManagerAssertInvariants(PrioritizedTextureManager* textureManager)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->assertInvariants();
|
||||
#endif
|
||||
}
|
||||
@ -91,7 +89,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
FakeProxy m_proxy;
|
||||
const gfx::Size m_textureSize;
|
||||
const GLenum m_textureFormat;
|
||||
scoped_ptr<GraphicsContext> m_context;
|
||||
@ -138,7 +135,7 @@ TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit)
|
||||
EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -159,7 +156,7 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
validateTexture(textures[i], false);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -172,7 +169,7 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 5);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -185,14 +182,14 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -216,7 +213,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], true), i < 6);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
|
||||
@ -228,7 +225,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
@ -236,7 +233,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
|
||||
// Do a one-time eviction for one more texture based on priority cutoff
|
||||
PrioritizedTextureManager::BackingList evictedBackings;
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider());
|
||||
textureManager->getEvictedBackings(evictedBackings);
|
||||
EXPECT_EQ(0, evictedBackings.size());
|
||||
@ -252,12 +249,12 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -317,7 +314,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
|
||||
EXPECT_FALSE(textures[2]->haveBackingTexture());
|
||||
EXPECT_FALSE(textures[3]->haveBackingTexture());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -357,7 +354,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
|
||||
EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -377,7 +374,7 @@ TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst)
|
||||
EXPECT_TRUE(texture->haveBackingTexture());
|
||||
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
textureManager.reset();
|
||||
@ -405,7 +402,7 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
|
||||
texture->setTextureManager(0);
|
||||
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManagerOne->clearAllMemory(resourceProvider());
|
||||
}
|
||||
textureManagerOne.reset();
|
||||
@ -421,7 +418,7 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
|
||||
EXPECT_TRUE(texture->canAcquireBackingTexture());
|
||||
EXPECT_TRUE(texture->haveBackingTexture());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManagerTwo->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -467,7 +464,7 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -504,7 +501,7 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -544,7 +541,7 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -592,7 +589,7 @@ TEST_F(PrioritizedTextureTest, requestLateBackingsSorting)
|
||||
for (size_t i = 1; i < maxTextures; i += 2)
|
||||
EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
@ -617,7 +614,7 @@ TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources)
|
||||
EXPECT_TRUE(validateTexture(textures[i], false));
|
||||
|
||||
ResourceUpdateQueue queue;
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
for (size_t i = 0; i < maxTextures; ++i) {
|
||||
const ResourceUpdate upload = ResourceUpdate::Create(
|
||||
textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
|
||||
@ -669,7 +666,7 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
|
||||
// Validate the statistics.
|
||||
{
|
||||
DebugScopedSetImplThread implThread(&m_proxy);
|
||||
DebugScopedSetImplThread implThread;
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes());
|
||||
@ -685,7 +682,7 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
|
||||
// Verify that we still see the old values.
|
||||
{
|
||||
DebugScopedSetImplThread implThread(&m_proxy);
|
||||
DebugScopedSetImplThread implThread;
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes());
|
||||
@ -693,14 +690,14 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
|
||||
// Push priorities to backings, and verify we see the new values.
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->pushTexturePrioritiesToBackings();
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyBytes());
|
||||
}
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
|
75
cc/proxy.cc
75
cc/proxy.cc
@ -7,52 +7,70 @@
|
||||
#include "cc/proxy.h"
|
||||
|
||||
#include "cc/thread.h"
|
||||
#include "cc/thread_impl.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
Thread* Proxy::mainThread() const
|
||||
{
|
||||
return m_mainThread.get();
|
||||
namespace {
|
||||
#ifndef NDEBUG
|
||||
bool implThreadIsOverridden = false;
|
||||
bool s_isMainThreadBlocked = false;
|
||||
#endif
|
||||
Thread* s_mainThread = 0;
|
||||
Thread* s_implThread = 0;
|
||||
}
|
||||
|
||||
bool Proxy::hasImplThread() const
|
||||
void Proxy::setMainThread(Thread* thread)
|
||||
{
|
||||
return m_implThread;
|
||||
s_mainThread = thread;
|
||||
}
|
||||
|
||||
Thread* Proxy::implThread() const
|
||||
Thread* Proxy::mainThread()
|
||||
{
|
||||
return m_implThread.get();
|
||||
return s_mainThread;
|
||||
}
|
||||
|
||||
Thread* Proxy::currentThread() const
|
||||
bool Proxy::hasImplThread()
|
||||
{
|
||||
if (mainThread() && mainThread()->belongsToCurrentThread())
|
||||
return mainThread();
|
||||
if (implThread() && implThread()->belongsToCurrentThread())
|
||||
return implThread();
|
||||
return s_implThread;
|
||||
}
|
||||
|
||||
void Proxy::setImplThread(Thread* thread)
|
||||
{
|
||||
s_implThread = thread;
|
||||
}
|
||||
|
||||
Thread* Proxy::implThread()
|
||||
{
|
||||
return s_implThread;
|
||||
}
|
||||
|
||||
Thread* Proxy::currentThread()
|
||||
{
|
||||
if (s_mainThread && s_mainThread->belongsToCurrentThread())
|
||||
return s_mainThread;
|
||||
if (s_implThread && s_implThread->belongsToCurrentThread())
|
||||
return s_implThread;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Proxy::isMainThread() const
|
||||
bool Proxy::isMainThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DCHECK(mainThread());
|
||||
if (m_implThreadIsOverridden)
|
||||
DCHECK(s_mainThread);
|
||||
if (implThreadIsOverridden)
|
||||
return false;
|
||||
return mainThread()->belongsToCurrentThread();
|
||||
return s_mainThread->belongsToCurrentThread();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Proxy::isImplThread() const
|
||||
bool Proxy::isImplThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (m_implThreadIsOverridden)
|
||||
if (implThreadIsOverridden)
|
||||
return true;
|
||||
return implThread() && implThread()->belongsToCurrentThread();
|
||||
return s_implThread && s_implThread->belongsToCurrentThread();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
@ -61,14 +79,14 @@ bool Proxy::isImplThread() const
|
||||
#ifndef NDEBUG
|
||||
void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
|
||||
{
|
||||
m_implThreadIsOverridden = isImplThread;
|
||||
implThreadIsOverridden = isImplThread;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Proxy::isMainThreadBlocked() const
|
||||
bool Proxy::isMainThreadBlocked()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
return m_isMainThreadBlocked;
|
||||
return s_isMainThreadBlocked;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
@ -77,18 +95,13 @@ bool Proxy::isMainThreadBlocked() const
|
||||
#ifndef NDEBUG
|
||||
void Proxy::setMainThreadBlocked(bool isMainThreadBlocked)
|
||||
{
|
||||
m_isMainThreadBlocked = isMainThreadBlocked;
|
||||
s_isMainThreadBlocked = isMainThreadBlocked;
|
||||
}
|
||||
#endif
|
||||
|
||||
Proxy::Proxy(scoped_ptr<Thread> implThread)
|
||||
: m_mainThread(ThreadImpl::createForCurrentThread())
|
||||
, m_implThread(implThread.Pass())
|
||||
#ifndef NDEBUG
|
||||
, m_implThreadIsOverridden(false)
|
||||
, m_isMainThreadBlocked(false)
|
||||
#endif
|
||||
Proxy::Proxy()
|
||||
{
|
||||
DCHECK(isMainThread());
|
||||
}
|
||||
|
||||
Proxy::~Proxy()
|
||||
|
56
cc/proxy.h
56
cc/proxy.h
@ -8,7 +8,6 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/time.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include <public/WebCompositorOutputSurface.h>
|
||||
#include "cc/cc_export.h"
|
||||
|
||||
@ -27,21 +26,15 @@ struct RendererCapabilities;
|
||||
// the compositor over to the compositor implementation.
|
||||
class CC_EXPORT Proxy {
|
||||
public:
|
||||
Thread* mainThread() const;
|
||||
bool hasImplThread() const;
|
||||
Thread* implThread() const;
|
||||
static void setMainThread(Thread*);
|
||||
static Thread* mainThread();
|
||||
|
||||
static bool hasImplThread();
|
||||
static void setImplThread(Thread*);
|
||||
static Thread* implThread();
|
||||
|
||||
// Returns 0 if the current thread is neither the main thread nor the impl thread.
|
||||
Thread* currentThread() const;
|
||||
|
||||
// Debug hooks
|
||||
bool isMainThread() const;
|
||||
bool isImplThread() const;
|
||||
bool isMainThreadBlocked() const;
|
||||
#ifndef NDEBUG
|
||||
void setMainThreadBlocked(bool);
|
||||
void setCurrentThreadIsImplThread(bool);
|
||||
#endif
|
||||
static Thread* currentThread();
|
||||
|
||||
virtual ~Proxy();
|
||||
|
||||
@ -97,45 +90,46 @@ public:
|
||||
|
||||
virtual void acquireLayerTextures() = 0;
|
||||
|
||||
// Debug hooks
|
||||
static bool isMainThread();
|
||||
static bool isImplThread();
|
||||
static bool isMainThreadBlocked();
|
||||
#ifndef NDEBUG
|
||||
static void setMainThreadBlocked(bool);
|
||||
#endif
|
||||
|
||||
// Testing hooks
|
||||
virtual void loseContext() = 0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
static void setCurrentThreadIsImplThread(bool);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
explicit Proxy(scoped_ptr<Thread> implThread);
|
||||
Proxy();
|
||||
friend class DebugScopedSetImplThread;
|
||||
friend class DebugScopedSetMainThread;
|
||||
friend class DebugScopedSetMainThreadBlocked;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Proxy);
|
||||
|
||||
scoped_ptr<Thread> m_mainThread;
|
||||
scoped_ptr<Thread> m_implThread;
|
||||
#ifndef NDEBUG
|
||||
bool m_implThreadIsOverridden;
|
||||
bool m_isMainThreadBlocked;
|
||||
#endif
|
||||
};
|
||||
|
||||
class DebugScopedSetMainThreadBlocked {
|
||||
public:
|
||||
explicit DebugScopedSetMainThreadBlocked(Proxy* proxy)
|
||||
: m_proxy(proxy)
|
||||
DebugScopedSetMainThreadBlocked()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!m_proxy->isMainThreadBlocked());
|
||||
m_proxy->setMainThreadBlocked(true);
|
||||
DCHECK(!Proxy::isMainThreadBlocked());
|
||||
Proxy::setMainThreadBlocked(true);
|
||||
#endif
|
||||
}
|
||||
~DebugScopedSetMainThreadBlocked()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DCHECK(m_proxy->isMainThreadBlocked());
|
||||
m_proxy->setMainThreadBlocked(false);
|
||||
DCHECK(Proxy::isMainThreadBlocked());
|
||||
Proxy::setMainThreadBlocked(false);
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
Proxy* m_proxy;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ static void appendQuads(QuadList& quadList, SharedQuadStateList& sharedStateList
|
||||
}
|
||||
|
||||
#define DECLARE_AND_INITIALIZE_TEST_QUADS \
|
||||
DebugScopedSetImplThread impl; \
|
||||
QuadList quadList; \
|
||||
SharedQuadStateList sharedStateList; \
|
||||
std::vector<LayerImpl*> renderSurfaceLayerList; \
|
||||
|
@ -7,19 +7,19 @@
|
||||
#include "cc/rate_limiter.h"
|
||||
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/thread.h"
|
||||
#include <public/WebGraphicsContext3D.h>
|
||||
|
||||
namespace cc {
|
||||
|
||||
scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client, Thread* thread)
|
||||
scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client)
|
||||
{
|
||||
return make_scoped_refptr(new RateLimiter(context, client, thread));
|
||||
return make_scoped_refptr(new RateLimiter(context, client));
|
||||
}
|
||||
|
||||
RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client, Thread* thread)
|
||||
: m_thread(thread)
|
||||
, m_context(context)
|
||||
RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client)
|
||||
: m_context(context)
|
||||
, m_active(false)
|
||||
, m_client(client)
|
||||
{
|
||||
@ -37,7 +37,7 @@ void RateLimiter::start()
|
||||
|
||||
TRACE_EVENT0("cc", "RateLimiter::start");
|
||||
m_active = true;
|
||||
m_thread->postTask(base::Bind(&RateLimiter::rateLimitContext, this));
|
||||
Proxy::mainThread()->postTask(base::Bind(&RateLimiter::rateLimitContext, this));
|
||||
}
|
||||
|
||||
void RateLimiter::stop()
|
||||
|
@ -13,8 +13,6 @@ class WebGraphicsContext3D;
|
||||
|
||||
namespace cc {
|
||||
|
||||
class Thread;
|
||||
|
||||
class RateLimiterClient {
|
||||
public:
|
||||
virtual void rateLimit() = 0;
|
||||
@ -26,7 +24,7 @@ public:
|
||||
// compositor.
|
||||
class RateLimiter : public base::RefCounted<RateLimiter> {
|
||||
public:
|
||||
static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, RateLimiterClient*, Thread*);
|
||||
static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
|
||||
|
||||
void start();
|
||||
|
||||
@ -34,7 +32,7 @@ public:
|
||||
void stop();
|
||||
|
||||
private:
|
||||
RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*, Thread*);
|
||||
RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
|
||||
~RateLimiter();
|
||||
friend class base::RefCounted<RateLimiter>;
|
||||
|
||||
@ -45,7 +43,6 @@ private:
|
||||
WebKit::WebGraphicsContext3D* m_context;
|
||||
bool m_active;
|
||||
RateLimiterClient *m_client;
|
||||
Thread* m_thread;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
|
||||
// This test checks that surfacePropertyChanged() has the correct behavior.
|
||||
//
|
||||
|
||||
// This will fake that we are on the correct thread for testing purposes.
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(1);
|
||||
owningLayer->createRenderSurface();
|
||||
ASSERT_TRUE(owningLayer->renderSurface());
|
||||
@ -73,6 +76,9 @@ TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
|
||||
|
||||
TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
|
||||
{
|
||||
// This will fake that we are on the correct thread for testing purposes.
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
|
||||
|
||||
scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
|
||||
@ -124,6 +130,9 @@ private:
|
||||
|
||||
TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
|
||||
{
|
||||
// This will fake that we are on the correct thread for testing purposes.
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
|
||||
scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
|
||||
|
||||
scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
|
||||
|
@ -24,7 +24,6 @@ public:
|
||||
virtual void setFullRootLayerDamage() = 0;
|
||||
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
|
||||
virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
|
||||
virtual bool hasImplThread() const = 0;
|
||||
protected:
|
||||
virtual ~RendererClient() { }
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/string_split.h"
|
||||
#include "base/string_util.h"
|
||||
#include "cc/gl_renderer.h" // For the GLC() macro.
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/texture_uploader.h"
|
||||
#include "cc/transferable_resource.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
@ -130,13 +131,13 @@ ResourceProvider::~ResourceProvider()
|
||||
|
||||
WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_context->context3D();
|
||||
}
|
||||
|
||||
bool ResourceProvider::inUseByConsumer(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -159,7 +160,7 @@ ResourceProvider::ResourceId ResourceProvider::createResource(int pool, const gf
|
||||
|
||||
ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const gfx::Size& size, GLenum format, TextureUsageHint hint)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
unsigned textureId = 0;
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
DCHECK(context3d);
|
||||
@ -185,7 +186,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const g
|
||||
|
||||
ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const gfx::Size& size)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
uint8_t* pixels = new uint8_t[size.width() * size.height() * 4];
|
||||
|
||||
@ -197,7 +198,7 @@ ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const gfx:
|
||||
|
||||
ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture(unsigned textureId)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(m_context->context3D());
|
||||
ResourceId id = m_nextId++;
|
||||
Resource resource(textureId, 0, gfx::Size(), 0);
|
||||
@ -208,7 +209,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
|
||||
|
||||
void ResourceProvider::deleteResource(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -240,7 +241,7 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
|
||||
|
||||
void ResourceProvider::deleteOwnedResources(int pool)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceIdArray toDelete;
|
||||
for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) {
|
||||
if (it->second.pool == pool && !it->second.external && !it->second.markedForDeletion)
|
||||
@ -260,7 +261,7 @@ ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
|
||||
|
||||
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());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -331,7 +332,7 @@ void ResourceProvider::flushUploads()
|
||||
|
||||
void ResourceProvider::flush()
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
if (context3d)
|
||||
context3d->flush();
|
||||
@ -339,7 +340,7 @@ void ResourceProvider::flush()
|
||||
|
||||
bool ResourceProvider::shallowFlushIfSupported()
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
if (!context3d || !m_useShallowFlush)
|
||||
return false;
|
||||
@ -350,7 +351,7 @@ bool ResourceProvider::shallowFlushIfSupported()
|
||||
|
||||
const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
|
||||
if (it == m_resources.end()) {
|
||||
@ -378,7 +379,7 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
|
||||
|
||||
void ResourceProvider::unlockForRead(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -389,7 +390,7 @@ void ResourceProvider::unlockForRead(ResourceId id)
|
||||
|
||||
const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -403,7 +404,7 @@ const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id)
|
||||
|
||||
void ResourceProvider::unlockForWrite(ResourceId id)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
Resource* resource = &it->second;
|
||||
@ -486,7 +487,7 @@ ResourceProvider::ResourceProvider(GraphicsContext* context)
|
||||
|
||||
bool ResourceProvider::initialize()
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
if (!context3d) {
|
||||
m_maxTextureSize = INT_MAX / 2;
|
||||
@ -522,7 +523,7 @@ bool ResourceProvider::initialize()
|
||||
|
||||
int ResourceProvider::createChild(int pool)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
Child childInfo;
|
||||
childInfo.pool = pool;
|
||||
int child = m_nextChild++;
|
||||
@ -532,7 +533,7 @@ int ResourceProvider::createChild(int pool)
|
||||
|
||||
void ResourceProvider::destroyChild(int child)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ChildMap::iterator it = m_children.find(child);
|
||||
DCHECK(it != m_children.end());
|
||||
deleteOwnedResources(it->second.pool);
|
||||
@ -542,7 +543,7 @@ void ResourceProvider::destroyChild(int child)
|
||||
|
||||
const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ChildMap::const_iterator it = m_children.find(child);
|
||||
DCHECK(it != m_children.end());
|
||||
return it->second.childToParentMap;
|
||||
@ -550,7 +551,7 @@ const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int
|
||||
|
||||
void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, TransferableResourceList* list)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
list->sync_point = 0;
|
||||
list->resources.clear();
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
@ -571,7 +572,7 @@ void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra
|
||||
|
||||
void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources, TransferableResourceList* list)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
list->sync_point = 0;
|
||||
list->resources.clear();
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
@ -597,7 +598,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso
|
||||
|
||||
void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
if (!context3d || !context3d->makeContextCurrent()) {
|
||||
// FIXME: Implement this path for software compositing.
|
||||
@ -629,7 +630,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis
|
||||
|
||||
void ResourceProvider::receiveFromParent(const TransferableResourceList& resources)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
WebGraphicsContext3D* context3d = m_context->context3D();
|
||||
if (!context3d || !context3d->makeContextCurrent()) {
|
||||
// FIXME: Implement this path for software compositing.
|
||||
@ -653,7 +654,7 @@ void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc
|
||||
|
||||
bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource)
|
||||
{
|
||||
DCHECK(m_threadChecker.CalledOnValidThread());
|
||||
DCHECK(Proxy::isImplThread());
|
||||
ResourceMap::const_iterator it = m_resources.find(id);
|
||||
CHECK(it != m_resources.end());
|
||||
const Resource* source = &it->second;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/hash_tables.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/threading/thread_checker.h"
|
||||
#include "cc/cc_export.h"
|
||||
#include "cc/graphics_context.h"
|
||||
#include "cc/texture_copier.h"
|
||||
@ -33,8 +32,8 @@ namespace cc {
|
||||
|
||||
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).
|
||||
// Thread-safety notes: this class is not thread-safe and can only be called
|
||||
// from the thread it was created on (in practice, the compositor thread).
|
||||
class CC_EXPORT ResourceProvider {
|
||||
public:
|
||||
typedef unsigned ResourceId;
|
||||
@ -263,8 +262,6 @@ private:
|
||||
scoped_ptr<AcceleratedTextureCopier> m_textureCopier;
|
||||
int m_maxTextureSize;
|
||||
|
||||
base::ThreadChecker m_threadChecker;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
|
||||
};
|
||||
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include "cc/graphics_context.h"
|
||||
#include "cc/scoped_ptr_deque.h"
|
||||
#include "cc/scoped_ptr_hash_map.h"
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
#include "third_party/khronos/GLES2/gl2ext.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include <public/WebGraphicsContext3D.h>
|
||||
|
||||
using namespace cc;
|
||||
@ -300,6 +300,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
DebugScopedSetImplThread implThread;
|
||||
scoped_ptr<ContextSharedData> m_sharedData;
|
||||
scoped_ptr<GraphicsContext> m_context;
|
||||
scoped_ptr<ResourceProvider> m_resourceProvider;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/texture_copier.h"
|
||||
#include "cc/thread.h"
|
||||
@ -66,9 +67,8 @@ size_t ResourceUpdateController::maxFullUpdatesPerTick(
|
||||
return texturesPerTick ? texturesPerTick : 1;
|
||||
}
|
||||
|
||||
ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider, bool hasImplThread)
|
||||
ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider)
|
||||
: m_client(client)
|
||||
, m_hasImplThread(hasImplThread)
|
||||
, m_queue(queue.Pass())
|
||||
, m_resourceProvider(resourceProvider)
|
||||
, m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider))
|
||||
@ -128,10 +128,10 @@ void ResourceUpdateController::updateTexture(ResourceUpdate update)
|
||||
DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
|
||||
ResourceProvider::GLTexture);
|
||||
|
||||
WebGraphicsContext3D* paintContext = m_hasImplThread ?
|
||||
WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ?
|
||||
WebSharedGraphicsContext3D::compositorThreadContext() :
|
||||
WebSharedGraphicsContext3D::mainThreadContext();
|
||||
GrContext* paintGrContext = m_hasImplThread ?
|
||||
GrContext* paintGrContext = Proxy::hasImplThread() ?
|
||||
WebSharedGraphicsContext3D::compositorThreadGrContext() :
|
||||
WebSharedGraphicsContext3D::mainThreadGrContext();
|
||||
|
||||
|
@ -27,9 +27,9 @@ protected:
|
||||
|
||||
class CC_EXPORT ResourceUpdateController {
|
||||
public:
|
||||
static scoped_ptr<ResourceUpdateController> create(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider, bool hasImplThread)
|
||||
static scoped_ptr<ResourceUpdateController> create(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider)
|
||||
{
|
||||
return make_scoped_ptr(new ResourceUpdateController(client, thread, queue.Pass(), resourceProvider, hasImplThread));
|
||||
return make_scoped_ptr(new ResourceUpdateController(client, thread, queue.Pass(), resourceProvider));
|
||||
}
|
||||
static size_t maxPartialTextureUpdates();
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
virtual size_t updateMoreTexturesSize() const;
|
||||
|
||||
protected:
|
||||
ResourceUpdateController(ResourceUpdateControllerClient*, Thread*, scoped_ptr<ResourceUpdateQueue>, ResourceProvider*, bool hasImplThread);
|
||||
ResourceUpdateController(ResourceUpdateControllerClient*, Thread*, scoped_ptr<ResourceUpdateQueue>, ResourceProvider*);
|
||||
|
||||
private:
|
||||
static size_t maxFullUpdatesPerTick(ResourceProvider*);
|
||||
@ -63,7 +63,6 @@ private:
|
||||
void onTimerFired();
|
||||
|
||||
ResourceUpdateControllerClient* m_client;
|
||||
bool m_hasImplThread;
|
||||
scoped_ptr<ResourceUpdateQueue> m_queue;
|
||||
bool m_contentsTexturesPurged;
|
||||
ResourceProvider* m_resourceProvider;
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "cc/resource_update_controller.h"
|
||||
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
#include "cc/test/fake_web_graphics_context_3d.h"
|
||||
#include "cc/test/scheduler_test_common.h"
|
||||
@ -64,9 +63,8 @@ private:
|
||||
class ResourceUpdateControllerTest : public Test {
|
||||
public:
|
||||
ResourceUpdateControllerTest()
|
||||
: m_proxy(scoped_ptr<Thread>(NULL))
|
||||
, m_queue(make_scoped_ptr(new ResourceUpdateQueue))
|
||||
, m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool, &m_proxy))
|
||||
: m_queue(make_scoped_ptr(new ResourceUpdateQueue))
|
||||
, m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_fullUploadCountExpected(0)
|
||||
, m_partialCountExpected(0)
|
||||
, m_totalUploadCountExpected(0)
|
||||
@ -81,7 +79,7 @@ public:
|
||||
~ResourceUpdateControllerTest()
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked(&m_proxy);
|
||||
implThreadAndMainThreadBlocked;
|
||||
m_textureManager->clearAllMemory(m_resourceProvider.get());
|
||||
}
|
||||
|
||||
@ -124,6 +122,7 @@ protected:
|
||||
}
|
||||
m_textureManager->prioritizeTextures();
|
||||
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_resourceProvider = ResourceProvider::create(m_context.get());
|
||||
}
|
||||
|
||||
@ -170,20 +169,18 @@ protected:
|
||||
void updateTextures()
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked(&m_proxy);
|
||||
implThreadAndMainThreadBlocked;
|
||||
scoped_ptr<ResourceUpdateController> updateController =
|
||||
ResourceUpdateController::create(
|
||||
NULL,
|
||||
m_proxy.implThread(),
|
||||
Proxy::implThread(),
|
||||
m_queue.Pass(),
|
||||
m_resourceProvider.get(),
|
||||
m_proxy.hasImplThread());
|
||||
m_resourceProvider.get());
|
||||
updateController->finalize();
|
||||
}
|
||||
|
||||
protected:
|
||||
// Classes required to interact and test the ResourceUpdateController
|
||||
FakeProxy m_proxy;
|
||||
scoped_ptr<GraphicsContext> m_context;
|
||||
scoped_ptr<ResourceProvider> m_resourceProvider;
|
||||
scoped_ptr<ResourceUpdateQueue> m_queue;
|
||||
@ -343,7 +340,7 @@ public:
|
||||
|
||||
protected:
|
||||
FakeResourceUpdateController(cc::ResourceUpdateControllerClient* client, cc::Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider)
|
||||
: cc::ResourceUpdateController(client, thread, queue.Pass(), resourceProvider, false)
|
||||
: cc::ResourceUpdateController(client, thread, queue.Pass(), resourceProvider)
|
||||
, m_updateMoreTexturesSize(0) { }
|
||||
|
||||
base::TimeTicks m_now;
|
||||
@ -368,7 +365,7 @@ TEST_F(ResourceUpdateControllerTest, UpdateMoreTextures)
|
||||
appendPartialUploadsToUpdateQueue(0);
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked(&m_proxy);
|
||||
implThreadAndMainThreadBlocked;
|
||||
scoped_ptr<FakeResourceUpdateController> controller(FakeResourceUpdateController::create(&client, &thread, m_queue.Pass(), m_resourceProvider.get()));
|
||||
|
||||
controller->setNow(
|
||||
@ -414,7 +411,7 @@ TEST_F(ResourceUpdateControllerTest, NoMoreUpdates)
|
||||
appendPartialUploadsToUpdateQueue(0);
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked(&m_proxy);
|
||||
implThreadAndMainThreadBlocked;
|
||||
scoped_ptr<FakeResourceUpdateController> controller(FakeResourceUpdateController::create(&client, &thread, m_queue.Pass(), m_resourceProvider.get()));
|
||||
|
||||
controller->setNow(
|
||||
@ -454,7 +451,7 @@ TEST_F(ResourceUpdateControllerTest, UpdatesCompleteInFiniteTime)
|
||||
appendPartialUploadsToUpdateQueue(0);
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked(&m_proxy);
|
||||
implThreadAndMainThreadBlocked;
|
||||
scoped_ptr<FakeResourceUpdateController> controller(FakeResourceUpdateController::create(&client, &thread, m_queue.Pass(), m_resourceProvider.get()));
|
||||
|
||||
controller->setNow(
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "cc/scoped_texture.h"
|
||||
|
||||
#include "cc/renderer.h"
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/test/fake_graphics_context.h"
|
||||
#include "cc/test/tiled_layer_test_common.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -21,6 +22,7 @@ namespace {
|
||||
TEST(ScopedTextureTest, NewScopedTexture)
|
||||
{
|
||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||
DebugScopedSetImplThread implThread;
|
||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
||||
|
||||
@ -35,6 +37,7 @@ TEST(ScopedTextureTest, NewScopedTexture)
|
||||
TEST(ScopedTextureTest, CreateScopedTexture)
|
||||
{
|
||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||
DebugScopedSetImplThread implThread;
|
||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
||||
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
||||
@ -51,6 +54,7 @@ TEST(ScopedTextureTest, CreateScopedTexture)
|
||||
TEST(ScopedTextureTest, ScopedTextureIsDeleted)
|
||||
{
|
||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||
DebugScopedSetImplThread implThread;
|
||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||
|
||||
{
|
||||
@ -78,6 +82,7 @@ TEST(ScopedTextureTest, ScopedTextureIsDeleted)
|
||||
TEST(ScopedTextureTest, LeakScopedTexture)
|
||||
{
|
||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||
DebugScopedSetImplThread implThread;
|
||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||
|
||||
{
|
||||
|
@ -30,6 +30,8 @@ protected:
|
||||
m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get());
|
||||
}
|
||||
|
||||
DebugScopedSetImplThread implThread;
|
||||
|
||||
scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController;
|
||||
scoped_ptr<LayerImpl> m_scrollLayer;
|
||||
LayerImpl* m_contentLayer;
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
|
||||
TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
WebKit::WebScrollbarThemePainter painter;
|
||||
|
||||
{
|
||||
@ -84,6 +86,8 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
|
||||
|
||||
TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
WebKit::WebScrollbarThemePainter painter;
|
||||
|
||||
scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "cc/graphics_context.h"
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/resource_update_controller.h"
|
||||
#include "cc/thread.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
@ -21,8 +20,7 @@ scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost)
|
||||
}
|
||||
|
||||
SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost)
|
||||
: Proxy(scoped_ptr<Thread>(NULL))
|
||||
, m_layerTreeHost(layerTreeHost)
|
||||
: m_layerTreeHost(layerTreeHost)
|
||||
, m_contextLost(false)
|
||||
, m_rendererInitialized(false)
|
||||
, m_nextFrameIsNewlyCommittedFrame(false)
|
||||
@ -34,7 +32,7 @@ SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost)
|
||||
|
||||
void SingleThreadProxy::start()
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
|
||||
}
|
||||
|
||||
@ -73,7 +71,7 @@ void SingleThreadProxy::finishAllRendering()
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
m_layerTreeHostImpl->finishAllRendering();
|
||||
}
|
||||
}
|
||||
@ -101,7 +99,7 @@ void SingleThreadProxy::setSurfaceReady()
|
||||
|
||||
void SingleThreadProxy::setVisible(bool visible)
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
m_layerTreeHostImpl->setVisible(visible);
|
||||
}
|
||||
|
||||
@ -110,7 +108,7 @@ bool SingleThreadProxy::initializeRenderer()
|
||||
DCHECK(Proxy::isMainThread());
|
||||
DCHECK(m_contextBeforeInitialization.get());
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitialization.Pass());
|
||||
if (ok) {
|
||||
m_rendererInitialized = true;
|
||||
@ -133,8 +131,8 @@ bool SingleThreadProxy::recreateContext()
|
||||
|
||||
bool initialized;
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
DebugScopedSetImplThread impl;
|
||||
if (!m_layerTreeHostImpl->contentsTexturesPurged())
|
||||
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
|
||||
initialized = m_layerTreeHostImpl->initializeRenderer(context.Pass());
|
||||
@ -181,8 +179,8 @@ void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue)
|
||||
DCHECK(Proxy::isMainThread());
|
||||
// Commit immediately
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
base::TimeTicks startTime = base::TimeTicks::HighResNow();
|
||||
m_layerTreeHostImpl->beginCommit();
|
||||
@ -195,8 +193,7 @@ void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue)
|
||||
NULL,
|
||||
Proxy::mainThread(),
|
||||
queue.Pass(),
|
||||
m_layerTreeHostImpl->resourceProvider(),
|
||||
hasImplThread());
|
||||
m_layerTreeHostImpl->resourceProvider());
|
||||
updateController->finalize();
|
||||
|
||||
m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
|
||||
@ -257,8 +254,8 @@ void SingleThreadProxy::stop()
|
||||
TRACE_EVENT0("cc", "SingleThreadProxy::stop");
|
||||
DCHECK(Proxy::isMainThread());
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
if (!m_layerTreeHostImpl->contentsTexturesPurged())
|
||||
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
|
||||
@ -280,7 +277,7 @@ void SingleThreadProxy::setNeedsCommitOnImplThread()
|
||||
void SingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector> events, base::Time wallClockTime)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DebugScopedSetMainThread main(this);
|
||||
DebugScopedSetMainThread main;
|
||||
m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
|
||||
}
|
||||
|
||||
@ -321,7 +318,7 @@ void SingleThreadProxy::compositeImmediately()
|
||||
void SingleThreadProxy::forceSerializeOnSwapBuffers()
|
||||
{
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
if (m_rendererInitialized)
|
||||
m_layerTreeHostImpl->renderer()->doNoOp();
|
||||
}
|
||||
@ -342,7 +339,7 @@ bool SingleThreadProxy::commitAndComposite()
|
||||
// Unlink any texture backings that were deleted
|
||||
PrioritizedTextureManager::BackingList evictedContentsTexturesBackings;
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_layerTreeHost->contentsTextureManager()->getEvictedBackings(evictedContentsTexturesBackings);
|
||||
}
|
||||
m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(evictedContentsTexturesBackings);
|
||||
@ -364,7 +361,7 @@ bool SingleThreadProxy::doComposite()
|
||||
{
|
||||
DCHECK(!m_contextLost);
|
||||
{
|
||||
DebugScopedSetImplThread impl(this);
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
if (!m_layerTreeHostImpl->visible())
|
||||
return false;
|
||||
|
@ -91,58 +91,42 @@ private:
|
||||
// code is running on the impl thread to satisfy assertion checks.
|
||||
class DebugScopedSetImplThread {
|
||||
public:
|
||||
explicit DebugScopedSetImplThread(Proxy* proxy)
|
||||
: m_proxy(proxy)
|
||||
DebugScopedSetImplThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_previousValue = m_proxy->m_implThreadIsOverridden;
|
||||
m_proxy->setCurrentThreadIsImplThread(true);
|
||||
Proxy::setCurrentThreadIsImplThread(true);
|
||||
#endif
|
||||
}
|
||||
~DebugScopedSetImplThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_proxy->setCurrentThreadIsImplThread(m_previousValue);
|
||||
Proxy::setCurrentThreadIsImplThread(false);
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
bool m_previousValue;
|
||||
Proxy* m_proxy;
|
||||
};
|
||||
|
||||
// For use in the single-threaded case. In debug builds, it pretends that the
|
||||
// code is running on the main thread to satisfy assertion checks.
|
||||
class DebugScopedSetMainThread {
|
||||
public:
|
||||
explicit DebugScopedSetMainThread(Proxy* proxy)
|
||||
: m_proxy(proxy)
|
||||
DebugScopedSetMainThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_previousValue = m_proxy->m_implThreadIsOverridden;
|
||||
m_proxy->setCurrentThreadIsImplThread(false);
|
||||
Proxy::setCurrentThreadIsImplThread(false);
|
||||
#endif
|
||||
}
|
||||
~DebugScopedSetMainThread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_proxy->setCurrentThreadIsImplThread(m_previousValue);
|
||||
Proxy::setCurrentThreadIsImplThread(true);
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
bool m_previousValue;
|
||||
Proxy* m_proxy;
|
||||
};
|
||||
|
||||
// For use in the single-threaded case. In debug builds, it pretends that the
|
||||
// code is running on the impl thread and that the main thread is blocked to
|
||||
// satisfy assertion checks
|
||||
class DebugScopedSetImplThreadAndMainThreadBlocked {
|
||||
public:
|
||||
explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy)
|
||||
: m_implThread(proxy)
|
||||
, m_mainThreadBlocked(proxy)
|
||||
{
|
||||
}
|
||||
private:
|
||||
DebugScopedSetImplThread m_implThread;
|
||||
DebugScopedSetMainThreadBlocked m_mainThreadBlocked;
|
||||
|
@ -339,7 +339,7 @@ void SoftwareRenderer::drawUnsupportedQuad(const DrawingFrame& frame, const Draw
|
||||
|
||||
bool SoftwareRenderer::swapBuffers()
|
||||
{
|
||||
if (m_client->hasImplThread())
|
||||
if (Proxy::hasImplThread())
|
||||
m_client->onSwapBuffersComplete();
|
||||
return true;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "cc/render_pass.h"
|
||||
#include "cc/render_pass_draw_quad.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/solid_color_draw_quad.h"
|
||||
#include "cc/test/animation_test_common.h"
|
||||
#include "cc/test/fake_web_compositor_output_surface.h"
|
||||
@ -49,9 +50,10 @@ public:
|
||||
virtual void setFullRootLayerDamage() OVERRIDE { }
|
||||
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { };
|
||||
virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { };
|
||||
virtual bool hasImplThread() const OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
DebugScopedSetImplThread m_alwaysImplThread;
|
||||
|
||||
scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface;
|
||||
scoped_ptr<ResourceProvider> m_resourceProvider;
|
||||
scoped_ptr<SoftwareRenderer> m_renderer;
|
||||
|
@ -21,6 +21,8 @@ namespace {
|
||||
|
||||
TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
MockQuadCuller quadCuller;
|
||||
gfx::Size layerSize = gfx::Size(800, 600);
|
||||
gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
|
||||
@ -40,6 +42,8 @@ TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
|
||||
|
||||
TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
SkColor testColor = 0xFFA55AFF;
|
||||
|
||||
MockQuadCuller quadCuller;
|
||||
@ -63,6 +67,8 @@ TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
|
||||
|
||||
TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
const float opacity = 0.5f;
|
||||
|
||||
MockQuadCuller quadCuller;
|
||||
|
@ -1,52 +0,0 @@
|
||||
// Copyright 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cc/test/fake_proxy.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
bool FakeProxy::compositeAndReadback(void *pixels, const gfx::Rect&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FakeProxy::isStarted() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FakeProxy::initializeContext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FakeProxy::initializeRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FakeProxy::recreateContext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const RendererCapabilities& FakeProxy::rendererCapabilities() const
|
||||
{
|
||||
return m_capabilities;
|
||||
}
|
||||
|
||||
bool FakeProxy::commitRequested() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t FakeProxy::maxPartialTextureUpdates() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace cc
|
@ -1,50 +0,0 @@
|
||||
// Copyright 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FakeCCProxy_h
|
||||
#define FakeCCProxy_h
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/thread.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
class FakeProxy : public Proxy {
|
||||
public:
|
||||
explicit FakeProxy(scoped_ptr<Thread> implThread) : Proxy(implThread.Pass()) { }
|
||||
|
||||
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE;
|
||||
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE { }
|
||||
virtual void finishAllRendering() OVERRIDE { }
|
||||
virtual bool isStarted() const OVERRIDE;
|
||||
virtual bool initializeContext() OVERRIDE;
|
||||
virtual void setSurfaceReady() OVERRIDE { }
|
||||
virtual void setVisible(bool) OVERRIDE { }
|
||||
virtual bool initializeRenderer() OVERRIDE;
|
||||
virtual bool recreateContext() OVERRIDE;
|
||||
virtual void renderingStats(RenderingStats*) OVERRIDE { }
|
||||
virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE;
|
||||
virtual void setNeedsAnimate() OVERRIDE { }
|
||||
virtual void setNeedsCommit() OVERRIDE { }
|
||||
virtual void setNeedsRedraw() OVERRIDE { }
|
||||
virtual void setDeferCommits(bool) OVERRIDE { }
|
||||
virtual void didAddAnimation() OVERRIDE { }
|
||||
virtual bool commitRequested() const OVERRIDE;
|
||||
virtual void start() OVERRIDE { }
|
||||
virtual void stop() OVERRIDE { }
|
||||
virtual void forceSerializeOnSwapBuffers() OVERRIDE { }
|
||||
virtual size_t maxPartialTextureUpdates() const OVERRIDE;
|
||||
virtual void acquireLayerTextures() OVERRIDE { }
|
||||
virtual void loseContext() OVERRIDE { }
|
||||
|
||||
private:
|
||||
RendererCapabilities m_capabilities;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -89,9 +89,9 @@ scoped_ptr<WebCompositorOutputSurface> TestHooks::createOutputSurface()
|
||||
return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>();
|
||||
}
|
||||
|
||||
scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
|
||||
scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client)
|
||||
{
|
||||
return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client, proxy));
|
||||
return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client));
|
||||
}
|
||||
|
||||
void MockLayerTreeHostImpl::beginCommit()
|
||||
@ -132,8 +132,8 @@ base::TimeDelta MockLayerTreeHostImpl::lowFrequencyAnimationInterval() const
|
||||
return base::TimeDelta::FromMilliseconds(16);
|
||||
}
|
||||
|
||||
MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
|
||||
: LayerTreeHostImpl(settings, client, proxy)
|
||||
MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client)
|
||||
: LayerTreeHostImpl(settings, client)
|
||||
, m_testHooks(testHooks)
|
||||
{
|
||||
}
|
||||
@ -141,10 +141,10 @@ MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTr
|
||||
// Adapts LayerTreeHost for test. Injects MockLayerTreeHostImpl.
|
||||
class MockLayerTreeHost : public cc::LayerTreeHost {
|
||||
public:
|
||||
static scoped_ptr<MockLayerTreeHost> create(TestHooks* testHooks, cc::LayerTreeHostClient* client, scoped_refptr<cc::Layer> rootLayer, const cc::LayerTreeSettings& settings, scoped_ptr<cc::Thread> implThread)
|
||||
static scoped_ptr<MockLayerTreeHost> create(TestHooks* testHooks, cc::LayerTreeHostClient* client, scoped_refptr<cc::Layer> rootLayer, const cc::LayerTreeSettings& settings)
|
||||
{
|
||||
scoped_ptr<MockLayerTreeHost> layerTreeHost(new MockLayerTreeHost(testHooks, client, settings));
|
||||
bool success = layerTreeHost->initialize(implThread.Pass());
|
||||
bool success = layerTreeHost->initialize();
|
||||
EXPECT_TRUE(success);
|
||||
layerTreeHost->setRootLayer(rootLayer);
|
||||
|
||||
@ -158,7 +158,7 @@ public:
|
||||
|
||||
virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerTreeHostImplClient* client)
|
||||
{
|
||||
return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, proxy()).PassAs<cc::LayerTreeHostImpl>();
|
||||
return MockLayerTreeHostImpl::create(m_testHooks, settings(), client).PassAs<cc::LayerTreeHostImpl>();
|
||||
}
|
||||
|
||||
virtual void didAddAnimation() OVERRIDE
|
||||
@ -275,7 +275,6 @@ ThreadedTest::ThreadedTest()
|
||||
, m_finished(false)
|
||||
, m_scheduled(false)
|
||||
, m_started(false)
|
||||
, m_implThread(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -347,13 +346,11 @@ void ThreadedTest::postDidAddAnimationToMainThread()
|
||||
|
||||
void ThreadedTest::doBeginTest()
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
m_client = ThreadedMockLayerTreeHostClient::create(this);
|
||||
|
||||
scoped_refptr<Layer> rootLayer = Layer::create();
|
||||
scoped_ptr<cc::Thread> implCCThread(NULL);
|
||||
if (m_implThread)
|
||||
implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->message_loop_proxy());
|
||||
m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass());
|
||||
m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings);
|
||||
ASSERT_TRUE(m_layerTreeHost.get());
|
||||
rootLayer->setLayerTreeHost(m_layerTreeHost.get());
|
||||
m_layerTreeHost->setSurfaceReady();
|
||||
@ -387,12 +384,13 @@ void ThreadedTest::scheduleComposite()
|
||||
|
||||
void ThreadedTest::realEndTest()
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
MessageLoop::current()->Quit();
|
||||
}
|
||||
|
||||
void ThreadedTest::dispatchSetNeedsAnimate()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -403,7 +401,7 @@ void ThreadedTest::dispatchSetNeedsAnimate()
|
||||
|
||||
void ThreadedTest::dispatchAddInstantAnimation()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -414,7 +412,7 @@ void ThreadedTest::dispatchAddInstantAnimation()
|
||||
|
||||
void ThreadedTest::dispatchAddAnimation(Layer* layerToReceiveAnimation)
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -425,7 +423,7 @@ void ThreadedTest::dispatchAddAnimation(Layer* layerToReceiveAnimation)
|
||||
|
||||
void ThreadedTest::dispatchSetNeedsAnimateAndCommit()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -438,7 +436,7 @@ void ThreadedTest::dispatchSetNeedsAnimateAndCommit()
|
||||
|
||||
void ThreadedTest::dispatchSetNeedsCommit()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -449,7 +447,7 @@ void ThreadedTest::dispatchSetNeedsCommit()
|
||||
|
||||
void ThreadedTest::dispatchAcquireLayerTextures()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -460,7 +458,7 @@ void ThreadedTest::dispatchAcquireLayerTextures()
|
||||
|
||||
void ThreadedTest::dispatchSetNeedsRedraw()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -471,7 +469,7 @@ void ThreadedTest::dispatchSetNeedsRedraw()
|
||||
|
||||
void ThreadedTest::dispatchSetVisible(bool visible)
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -489,7 +487,7 @@ void ThreadedTest::dispatchComposite()
|
||||
|
||||
void ThreadedTest::dispatchDidAddAnimation()
|
||||
{
|
||||
DCHECK(!proxy() || proxy()->isMainThread());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
if (m_finished)
|
||||
return;
|
||||
@ -507,21 +505,25 @@ void ThreadedTest::runTest(bool threaded)
|
||||
if (threaded) {
|
||||
m_implThread.reset(new base::Thread("ThreadedTest"));
|
||||
ASSERT_TRUE(m_implThread->Start());
|
||||
m_implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->message_loop_proxy());
|
||||
cc::Proxy::setImplThread(m_implCCThread.get());
|
||||
}
|
||||
|
||||
m_mainCCThread = cc::ThreadImpl::createForCurrentThread();
|
||||
m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get());
|
||||
DCHECK(Proxy::isMainThread());
|
||||
m_mainThreadProxy = ScopedThreadProxy::create(Proxy::mainThread());
|
||||
|
||||
initializeSettings(m_settings);
|
||||
|
||||
m_mainCCThread->postTask(base::Bind(&ThreadedTest::doBeginTest, base::Unretained(this)));
|
||||
cc::Proxy::mainThread()->postTask(base::Bind(&ThreadedTest::doBeginTest, base::Unretained(this)));
|
||||
m_timeout.Reset(base::Bind(&ThreadedTest::timeout, base::Unretained(this)));
|
||||
m_mainCCThread->postDelayedTask(m_timeout.callback(), 5000);
|
||||
cc::Proxy::mainThread()->postDelayedTask(m_timeout.callback(), 5000);
|
||||
MessageLoop::current()->Run();
|
||||
if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer())
|
||||
m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
|
||||
m_layerTreeHost.reset();
|
||||
|
||||
cc::Proxy::setImplThread(0);
|
||||
|
||||
m_timeout.Cancel();
|
||||
|
||||
ASSERT_FALSE(m_layerTreeHost.get());
|
||||
|
@ -114,8 +114,7 @@ protected:
|
||||
|
||||
virtual void runTest(bool threaded);
|
||||
|
||||
cc::Thread* implThread() { return proxy() ? proxy()->implThread() : 0; }
|
||||
cc::Proxy* proxy() const { return m_layerTreeHost ? m_layerTreeHost->proxy() : 0; }
|
||||
cc::Thread* implThread() { return m_implCCThread.get(); }
|
||||
|
||||
cc::LayerTreeSettings m_settings;
|
||||
scoped_ptr<MockLayerImplTreeHostClient> m_client;
|
||||
@ -133,6 +132,7 @@ private:
|
||||
bool m_started;
|
||||
|
||||
scoped_ptr<cc::Thread> m_mainCCThread;
|
||||
scoped_ptr<cc::Thread> m_implCCThread;
|
||||
scoped_ptr<base::Thread> m_implThread;
|
||||
base::CancelableClosure m_timeout;
|
||||
};
|
||||
@ -148,7 +148,7 @@ public:
|
||||
// Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
|
||||
class MockLayerTreeHostImpl : public cc::LayerTreeHostImpl {
|
||||
public:
|
||||
static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTreeHostImplClient*, cc::Proxy*);
|
||||
static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTreeHostImplClient*);
|
||||
|
||||
virtual void beginCommit() OVERRIDE;
|
||||
virtual void commitComplete() OVERRIDE;
|
||||
@ -164,7 +164,7 @@ protected:
|
||||
virtual base::TimeDelta lowFrequencyAnimationInterval() const OVERRIDE;
|
||||
|
||||
private:
|
||||
MockLayerTreeHostImpl(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTreeHostImplClient*, cc::Proxy*);
|
||||
MockLayerTreeHostImpl(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTreeHostImplClient*);
|
||||
|
||||
TestHooks* m_testHooks;
|
||||
};
|
||||
|
@ -4,13 +4,18 @@
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "base/test/test_suite.h"
|
||||
#include "cc/thread_impl.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
TestSuite test_suite(argc, argv);
|
||||
MessageLoop message_loop;
|
||||
scoped_ptr<cc::Thread> mainCCThread = cc::ThreadImpl::createForCurrentThread();
|
||||
cc::Proxy::setMainThread(mainCCThread.get());
|
||||
int result = test_suite.Run();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/texture_layer_impl.h"
|
||||
#include "cc/test/fake_layer_tree_host_client.h"
|
||||
#include "cc/thread.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -27,7 +26,7 @@ public:
|
||||
MockLayerImplTreeHost()
|
||||
: LayerTreeHost(&m_fakeClient, LayerTreeSettings())
|
||||
{
|
||||
initialize(scoped_ptr<Thread>(NULL));
|
||||
initialize();
|
||||
}
|
||||
|
||||
MOCK_METHOD0(acquireLayerTextures, void());
|
||||
@ -98,7 +97,10 @@ TEST_F(TextureLayerTest, syncImplWhenDrawing)
|
||||
scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0);
|
||||
ASSERT_TRUE(testLayer);
|
||||
scoped_ptr<TextureLayerImpl> implLayer;
|
||||
implLayer = TextureLayerImpl::create(1);
|
||||
{
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
implLayer = TextureLayerImpl::create(1);
|
||||
}
|
||||
ASSERT_TRUE(implLayer);
|
||||
|
||||
EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
|
||||
@ -142,6 +144,11 @@ TEST_F(TextureLayerTest, syncImplWhenDrawing)
|
||||
testLayer->willModifyTexture();
|
||||
testLayer->setNeedsDisplayRect(dirtyRect);
|
||||
Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
|
||||
|
||||
{
|
||||
DebugScopedSetImplThread setImplThread;
|
||||
delete implLayer.release();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree)
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/scheduler.h"
|
||||
#include "cc/scoped_thread_proxy.h"
|
||||
#include "cc/thread.h"
|
||||
#include <public/WebSharedGraphicsContext3D.h>
|
||||
|
||||
using WebKit::WebSharedGraphicsContext3D;
|
||||
@ -30,14 +29,13 @@ const double contextRecreationTickRate = 0.03;
|
||||
|
||||
namespace cc {
|
||||
|
||||
scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implThread)
|
||||
scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost)
|
||||
{
|
||||
return make_scoped_ptr(new ThreadProxy(layerTreeHost, implThread.Pass())).PassAs<Proxy>();
|
||||
return make_scoped_ptr(new ThreadProxy(layerTreeHost)).PassAs<Proxy>();
|
||||
}
|
||||
|
||||
ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implThread)
|
||||
: Proxy(implThread.Pass())
|
||||
, m_animateRequested(false)
|
||||
ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost)
|
||||
: m_animateRequested(false)
|
||||
, m_commitRequested(false)
|
||||
, m_commitRequestSentToImplThread(false)
|
||||
, m_forcedCommitRequested(false)
|
||||
@ -83,7 +81,7 @@ bool ThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect)
|
||||
|
||||
// Perform a synchronous commit.
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent beginFrameCompletion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceBeginFrameOnImplThread, base::Unretained(this), &beginFrameCompletion));
|
||||
beginFrameCompletion.wait();
|
||||
@ -97,7 +95,7 @@ bool ThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect)
|
||||
request.rect = rect;
|
||||
request.pixels = pixels;
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestReadbackOnImplThread, base::Unretained(this), &request));
|
||||
request.completion.wait();
|
||||
}
|
||||
@ -138,7 +136,7 @@ void ThreadProxy::finishAllRendering()
|
||||
DCHECK(!m_deferCommits);
|
||||
|
||||
// Make sure all GL drawing is finished on the impl thread.
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnImplThread, base::Unretained(this), &completion));
|
||||
completion.wait();
|
||||
@ -176,7 +174,7 @@ void ThreadProxy::setSurfaceReadyOnImplThread()
|
||||
void ThreadProxy::setVisible(bool visible)
|
||||
{
|
||||
TRACE_EVENT0("cc", "ThreadProxy::setVisible");
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThread, base::Unretained(this), &completion, visible));
|
||||
completion.wait();
|
||||
@ -198,7 +196,7 @@ bool ThreadProxy::initializeRenderer()
|
||||
CompletionEvent completion;
|
||||
bool initializeSucceeded = false;
|
||||
RendererCapabilities capabilities;
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeRendererOnImplThread,
|
||||
base::Unretained(this),
|
||||
&completion,
|
||||
@ -232,7 +230,7 @@ bool ThreadProxy::recreateContext()
|
||||
CompletionEvent completion;
|
||||
bool recreateSucceeded = false;
|
||||
RendererCapabilities capabilities;
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImplThread,
|
||||
base::Unretained(this),
|
||||
&completion,
|
||||
@ -250,7 +248,7 @@ void ThreadProxy::renderingStats(RenderingStats* stats)
|
||||
{
|
||||
DCHECK(isMainThread());
|
||||
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplThread,
|
||||
base::Unretained(this), &completion, stats));
|
||||
@ -430,7 +428,7 @@ void ThreadProxy::start()
|
||||
DCHECK(isMainThread());
|
||||
DCHECK(Proxy::implThread());
|
||||
// Create LayerTreeHostImpl.
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler();
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeImplOnImplThread, base::Unretained(this), &completion, handler.release()));
|
||||
@ -447,7 +445,7 @@ void ThreadProxy::stop()
|
||||
|
||||
// Synchronously deletes the impl.
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::layerTreeHostClosedOnImplThread, base::Unretained(this), &completion));
|
||||
@ -463,7 +461,7 @@ void ThreadProxy::stop()
|
||||
|
||||
void ThreadProxy::forceSerializeOnSwapBuffers()
|
||||
{
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceSerializeOnSwapBuffersOnImplThread, base::Unretained(this), &completion));
|
||||
completion.wait();
|
||||
@ -616,7 +614,7 @@ void ThreadProxy::beginFrame()
|
||||
{
|
||||
TRACE_EVENT0("cc", "commit");
|
||||
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
|
||||
base::TimeTicks startTime = base::TimeTicks::HighResNow();
|
||||
CompletionEvent completion;
|
||||
@ -659,7 +657,7 @@ void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re
|
||||
|
||||
m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings();
|
||||
|
||||
m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::create(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvider(), hasImplThread());
|
||||
m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::create(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvider());
|
||||
ResourceProvider::debugNotifyEnterZone(0x2000000);
|
||||
m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(
|
||||
m_schedulerOnImplThread->anticipatedDrawTime());
|
||||
@ -797,7 +795,7 @@ void ThreadProxy::acquireLayerTextures()
|
||||
return;
|
||||
|
||||
TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures");
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
|
||||
DebugScopedSetMainThreadBlocked mainThreadBlocked;
|
||||
CompletionEvent completion;
|
||||
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread, base::Unretained(this), &completion));
|
||||
completion.wait(); // Block until it is safe to write to layer textures from the main thread.
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef CC_THREAD_PROXY_H_
|
||||
#define CC_THREAD_PROXY_H_
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/time.h"
|
||||
#include "cc/animation_events.h"
|
||||
#include "cc/completion_event.h"
|
||||
@ -25,7 +24,7 @@ class Thread;
|
||||
|
||||
class ThreadProxy : public Proxy, LayerTreeHostImplClient, SchedulerClient, ResourceUpdateControllerClient {
|
||||
public:
|
||||
static scoped_ptr<Proxy> create(LayerTreeHost*, scoped_ptr<Thread> implThread);
|
||||
static scoped_ptr<Proxy> create(LayerTreeHost*);
|
||||
|
||||
virtual ~ThreadProxy();
|
||||
|
||||
@ -78,7 +77,7 @@ public:
|
||||
virtual void readyToFinalizeTextureUpdates() OVERRIDE;
|
||||
|
||||
private:
|
||||
ThreadProxy(LayerTreeHost*, scoped_ptr<Thread> implThread);
|
||||
explicit ThreadProxy(LayerTreeHost*);
|
||||
|
||||
// Set on impl thread, read on main thread.
|
||||
struct BeginFrameAndCommitState {
|
||||
|
@ -46,6 +46,8 @@ static scoped_ptr<TiledLayerImpl> createLayer(const gfx::Size& tileSize, const g
|
||||
|
||||
TEST(TiledLayerImplTest, emptyQuadList)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
const gfx::Size tileSize(90, 90);
|
||||
const int numTilesX = 8;
|
||||
const int numTilesY = 4;
|
||||
@ -99,6 +101,8 @@ TEST(TiledLayerImplTest, emptyQuadList)
|
||||
|
||||
TEST(TiledLayerImplTest, checkerboarding)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
const gfx::Size tileSize(10, 10);
|
||||
const int numTilesX = 2;
|
||||
const int numTilesY = 2;
|
||||
@ -158,6 +162,8 @@ static void getQuads(QuadList& quads, SharedQuadStateList& sharedStates, gfx::Si
|
||||
|
||||
static void coverageVisibleRectOnTileBoundaries(LayerTilingData::BorderTexelOption borders)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
gfx::Size layerSize(1000, 1000);
|
||||
QuadList quads;
|
||||
SharedQuadStateList sharedStates;
|
||||
@ -168,6 +174,8 @@ WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectOnTileBoundaries);
|
||||
|
||||
static void coverageVisibleRectIntersectsTiles(LayerTilingData::BorderTexelOption borders)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
// This rect intersects the middle 3x3 of the 5x5 tiles.
|
||||
gfx::Point topLeft(65, 73);
|
||||
gfx::Point bottomRight(182, 198);
|
||||
@ -183,6 +191,8 @@ WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsTiles);
|
||||
|
||||
static void coverageVisibleRectIntersectsBounds(LayerTilingData::BorderTexelOption borders)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
gfx::Size layerSize(220, 210);
|
||||
gfx::Rect visibleContentRect(gfx::Point(), layerSize);
|
||||
QuadList quads;
|
||||
@ -194,6 +204,8 @@ WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsBounds);
|
||||
|
||||
TEST(TiledLayerImplTest, textureInfoForLayerNoBorders)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
gfx::Size tileSize(50, 50);
|
||||
gfx::Size layerSize(250, 250);
|
||||
QuadList quads;
|
||||
@ -213,6 +225,8 @@ TEST(TiledLayerImplTest, textureInfoForLayerNoBorders)
|
||||
|
||||
TEST(TiledLayerImplTest, tileOpaqueRectForLayerNoBorders)
|
||||
{
|
||||
DebugScopedSetImplThread scopedImplThread;
|
||||
|
||||
gfx::Size tileSize(50, 50);
|
||||
gfx::Size layerSize(250, 250);
|
||||
QuadList quads;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "cc/test/animation_test_common.h"
|
||||
#include "cc/test/fake_graphics_context.h"
|
||||
#include "cc/test/fake_layer_tree_host_client.h"
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "cc/test/geometry_test_utils.h"
|
||||
#include "cc/test/tiled_layer_test_common.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -50,38 +49,34 @@ private:
|
||||
class TiledLayerTest : public testing::Test {
|
||||
public:
|
||||
TiledLayerTest()
|
||||
: m_proxy(NULL)
|
||||
, m_context(WebKit::createFakeGraphicsContext())
|
||||
: m_context(WebKit::createFakeGraphicsContext())
|
||||
, m_queue(make_scoped_ptr(new ResourceUpdateQueue))
|
||||
, m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_occlusion(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL));
|
||||
m_proxy = m_layerTreeHost->proxy();
|
||||
m_textureManager = PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool, m_proxy);
|
||||
m_layerTreeHost->initializeRendererIfNeeded();
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
m_resourceProvider = ResourceProvider::create(m_context.get());
|
||||
}
|
||||
|
||||
virtual ~TiledLayerTest()
|
||||
{
|
||||
textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get());
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
m_resourceProvider.reset();
|
||||
}
|
||||
|
||||
// Helper classes and functions that set the current thread to be the impl thread
|
||||
// before doing the action that they wrap.
|
||||
class ScopedFakeTiledLayerImpl {
|
||||
public:
|
||||
ScopedFakeTiledLayerImpl(int id)
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_layerImpl = new FakeTiledLayerImpl(id);
|
||||
}
|
||||
~ScopedFakeTiledLayerImpl()
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
delete m_layerImpl;
|
||||
}
|
||||
FakeTiledLayerImpl* get()
|
||||
@ -97,32 +92,31 @@ public:
|
||||
};
|
||||
void textureManagerClearAllMemory(PrioritizedTextureManager* textureManager, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider);
|
||||
textureManager->reduceMemory(resourceProvider);
|
||||
}
|
||||
void updateTextures()
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
DCHECK(m_queue);
|
||||
scoped_ptr<ResourceUpdateController> updateController =
|
||||
ResourceUpdateController::create(
|
||||
NULL,
|
||||
m_proxy->implThread(),
|
||||
Proxy::implThread(),
|
||||
m_queue.Pass(),
|
||||
m_resourceProvider.get(),
|
||||
m_proxy->hasImplThread());
|
||||
m_resourceProvider.get());
|
||||
updateController->finalize();
|
||||
m_queue = make_scoped_ptr(new ResourceUpdateQueue);
|
||||
}
|
||||
void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerImpl)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
layer->pushPropertiesTo(layerImpl);
|
||||
}
|
||||
void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded)
|
||||
{
|
||||
DebugScopedSetMainThread mainThread(m_proxy);
|
||||
DebugScopedSetMainThread mainThread;
|
||||
layer->update(*m_queue.get(), occluded, m_stats);
|
||||
}
|
||||
|
||||
@ -162,15 +156,11 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
Proxy* m_proxy;
|
||||
LayerTreeSettings m_settings;
|
||||
scoped_ptr<GraphicsContext> m_context;
|
||||
scoped_ptr<ResourceProvider> m_resourceProvider;
|
||||
scoped_ptr<ResourceUpdateQueue> m_queue;
|
||||
RenderingStats m_stats;
|
||||
PriorityCalculator m_priorityCalculator;
|
||||
FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
|
||||
scoped_ptr<LayerTreeHost> m_layerTreeHost;
|
||||
scoped_ptr<PrioritizedTextureManager> m_textureManager;
|
||||
TestOcclusionTracker* m_occlusion;
|
||||
};
|
||||
@ -522,7 +512,7 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
|
||||
// Create a LayerTreeHost that has the right viewportsize,
|
||||
// so the layer is considered small enough.
|
||||
FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerImplTreeHostClient, LayerTreeSettings(), scoped_ptr<Thread>(NULL));
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerImplTreeHostClient, LayerTreeSettings());
|
||||
|
||||
bool runOutOfMemory[2] = {false, true};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@ -788,6 +778,10 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
|
||||
|
||||
TEST_F(TiledLayerTest, skipsDrawGetsReset)
|
||||
{
|
||||
FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerImplTreeHostClient, LayerTreeSettings());
|
||||
ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
|
||||
|
||||
// Create two 300 x 300 tiled layers.
|
||||
gfx::Size contentBounds(300, 300);
|
||||
gfx::Rect contentRect(gfx::Point(), contentBounds);
|
||||
@ -795,8 +789,8 @@ TEST_F(TiledLayerTest, skipsDrawGetsReset)
|
||||
// We have enough memory for only one of the two layers.
|
||||
int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
|
||||
|
||||
scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
rootLayer->addChild(childLayer);
|
||||
|
||||
rootLayer->setBounds(contentBounds);
|
||||
@ -808,25 +802,25 @@ TEST_F(TiledLayerTest, skipsDrawGetsReset)
|
||||
rootLayer->invalidateContentRect(contentRect);
|
||||
childLayer->invalidateContentRect(contentRect);
|
||||
|
||||
m_layerTreeHost->setRootLayer(rootLayer);
|
||||
m_layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300));
|
||||
layerTreeHost->setRootLayer(rootLayer);
|
||||
layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300));
|
||||
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
|
||||
layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
|
||||
|
||||
// We'll skip the root layer.
|
||||
EXPECT_TRUE(rootLayer->skipsDraw());
|
||||
EXPECT_FALSE(childLayer->skipsDraw());
|
||||
|
||||
m_layerTreeHost->commitComplete();
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Remove the child layer.
|
||||
rootLayer->removeAllChildren();
|
||||
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
|
||||
layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
|
||||
EXPECT_FALSE(rootLayer->skipsDraw());
|
||||
|
||||
textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
m_layerTreeHost->setRootLayer(0);
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, resizeToSmaller)
|
||||
@ -860,6 +854,115 @@ TEST_F(TiledLayerTest, hugeLayerUpdateCrash)
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, partialUpdates)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
settings.maxPartialTextureUpdates = 4;
|
||||
|
||||
FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerImplTreeHostClient, settings);
|
||||
ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
|
||||
|
||||
// Create one 300 x 200 tiled layer with 3 x 2 tiles.
|
||||
gfx::Size contentBounds(300, 200);
|
||||
gfx::Rect contentRect(gfx::Point(), contentBounds);
|
||||
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
layer->setBounds(contentBounds);
|
||||
layer->setPosition(gfx::PointF(0, 0));
|
||||
layer->setVisibleContentRect(contentRect);
|
||||
layer->invalidateContentRect(contentRect);
|
||||
|
||||
layerTreeHost->setRootLayer(layer);
|
||||
layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200));
|
||||
|
||||
// Full update of all 6 tiles.
|
||||
layerTreeHost->updateLayers(
|
||||
*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
EXPECT_EQ(6, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(0, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Full update of 3 tiles and partial update of 3 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
|
||||
layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
EXPECT_EQ(3, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(3, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 6 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(2, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(4, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Checkerboard all tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 6 checkerboard tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(6, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(0, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 4 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(0, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(4, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
@ -1278,10 +1381,15 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
gfx::Rect childRect(0, 0, 300, 100);
|
||||
gfx::Rect child2Rect(0, 100, 300, 100);
|
||||
|
||||
scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
LayerTreeSettings settings;
|
||||
FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
|
||||
scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerImplTreeHostClient, settings);
|
||||
ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
|
||||
|
||||
scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<Layer> surface = Layer::create();
|
||||
scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer(layerTreeHost->contentsTextureManager()));
|
||||
|
||||
root->setBounds(rootRect.size());
|
||||
root->setAnchorPoint(gfx::PointF());
|
||||
@ -1307,14 +1415,14 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
child2->setVisibleContentRect(child2Rect);
|
||||
child2->setDrawableContentRect(rootRect);
|
||||
|
||||
m_layerTreeHost->setRootLayer(root);
|
||||
m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
|
||||
layerTreeHost->setRootLayer(root);
|
||||
layerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
|
||||
|
||||
// With a huge memory limit, all layers should update and push their textures.
|
||||
root->invalidateContentRect(rootRect);
|
||||
child->invalidateContentRect(childRect);
|
||||
child2->invalidateContentRect(child2Rect);
|
||||
m_layerTreeHost->updateLayers(
|
||||
layerTreeHost->updateLayers(
|
||||
*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
{
|
||||
updateTextures();
|
||||
@ -1341,7 +1449,7 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
|
||||
}
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// With a memory limit that includes only the root layer (3x2 tiles) and half the surface that
|
||||
// the child layers draw into, the child layers will not be allocated. If the surface isn't
|
||||
@ -1349,7 +1457,7 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
root->invalidateContentRect(rootRect);
|
||||
child->invalidateContentRect(childRect);
|
||||
child2->invalidateContentRect(child2Rect);
|
||||
m_layerTreeHost->updateLayers(
|
||||
layerTreeHost->updateLayers(
|
||||
*m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4);
|
||||
{
|
||||
updateTextures();
|
||||
@ -1376,7 +1484,7 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
|
||||
}
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
// With a memory limit that includes only half the root layer, no contents will be
|
||||
// allocated. If render surface memory wasn't accounted for, there is enough space
|
||||
@ -1385,7 +1493,7 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
root->invalidateContentRect(rootRect);
|
||||
child->invalidateContentRect(childRect);
|
||||
child2->invalidateContentRect(child2Rect);
|
||||
m_layerTreeHost->updateLayers(
|
||||
layerTreeHost->updateLayers(
|
||||
*m_queue.get(), (3 * 1) * (100 * 100) * 4);
|
||||
{
|
||||
updateTextures();
|
||||
@ -1412,10 +1520,10 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
|
||||
}
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
m_layerTreeHost->setRootLayer(0);
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
class TrackingLayerPainter : public LayerPainter {
|
||||
@ -1519,114 +1627,4 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
|
||||
EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
|
||||
}
|
||||
|
||||
class TiledLayerPartialUpdateTest : public TiledLayerTest {
|
||||
public:
|
||||
TiledLayerPartialUpdateTest()
|
||||
{
|
||||
m_settings.maxPartialTextureUpdates = 4;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
|
||||
{
|
||||
// Create one 300 x 200 tiled layer with 3 x 2 tiles.
|
||||
gfx::Size contentBounds(300, 200);
|
||||
gfx::Rect contentRect(gfx::Point(), contentBounds);
|
||||
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_layerTreeHost->contentsTextureManager()));
|
||||
layer->setBounds(contentBounds);
|
||||
layer->setPosition(gfx::PointF(0, 0));
|
||||
layer->setVisibleContentRect(contentRect);
|
||||
layer->invalidateContentRect(contentRect);
|
||||
|
||||
m_layerTreeHost->setRootLayer(layer);
|
||||
m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200));
|
||||
|
||||
// Full update of all 6 tiles.
|
||||
m_layerTreeHost->updateLayers(
|
||||
*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
EXPECT_EQ(6, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(0, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
// Full update of 3 tiles and partial update of 3 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
EXPECT_EQ(3, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(3, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 6 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(2, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(4, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
// Checkerboard all tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 6 checkerboard tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(6, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(0, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
// Partial update of 4 tiles.
|
||||
layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
|
||||
{
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
|
||||
EXPECT_EQ(0, m_queue->fullUploadSize());
|
||||
EXPECT_EQ(4, m_queue->partialUploadSize());
|
||||
updateTextures();
|
||||
EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
|
||||
EXPECT_FALSE(m_queue->hasMoreUpdates());
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
}
|
||||
m_layerTreeHost->commitComplete();
|
||||
|
||||
textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
m_layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/single_thread_proxy.h"
|
||||
#include "cc/test/animation_test_common.h"
|
||||
#include "cc/test/fake_proxy.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using namespace cc;
|
||||
@ -132,6 +131,8 @@ void expectTreesAreIdentical(Layer* layer, LayerImpl* layerImpl, LayerTreeHostIm
|
||||
// return a null tree.
|
||||
TEST(TreeSynchronizerTest, syncNullTree)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(0, scoped_ptr<LayerImpl>(), 0);
|
||||
|
||||
EXPECT_TRUE(!layerImplTreeRoot.get());
|
||||
@ -140,10 +141,10 @@ TEST(TreeSynchronizerTest, syncNullTree)
|
||||
// Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers.
|
||||
TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> layerTreeRoot = Layer::create();
|
||||
layerTreeRoot->addChild(Layer::create());
|
||||
@ -157,12 +158,11 @@ TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
|
||||
// Constructs a very simple tree and synchronizes it attempting to reuse some layers
|
||||
TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
std::vector<int> layerImplDestructionList;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestructionList);
|
||||
layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
|
||||
@ -188,12 +188,11 @@ TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers)
|
||||
// Constructs a very simple tree and checks that a stacking-order change is tracked properly.
|
||||
TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
std::vector<int> layerImplDestructionList;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
// Set up the tree and sync once. child2 needs to be synced here, too, even though we
|
||||
// remove it to set up the intended scenario.
|
||||
@ -219,10 +218,10 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange)
|
||||
|
||||
TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> layerTreeRoot = Layer::create();
|
||||
layerTreeRoot->addChild(Layer::create());
|
||||
@ -255,12 +254,11 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties)
|
||||
|
||||
TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
std::vector<int> layerImplDestructionList;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
// Set up a tree with this sort of structure:
|
||||
// root --- A --- B ---+--- C
|
||||
@ -306,12 +304,11 @@ TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange)
|
||||
// Constructs a very simple tree, synchronizes it, then synchronizes to a totally new tree. All layers from the old tree should be deleted.
|
||||
TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
std::vector<int> layerImplDestructionList;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestructionList);
|
||||
oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
|
||||
@ -342,10 +339,10 @@ TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy)
|
||||
// Constructs+syncs a tree with mask, replica, and replica mask layers.
|
||||
TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> layerTreeRoot = Layer::create();
|
||||
layerTreeRoot->addChild(Layer::create());
|
||||
@ -388,10 +385,10 @@ TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers)
|
||||
|
||||
TEST(TreeSynchronizerTest, synchronizeAnimations)
|
||||
{
|
||||
DebugScopedSetImplThread impl;
|
||||
|
||||
LayerTreeSettings settings;
|
||||
FakeProxy proxy(scoped_ptr<Thread>(NULL));
|
||||
DebugScopedSetImplThread impl(&proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
|
||||
scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0);
|
||||
|
||||
scoped_refptr<Layer> layerTreeRoot = Layer::create();
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "cc/io_surface_draw_quad.h"
|
||||
#include "cc/layer_tree_host_impl.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/quad_sink.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/stream_video_draw_quad.h"
|
||||
@ -42,12 +43,14 @@ VideoLayerImpl::VideoLayerImpl(int id, WebKit::WebVideoFrameProvider* provider,
|
||||
// thread is blocked. That makes this a thread-safe call to set the video
|
||||
// frame provider client that does not require a lock. The same is true of
|
||||
// the call in the destructor.
|
||||
DCHECK(Proxy::isMainThreadBlocked());
|
||||
m_provider->setVideoFrameProviderClient(this);
|
||||
}
|
||||
|
||||
VideoLayerImpl::~VideoLayerImpl()
|
||||
{
|
||||
// See comment in constructor for why this doesn't need a lock.
|
||||
DCHECK(Proxy::isMainThreadBlocked());
|
||||
if (m_provider) {
|
||||
m_provider->setVideoFrameProviderClient(0);
|
||||
m_provider = 0;
|
||||
@ -116,6 +119,7 @@ size_t VideoLayerImpl::numPlanes() const
|
||||
|
||||
void VideoLayerImpl::willDraw(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
LayerImpl::willDraw(resourceProvider);
|
||||
|
||||
// Explicitly acquire and release the provider mutex so it can be held from
|
||||
@ -136,6 +140,7 @@ void VideoLayerImpl::willDraw(ResourceProvider* resourceProvider)
|
||||
|
||||
void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(!m_externalTextureResource);
|
||||
|
||||
if (!m_provider) {
|
||||
@ -186,6 +191,8 @@ void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider)
|
||||
|
||||
void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
if (!m_frame)
|
||||
return;
|
||||
|
||||
@ -246,6 +253,7 @@ void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
|
||||
|
||||
void VideoLayerImpl::didDraw(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
LayerImpl::didDraw(resourceProvider);
|
||||
|
||||
if (!m_frame)
|
||||
|
@ -9,6 +9,8 @@
|
||||
'web_animation_curve_common.h',
|
||||
'web_animation_impl.cc',
|
||||
'web_animation_impl.h',
|
||||
'web_compositor_impl.cc',
|
||||
'web_compositor_impl.h',
|
||||
'web_content_layer_impl.cc',
|
||||
'web_content_layer_impl.h',
|
||||
'web_delegated_renderer_layer_impl.cc',
|
||||
|
@ -12,7 +12,10 @@ int main(int argc, char** argv) {
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
TestSuite testSuite(argc, argv);
|
||||
MessageLoop message_loop;
|
||||
scoped_ptr<cc::Thread> mainCCThread = cc::ThreadImpl::createForCurrentThread();
|
||||
cc::Proxy::setMainThread(mainCCThread.get());
|
||||
int result = testSuite.Run();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
85
webkit/compositor_bindings/web_compositor_impl.cc
Normal file
85
webkit/compositor_bindings/web_compositor_impl.cc
Normal file
@ -0,0 +1,85 @@
|
||||
// Copyright 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "web_compositor_impl.h"
|
||||
|
||||
#ifdef LOG
|
||||
#undef LOG
|
||||
#endif
|
||||
#include "base/message_loop_proxy.h"
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/thread_impl.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
|
||||
#include "webkit/glue/webthread_impl.h"
|
||||
|
||||
using namespace cc;
|
||||
|
||||
namespace WebKit {
|
||||
|
||||
bool WebCompositorImpl::s_initialized = false;
|
||||
Thread* WebCompositorImpl::s_mainThread = 0;
|
||||
Thread* WebCompositorImpl::s_implThread = 0;
|
||||
|
||||
void WebCompositor::initialize(WebThread* implThread)
|
||||
{
|
||||
WebCompositorImpl::initialize(implThread);
|
||||
}
|
||||
|
||||
bool WebCompositor::isThreadingEnabled()
|
||||
{
|
||||
return WebCompositorImpl::isThreadingEnabled();
|
||||
}
|
||||
|
||||
void WebCompositor::shutdown()
|
||||
{
|
||||
WebCompositorImpl::shutdown();
|
||||
}
|
||||
|
||||
void WebCompositorImpl::initialize(WebThread* implThread)
|
||||
{
|
||||
ASSERT(!s_initialized);
|
||||
s_initialized = true;
|
||||
|
||||
s_mainThread = cc::ThreadImpl::createForCurrentThread().release();
|
||||
Proxy::setMainThread(s_mainThread);
|
||||
if (implThread) {
|
||||
webkit_glue::WebThreadImpl* webThreadImpl = static_cast<webkit_glue::WebThreadImpl*>(implThread);
|
||||
MessageLoop* implMessageLoop = webThreadImpl->message_loop();
|
||||
s_implThread = cc::ThreadImpl::createForDifferentThread(implMessageLoop->message_loop_proxy()).release();
|
||||
Proxy::setImplThread(s_implThread);
|
||||
} else
|
||||
Proxy::setImplThread(0);
|
||||
}
|
||||
|
||||
bool WebCompositorImpl::isThreadingEnabled()
|
||||
{
|
||||
return s_implThread;
|
||||
}
|
||||
|
||||
bool WebCompositorImpl::initialized()
|
||||
{
|
||||
return s_initialized;
|
||||
}
|
||||
|
||||
void WebCompositorImpl::shutdown()
|
||||
{
|
||||
ASSERT(s_initialized);
|
||||
ASSERT(!LayerTreeHost::anyLayerTreeHostInstanceExists());
|
||||
|
||||
if (s_implThread) {
|
||||
delete s_implThread;
|
||||
s_implThread = 0;
|
||||
}
|
||||
delete s_mainThread;
|
||||
s_mainThread = 0;
|
||||
Proxy::setImplThread(0);
|
||||
Proxy::setMainThread(0);
|
||||
s_initialized = false;
|
||||
}
|
||||
|
||||
}
|
34
webkit/compositor_bindings/web_compositor_impl.h
Normal file
34
webkit/compositor_bindings/web_compositor_impl.h
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef WebCompositorImpl_h
|
||||
#define WebCompositorImpl_h
|
||||
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h"
|
||||
|
||||
namespace cc {
|
||||
class Thread;
|
||||
}
|
||||
|
||||
namespace WebKit {
|
||||
|
||||
class WebThread;
|
||||
|
||||
class WebCompositorImpl : public WebCompositor {
|
||||
public:
|
||||
static bool initialized();
|
||||
|
||||
static void initialize(WebThread* implThread);
|
||||
static bool isThreadingEnabled();
|
||||
static void shutdown();
|
||||
|
||||
private:
|
||||
static bool s_initialized;
|
||||
static cc::Thread* s_mainThread;
|
||||
static cc::Thread* s_implThread;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WebCompositorImpl_h
|
@ -7,10 +7,9 @@
|
||||
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/message_loop_proxy.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/thread_impl.h"
|
||||
#include "webkit/compositor_bindings/web_animation_impl.h"
|
||||
#include "webkit/compositor_bindings/web_compositor_impl.h"
|
||||
#include "webkit/compositor_bindings/web_content_layer_impl.h"
|
||||
#include "webkit/compositor_bindings/web_delegated_renderer_layer_impl.h"
|
||||
#include "webkit/compositor_bindings/web_external_texture_layer_impl.h"
|
||||
@ -23,7 +22,6 @@
|
||||
#include "webkit/compositor_bindings/web_solid_color_layer_impl.h"
|
||||
#include "webkit/compositor_bindings/web_transform_animation_curve_impl.h"
|
||||
#include "webkit/compositor_bindings/web_video_layer_impl.h"
|
||||
#include "webkit/glue/webthread_impl.h"
|
||||
|
||||
using WebKit::WebAnimation;
|
||||
using WebKit::WebAnimationCurve;
|
||||
@ -48,6 +46,8 @@ using WebKit::WebTransformAnimationCurve;
|
||||
using WebKit::WebVideoFrameProvider;
|
||||
using WebKit::WebVideoLayer;
|
||||
|
||||
using WebKit::WebCompositorImpl;
|
||||
|
||||
namespace webkit {
|
||||
|
||||
WebCompositorSupportImpl::WebCompositorSupportImpl() {
|
||||
@ -56,22 +56,19 @@ WebCompositorSupportImpl::WebCompositorSupportImpl() {
|
||||
WebCompositorSupportImpl::~WebCompositorSupportImpl() {
|
||||
}
|
||||
|
||||
void WebCompositorSupportImpl::initialize(WebKit::WebThread* impl_thread) {
|
||||
if (impl_thread) {
|
||||
void WebCompositorSupportImpl::initialize(WebKit::WebThread* thread) {
|
||||
if (thread) {
|
||||
TRACE_EVENT_INSTANT0("test_gpu", "ThreadedCompositingInitialization");
|
||||
}
|
||||
if (impl_thread)
|
||||
impl_thread_message_loop_proxy_ =
|
||||
static_cast<webkit_glue::WebThreadImpl*>(impl_thread)->
|
||||
message_loop()->message_loop_proxy();
|
||||
WebCompositorImpl::initialize(thread);
|
||||
}
|
||||
|
||||
bool WebCompositorSupportImpl::isThreadingEnabled() {
|
||||
return impl_thread_message_loop_proxy_;
|
||||
return WebCompositorImpl::isThreadingEnabled();
|
||||
}
|
||||
|
||||
void WebCompositorSupportImpl::shutdown() {
|
||||
impl_thread_message_loop_proxy_ = NULL;
|
||||
WebCompositorImpl::shutdown();
|
||||
}
|
||||
|
||||
void WebCompositorSupportImpl::setPerTilePaintingEnabled(bool enabled) {
|
||||
@ -95,11 +92,7 @@ WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
|
||||
const WebLayerTreeView::Settings& settings) {
|
||||
scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl(
|
||||
new WebKit::WebLayerTreeViewImpl(client));
|
||||
scoped_ptr<cc::Thread> impl_thread(NULL);
|
||||
if (impl_thread_message_loop_proxy_)
|
||||
impl_thread = cc::ThreadImpl::createForDifferentThread(
|
||||
impl_thread_message_loop_proxy_);
|
||||
if (!layerTreeViewImpl->initialize(settings, impl_thread.Pass()))
|
||||
if (!layerTreeViewImpl->initialize(settings))
|
||||
return NULL;
|
||||
layerTreeViewImpl->setRootLayer(root);
|
||||
return layerTreeViewImpl.release();
|
||||
|
@ -5,14 +5,9 @@
|
||||
#ifndef WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
|
||||
#define WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSupport.h"
|
||||
|
||||
namespace base {
|
||||
class MessageLoopProxy;
|
||||
}
|
||||
|
||||
namespace webkit {
|
||||
|
||||
class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
|
||||
@ -20,7 +15,7 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
|
||||
WebCompositorSupportImpl();
|
||||
virtual ~WebCompositorSupportImpl();
|
||||
|
||||
virtual void initialize(WebKit::WebThread* implThread);
|
||||
virtual void initialize(WebKit::WebThread* thread);
|
||||
virtual bool isThreadingEnabled();
|
||||
virtual void shutdown();
|
||||
virtual void setPerTilePaintingEnabled(bool enabled);
|
||||
@ -55,9 +50,6 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
|
||||
createFloatAnimationCurve();
|
||||
virtual WebKit::WebTransformAnimationCurve*
|
||||
createTransformAnimationCurve();
|
||||
|
||||
private:
|
||||
scoped_refptr<base::MessageLoopProxy> impl_thread_message_loop_proxy_;
|
||||
};
|
||||
|
||||
} // namespace webkit
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "cc/input_handler.h"
|
||||
#include "cc/layer.h"
|
||||
#include "cc/layer_tree_host.h"
|
||||
#include "cc/thread.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
|
||||
@ -28,7 +27,7 @@ namespace WebKit {
|
||||
WebLayerTreeView* WebLayerTreeView::create(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings)
|
||||
{
|
||||
scoped_ptr<WebLayerTreeViewImpl> layerTreeViewImpl(new WebLayerTreeViewImpl(client));
|
||||
if (!layerTreeViewImpl->initialize(settings, scoped_ptr<Thread>(NULL)))
|
||||
if (!layerTreeViewImpl->initialize(settings))
|
||||
return 0;
|
||||
layerTreeViewImpl->setRootLayer(root);
|
||||
return layerTreeViewImpl.release();
|
||||
@ -36,7 +35,6 @@ WebLayerTreeView* WebLayerTreeView::create(WebLayerTreeViewClient* client, const
|
||||
|
||||
WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client)
|
||||
: m_client(client)
|
||||
, m_hasImplThread(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -44,7 +42,7 @@ WebLayerTreeViewImpl::~WebLayerTreeViewImpl()
|
||||
{
|
||||
}
|
||||
|
||||
bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSettings, scoped_ptr<Thread> implThread)
|
||||
bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSettings)
|
||||
{
|
||||
LayerTreeSettings settings;
|
||||
settings.acceleratePainting = webSettings.acceleratePainting;
|
||||
@ -55,9 +53,7 @@ bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti
|
||||
settings.refreshRate = webSettings.refreshRate;
|
||||
settings.defaultTileSize = webSettings.defaultTileSize;
|
||||
settings.maxUntiledLayerSize = webSettings.maxUntiledLayerSize;
|
||||
m_layerTreeHost = LayerTreeHost::create(this, settings, implThread.Pass());
|
||||
if (implThread)
|
||||
m_hasImplThread = true;
|
||||
m_layerTreeHost = LayerTreeHost::create(this, settings);
|
||||
if (!m_layerTreeHost.get())
|
||||
return false;
|
||||
return true;
|
||||
@ -154,7 +150,7 @@ bool WebLayerTreeViewImpl::commitRequested() const
|
||||
|
||||
void WebLayerTreeViewImpl::composite()
|
||||
{
|
||||
if (m_hasImplThread)
|
||||
if (Proxy::hasImplThread())
|
||||
m_layerTreeHost->setNeedsCommit();
|
||||
else
|
||||
m_layerTreeHost->composite();
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace cc {
|
||||
class LayerTreeHost;
|
||||
class Thread;
|
||||
}
|
||||
|
||||
namespace WebKit {
|
||||
@ -24,7 +23,7 @@ public:
|
||||
explicit WebLayerTreeViewImpl(WebLayerTreeViewClient*);
|
||||
virtual ~WebLayerTreeViewImpl();
|
||||
|
||||
bool initialize(const Settings&, scoped_ptr<cc::Thread> implThread);
|
||||
bool initialize(const Settings&);
|
||||
|
||||
// WebLayerTreeView implementation.
|
||||
virtual void setSurfaceReady() OVERRIDE;
|
||||
@ -72,7 +71,6 @@ public:
|
||||
private:
|
||||
WebLayerTreeViewClient* m_client;
|
||||
scoped_ptr<cc::LayerTreeHost> m_layerTreeHost;
|
||||
bool m_hasImplThread;
|
||||
};
|
||||
|
||||
} // namespace WebKit
|
||||
|
@ -46,12 +46,7 @@ public:
|
||||
initializeCompositor();
|
||||
m_rootLayer.reset(new WebLayerImpl);
|
||||
m_view.reset(new WebLayerTreeViewImpl(client()));
|
||||
scoped_ptr<cc::Thread> implCCThread(NULL);
|
||||
if (m_implThread)
|
||||
implCCThread = cc::ThreadImpl::createForDifferentThread(
|
||||
m_implThread->message_loop_proxy());
|
||||
ASSERT_TRUE(m_view->initialize(WebLayerTreeView::Settings(),
|
||||
implCCThread.Pass()));
|
||||
ASSERT_TRUE(m_view->initialize(WebLayerTreeView::Settings()));
|
||||
m_view->setRootLayer(*m_rootLayer);
|
||||
m_view->setSurfaceReady();
|
||||
}
|
||||
@ -67,7 +62,6 @@ public:
|
||||
protected:
|
||||
scoped_ptr<WebLayer> m_rootLayer;
|
||||
scoped_ptr<WebLayerTreeViewImpl> m_view;
|
||||
scoped_ptr<base::Thread> m_implThread;
|
||||
};
|
||||
|
||||
class WebLayerTreeViewSingleThreadTest : public WebLayerTreeViewTestBase {
|
||||
@ -93,6 +87,7 @@ class WebLayerTreeViewThreadedTest : public WebLayerTreeViewTestBase {
|
||||
protected:
|
||||
virtual ~WebLayerTreeViewThreadedTest()
|
||||
{
|
||||
cc::Proxy::setImplThread(0);
|
||||
}
|
||||
|
||||
void composite()
|
||||
@ -110,6 +105,8 @@ protected:
|
||||
{
|
||||
m_implThread.reset(new base::Thread("ThreadedTest"));
|
||||
ASSERT_TRUE(m_implThread->Start());
|
||||
m_implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->message_loop_proxy());
|
||||
cc::Proxy::setImplThread(m_implCCThread.get());
|
||||
}
|
||||
|
||||
virtual WebLayerTreeViewClient* client() OVERRIDE
|
||||
@ -118,6 +115,8 @@ protected:
|
||||
}
|
||||
|
||||
MockWebLayerTreeViewClientForThreadedTests m_client;
|
||||
scoped_ptr<base::Thread> m_implThread;
|
||||
scoped_ptr<cc::Thread> m_implCCThread;
|
||||
base::CancelableClosure m_timeout;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user