summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 21:21:59 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 21:21:59 +0000
commit5bc29a2dabe01f1e2315bcc287f11db10df4144b (patch)
tree0c451bebe2c40e867a935b5f52b25a242f5f825c /cc
parent4d8bb1a91681f8e48cc5e6b7ac29f3723eadf0d5 (diff)
downloadchromium_src-5bc29a2dabe01f1e2315bcc287f11db10df4144b.zip
chromium_src-5bc29a2dabe01f1e2315bcc287f11db10df4144b.tar.gz
chromium_src-5bc29a2dabe01f1e2315bcc287f11db10df4144b.tar.bz2
Revert 165476 - Remove static thread pointers from CC
Might be causing webkit_unit_tests to fail on mac/win BUG=152904 Review URL: https://codereview.chromium.org/11232051 TBR=jamesr@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/cc_tests.gyp2
-rw-r--r--cc/damage_tracker_unittest.cc3
-rw-r--r--cc/delegated_renderer_layer_impl_unittest.cc10
-rw-r--r--cc/font_atlas.cc6
-rw-r--r--cc/font_atlas.h3
-rw-r--r--cc/frame_rate_counter.cc14
-rw-r--r--cc/frame_rate_counter.h6
-rw-r--r--cc/gl_renderer.cc77
-rw-r--r--cc/gl_renderer.h1
-rw-r--r--cc/gl_renderer_unittest.cc6
-rw-r--r--cc/layer_impl.cc2
-rw-r--r--cc/layer_impl_unittest.cc2
-rw-r--r--cc/layer_sorter_unittest.cc2
-rw-r--r--cc/layer_tree_host.cc43
-rw-r--r--cc/layer_tree_host.h8
-rw-r--r--cc/layer_tree_host_common_unittest.cc44
-rw-r--r--cc/layer_tree_host_impl.cc27
-rw-r--r--cc/layer_tree_host_impl.h7
-rw-r--r--cc/layer_tree_host_impl_unittest.cc54
-rw-r--r--cc/layer_tree_host_unittest.cc2
-rw-r--r--cc/layer_unittest.cc7
-rw-r--r--cc/occlusion_tracker_unittest.cc2
-rw-r--r--cc/prioritized_texture.cc17
-rw-r--r--cc/prioritized_texture.h4
-rw-r--r--cc/prioritized_texture_manager.cc54
-rw-r--r--cc/prioritized_texture_manager.h12
-rw-r--r--cc/prioritized_texture_unittest.cc65
-rw-r--r--cc/proxy.cc73
-rw-r--r--cc/proxy.h56
-rw-r--r--cc/quad_culler_unittest.cc1
-rw-r--r--cc/rate_limiter.cc12
-rw-r--r--cc/rate_limiter.h7
-rw-r--r--cc/render_surface_unittest.cc9
-rw-r--r--cc/renderer.h1
-rw-r--r--cc/resource_provider.cc47
-rw-r--r--cc/resource_provider.h7
-rw-r--r--cc/resource_provider_unittest.cc3
-rw-r--r--cc/resource_update_controller.cc8
-rw-r--r--cc/resource_update_controller.h7
-rw-r--r--cc/resource_update_controller_unittest.cc25
-rw-r--r--cc/scoped_texture_unittest.cc5
-rw-r--r--cc/scrollbar_animation_controller_linear_fade_unittest.cc2
-rw-r--r--cc/scrollbar_layer_unittest.cc4
-rw-r--r--cc/single_thread_proxy.cc35
-rw-r--r--cc/single_thread_proxy.h28
-rw-r--r--cc/software_renderer.cc2
-rw-r--r--cc/software_renderer_unittest.cc4
-rw-r--r--cc/solid_color_layer_impl_unittest.cc6
-rw-r--r--cc/test/fake_proxy.cc52
-rw-r--r--cc/test/fake_proxy.h50
-rw-r--r--cc/test/layer_tree_test_common.cc52
-rw-r--r--cc/test/layer_tree_test_common.h8
-rw-r--r--cc/test/run_all_unittests.cc5
-rw-r--r--cc/texture_layer_unittest.cc13
-rw-r--r--cc/thread_proxy.cc36
-rw-r--r--cc/thread_proxy.h5
-rw-r--r--cc/tiled_layer_impl_unittest.cc14
-rw-r--r--cc/tiled_layer_unittest.cc312
-rw-r--r--cc/tree_synchronizer_unittest.cc47
-rw-r--r--cc/video_layer_impl.cc8
60 files changed, 691 insertions, 733 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 255c699..963f841 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -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',
diff --git a/cc/damage_tracker_unittest.cc b/cc/damage_tracker_unittest.cc
index a2d5a44..22280e4 100644
--- a/cc/damage_tracker_unittest.cc
+++ b/cc/damage_tracker_unittest.cc
@@ -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)
diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc
index 772f292..23df876 100644
--- a/cc/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/delegated_renderer_layer_impl_unittest.cc
@@ -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;
};
diff --git a/cc/font_atlas.cc b/cc/font_atlas.cc
index 2f18e02..2d15766 100644
--- a/cc/font_atlas.cc
+++ b/cc/font_atlas.cc
@@ -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()));
diff --git a/cc/font_atlas.h b/cc/font_atlas.h
index f5878a7..0a227a6 100644
--- a/cc/font_atlas.h
+++ b/cc/font_atlas.h
@@ -9,7 +9,6 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread_checker.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/rect.h"
@@ -55,8 +54,6 @@ private:
int m_fontHeight;
- base::ThreadChecker m_threadChecker;
-
DISALLOW_COPY_AND_ASSIGN(FontAtlas);
};
diff --git a/cc/frame_rate_counter.cc b/cc/frame_rate_counter.cc
index 877930f..46b51f4 100644
--- a/cc/frame_rate_counter.cc
+++ b/cc/frame_rate_counter.cc
@@ -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
+
diff --git a/cc/frame_rate_counter.h b/cc/frame_rate_counter.h
index bc1765b..008c2f3 100644
--- a/cc/frame_rate_counter.h
+++ b/cc/frame_rate_counter.h
@@ -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];
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index 4faa422..6b78e04 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -112,7 +112,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);
@@ -145,6 +145,7 @@ bool GLRenderer::initialize()
GLRenderer::~GLRenderer()
{
+ DCHECK(Proxy::isImplThread());
m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
m_context->setContextLostCallback(0);
@@ -342,29 +343,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();
@@ -376,13 +377,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();
@@ -468,7 +469,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>();
@@ -523,9 +524,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;
@@ -953,6 +954,8 @@ struct TexTransformTextureProgramBinding : TextureProgramBinding {
void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQuad* quad)
{
+ DCHECK(Proxy::isImplThread());
+
TexTransformTextureProgramBinding binding;
if (quad->flipped())
binding.set(textureProgramFlip());
@@ -995,6 +998,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());
@@ -1136,6 +1140,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
// is not visible (which the renderer knows better).
@@ -1159,22 +1192,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) {
diff --git a/cc/gl_renderer.h b/cc/gl_renderer.h
index 4fff3a1..cb03c06 100644
--- a/cc/gl_renderer.h
+++ b/cc/gl_renderer.h
@@ -116,6 +116,7 @@ private:
// WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation) OVERRIDE;
+ void onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation);
void discardFramebuffer();
void ensureFramebuffer();
void enforceMemoryPolicy();
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc
index b2f8fa5..5979a38 100644
--- a/cc/gl_renderer_unittest.cc
+++ b/cc/gl_renderer_unittest.cc
@@ -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;
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index f1555c1..fadcf04 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -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
diff --git a/cc/layer_impl_unittest.cc b/cc/layer_impl_unittest.cc
index 259a6ed..3640185 100644
--- a/cc/layer_impl_unittest.cc
+++ b/cc/layer_impl_unittest.cc
@@ -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));
diff --git a/cc/layer_sorter_unittest.cc b/cc/layer_sorter_unittest.cc
index 7bc70a8..941bd72 100644
--- a/cc/layer_sorter_unittest.cc
+++ b/cc/layer_sorter_unittest.cc
@@ -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
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index 50d0433..e4341a4 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -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();
}
diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h
index a660e27..7879d1a 100644
--- a/cc/layer_tree_host.h
+++ b/cc/layer_tree_host.h
@@ -93,7 +93,7 @@ struct RendererCapabilities {
class 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;
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index b39ea1f..d25bb58 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -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;
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 9c60568..4b1d2c6 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -200,14 +200,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)
@@ -226,18 +225,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)
@@ -505,7 +504,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);
}
@@ -650,20 +649,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
@@ -830,7 +819,7 @@ scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree()
void LayerTreeHostImpl::setVisible(bool visible)
{
- DCHECK(m_proxy->isImplThread());
+ DCHECK(Proxy::isImplThread());
if (m_visible == visible)
return;
diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h
index 7e4d57b..783d042 100644
--- a/cc/layer_tree_host_impl.h
+++ b/cc/layer_tree_host_impl.h
@@ -105,7 +105,7 @@ class 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
@@ -154,7 +154,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;
@@ -232,7 +231,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 CullRenderPassesWithCachedTextures {
public:
@@ -265,7 +263,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);
@@ -280,7 +278,6 @@ protected:
virtual base::TimeDelta lowFrequencyAnimationInterval() const;
LayerTreeHostImplClient* m_client;
- Proxy* m_proxy;
int m_sourceFrameNumber;
private:
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 22fbfee..fc4d1dd 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -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) {
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 00d8d70..166c4070 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -2863,7 +2863,7 @@ public:
implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfterEvictTextures::evictTexturesOnImplThread,
base::Unretained(this)));
} else {
- DebugScopedSetImplThread impl(proxy());
+ DebugScopedSetImplThread impl;
evictTexturesOnImplThread();
}
}
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 8407eb1..f1a64e8 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -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();
}
diff --git a/cc/occlusion_tracker_unittest.cc b/cc/occlusion_tracker_unittest.cc
index 71dee9c..e59c0ab 100644
--- a/cc/occlusion_tracker_unittest.cc
+++ b/cc/occlusion_tracker_unittest.cc
@@ -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) { } \
}; \
diff --git a/cc/prioritized_texture.cc b/cc/prioritized_texture.cc
index e2fee50..1c4428a 100644
--- a/cc/prioritized_texture.cc
+++ b/cc/prioritized_texture.cc
@@ -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
diff --git a/cc/prioritized_texture.h b/cc/prioritized_texture.h
index 51921c8..fed3470 100644
--- a/cc/prioritized_texture.h
+++ b/cc/prioritized_texture.h
@@ -19,7 +19,6 @@
namespace cc {
class PrioritizedTextureManager;
-class Proxy;
class PrioritizedTexture {
public:
@@ -108,8 +107,6 @@ private:
bool resourceHasBeenDeleted() const;
private:
- const Proxy* proxy() const;
-
friend class PrioritizedTexture;
PrioritizedTexture* m_owner;
int m_priorityAtLastPriorityUpdate;
@@ -122,6 +119,7 @@ private:
#ifndef NDEBUG
ResourceProvider* m_resourceProvider;
#endif
+
DISALLOW_COPY_AND_ASSIGN(Backing);
};
diff --git a/cc/prioritized_texture_manager.cc b/cc/prioritized_texture_manager.cc
index 07de017..32944bf 100644
--- a/cc/prioritized_texture_manager.cc
+++ b/cc/prioritized_texture_manager.cc
@@ -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
diff --git a/cc/prioritized_texture_manager.h b/cc/prioritized_texture_manager.h
index b0127db..92d739f 100644
--- a/cc/prioritized_texture_manager.h
+++ b/cc/prioritized_texture_manager.h
@@ -11,7 +11,6 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/memory/scoped_ptr.h"
-#include "cc/proxy.h"
#include "cc/prioritized_texture.h"
#include "cc/priority_calculator.h"
#include "cc/texture.h"
@@ -32,13 +31,12 @@ struct hash<cc::PrioritizedTexture*> {
namespace cc {
class PriorityCalculator;
-class Proxy;
class 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)
{
@@ -109,8 +107,6 @@ public:
// Mark all textures' backings as being in the drawing impl tree.
void updateBackingsInDrawingImplTree();
- const Proxy* proxyForDebug() const;
-
private:
friend class PrioritizedTextureTest;
@@ -145,7 +141,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*);
@@ -171,8 +167,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
diff --git a/cc/prioritized_texture_unittest.cc b/cc/prioritized_texture_unittest.cc
index 6511dce..9c37395 100644
--- a/cc/prioritized_texture_unittest.cc
+++ b/cc/prioritized_texture_unittest.cc
@@ -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 IntSize 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());
}
diff --git a/cc/proxy.cc b/cc/proxy.cc
index 46ef19f..7b738aa 100644
--- a/cc/proxy.cc
+++ b/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
+namespace {
+#ifndef NDEBUG
+bool implThreadIsOverridden = false;
+bool s_isMainThreadBlocked = false;
+#endif
+Thread* s_mainThread = 0;
+Thread* s_implThread = 0;
+}
+
+void Proxy::setMainThread(Thread* thread)
+{
+ s_mainThread = thread;
+}
+
+Thread* Proxy::mainThread()
{
- return m_mainThread.get();
+ return s_mainThread;
}
-bool Proxy::hasImplThread() const
+bool Proxy::hasImplThread()
{
- return m_implThread;
+ return s_implThread;
}
-Thread* Proxy::implThread() const
+void Proxy::setImplThread(Thread* thread)
{
- return m_implThread.get();
+ s_implThread = thread;
}
-Thread* Proxy::currentThread() const
+Thread* Proxy::implThread()
{
- if (mainThread() && mainThread()->belongsToCurrentThread())
- return mainThread();
- if (implThread() && implThread()->belongsToCurrentThread())
- return 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()
diff --git a/cc/proxy.h b/cc/proxy.h
index 3fc1552..7b1c7e8 100644
--- a/cc/proxy.h
+++ b/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>
namespace gfx {
@@ -26,21 +25,15 @@ struct RendererCapabilities;
// the compositor over to the compositor implementation.
class Proxy {
public:
- Thread* mainThread() const;
- bool hasImplThread() const;
- Thread* implThread() const;
+ static void setMainThread(Thread*);
+ static Thread* mainThread();
- // Returns 0 if the current thread is neither the main thread nor the impl thread.
- Thread* currentThread() const;
+ static bool hasImplThread();
+ static void setImplThread(Thread*);
+ static Thread* implThread();
- // Debug hooks
- bool isMainThread() const;
- bool isImplThread() const;
- bool isMainThreadBlocked() const;
-#ifndef NDEBUG
- void setMainThreadBlocked(bool);
- void setCurrentThreadIsImplThread(bool);
-#endif
+ // Returns 0 if the current thread is neither the main thread nor the impl thread.
+ static Thread* currentThread();
virtual ~Proxy();
@@ -96,45 +89,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;
};
}
diff --git a/cc/quad_culler_unittest.cc b/cc/quad_culler_unittest.cc
index 05060d4d..a9f15bb 100644
--- a/cc/quad_culler_unittest.cc
+++ b/cc/quad_culler_unittest.cc
@@ -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; \
diff --git a/cc/rate_limiter.cc b/cc/rate_limiter.cc
index 28254f7..fab541e 100644
--- a/cc/rate_limiter.cc
+++ b/cc/rate_limiter.cc
@@ -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()
diff --git a/cc/rate_limiter.h b/cc/rate_limiter.h
index 935e64b..1630864 100644
--- a/cc/rate_limiter.h
+++ b/cc/rate_limiter.h
@@ -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;
};
}
diff --git a/cc/render_surface_unittest.cc b/cc/render_surface_unittest.cc
index 8e11d8e..397cfc6 100644
--- a/cc/render_surface_unittest.cc
+++ b/cc/render_surface_unittest.cc
@@ -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);
diff --git a/cc/renderer.h b/cc/renderer.h
index df0c9431..11e00fc 100644
--- a/cc/renderer.h
+++ b/cc/renderer.h
@@ -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() { }
};
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc
index 973c947..dab281a 100644
--- a/cc/resource_provider.cc
+++ b/cc/resource_provider.cc
@@ -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 "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
@@ -137,13 +138,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;
@@ -166,7 +167,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);
@@ -192,7 +193,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];
@@ -204,7 +205,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);
@@ -215,7 +216,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;
@@ -247,7 +248,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)
@@ -267,7 +268,7 @@ ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
void ResourceProvider::upload(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;
@@ -330,7 +331,7 @@ double ResourceProvider::estimatedUploadsPerSecond()
void ResourceProvider::flush()
{
- DCHECK(m_threadChecker.CalledOnValidThread());
+ DCHECK(Proxy::isImplThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (context3d)
context3d->flush();
@@ -338,7 +339,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;
@@ -349,7 +350,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()) {
@@ -377,7 +378,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;
@@ -388,7 +389,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;
@@ -402,7 +403,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;
@@ -485,7 +486,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;
@@ -521,7 +522,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++;
@@ -531,7 +532,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);
@@ -541,7 +542,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;
@@ -549,7 +550,7 @@ const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int
ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToParent(const ResourceIdArray& resources)
{
- DCHECK(m_threadChecker.CalledOnValidThread());
+ DCHECK(Proxy::isImplThread());
TransferableResourceList list;
list.syncPoint = 0;
WebGraphicsContext3D* context3d = m_context->context3D();
@@ -571,7 +572,7 @@ ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToParent
ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources)
{
- DCHECK(m_threadChecker.CalledOnValidThread());
+ DCHECK(Proxy::isImplThread());
TransferableResourceList list;
list.syncPoint = 0;
WebGraphicsContext3D* context3d = m_context->context3D();
@@ -598,7 +599,7 @@ ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToChild(
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.
@@ -630,7 +631,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.
@@ -654,7 +655,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;
diff --git a/cc/resource_provider.h b/cc/resource_provider.h
index f273550..45b99eb 100644
--- a/cc/resource_provider.h
+++ b/cc/resource_provider.h
@@ -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/graphics_context.h"
#include "cc/texture_copier.h"
#include "third_party/khronos/GLES2/gl2.h"
@@ -33,8 +32,8 @@ class LayerTextureSubImage;
class TextureCopier;
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 ResourceProvider {
public:
typedef unsigned ResourceId;
@@ -279,8 +278,6 @@ private:
scoped_ptr<AcceleratedTextureCopier> m_textureCopier;
int m_maxTextureSize;
- base::ThreadChecker m_threadChecker;
-
DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
};
diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc
index f116142..f3c852f 100644
--- a/cc/resource_provider_unittest.cc
+++ b/cc/resource_provider_unittest.cc
@@ -10,7 +10,7 @@
#include "cc/graphics_context.h"
#include "cc/scoped_ptr_deque.h"
#include "cc/scoped_ptr_hash_map.h"
-#include "cc/stubs/int_rect.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"
@@ -300,6 +300,7 @@ public:
}
protected:
+ DebugScopedSetImplThread implThread;
scoped_ptr<ContextSharedData> m_sharedData;
scoped_ptr<GraphicsContext> m_context;
scoped_ptr<ResourceProvider> m_resourceProvider;
diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
index 4afb987..55c5277 100644
--- a/cc/resource_update_controller.cc
+++ b/cc/resource_update_controller.cc
@@ -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"
@@ -69,9 +70,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))
@@ -131,10 +131,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();
diff --git a/cc/resource_update_controller.h b/cc/resource_update_controller.h
index 375246c..7405149 100644
--- a/cc/resource_update_controller.h
+++ b/cc/resource_update_controller.h
@@ -26,9 +26,9 @@ protected:
class 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();
@@ -47,7 +47,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*);
@@ -62,7 +62,6 @@ private:
void onTimerFired();
ResourceUpdateControllerClient* m_client;
- bool m_hasImplThread;
scoped_ptr<ResourceUpdateQueue> m_queue;
bool m_contentsTexturesPurged;
ResourceProvider* m_resourceProvider;
diff --git a/cc/resource_update_controller_unittest.cc b/cc/resource_update_controller_unittest.cc
index 39284f7..9c46af5 100644
--- a/cc/resource_update_controller_unittest.cc
+++ b/cc/resource_update_controller_unittest.cc
@@ -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(
diff --git a/cc/scoped_texture_unittest.cc b/cc/scoped_texture_unittest.cc
index fdd4e30..0be883d 100644
--- a/cc/scoped_texture_unittest.cc
+++ b/cc/scoped_texture_unittest.cc
@@ -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, IntSize(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()));
{
diff --git a/cc/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
index bbd6882..32537cb 100644
--- a/cc/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -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;
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index 736d4b5..fb68734 100644
--- a/cc/scrollbar_layer_unittest.cc
+++ b/cc/scrollbar_layer_unittest.cc
@@ -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());
diff --git a/cc/single_thread_proxy.cc b/cc/single_thread_proxy.cc
index dfc86fb..7fe679f 100644
--- a/cc/single_thread_proxy.cc
+++ b/cc/single_thread_proxy.cc
@@ -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;
diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h
index fa3ce013..91e0810 100644
--- a/cc/single_thread_proxy.h
+++ b/cc/single_thread_proxy.h
@@ -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;
diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc
index 7439ae8..9592039 100644
--- a/cc/software_renderer.cc
+++ b/cc/software_renderer.cc
@@ -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;
}
diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc
index 3eb4012..a04864a 100644
--- a/cc/software_renderer_unittest.cc
+++ b/cc/software_renderer_unittest.cc
@@ -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;
diff --git a/cc/solid_color_layer_impl_unittest.cc b/cc/solid_color_layer_impl_unittest.cc
index 01da554..c43ca5c 100644
--- a/cc/solid_color_layer_impl_unittest.cc
+++ b/cc/solid_color_layer_impl_unittest.cc
@@ -21,6 +21,8 @@ namespace {
TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
{
+ DebugScopedSetImplThread scopedImplThread;
+
MockQuadCuller quadCuller;
IntSize layerSize = IntSize(800, 600);
IntRect visibleContentRect = IntRect(IntPoint(), 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;
diff --git a/cc/test/fake_proxy.cc b/cc/test/fake_proxy.cc
deleted file mode 100644
index fad6c69..0000000
--- a/cc/test/fake_proxy.cc
+++ /dev/null
@@ -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
diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h
deleted file mode 100644
index e432d00..0000000
--- a/cc/test/fake_proxy.h
+++ /dev/null
@@ -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
diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc
index 608d516..da3f430 100644
--- a/cc/test/layer_tree_test_common.cc
+++ b/cc/test/layer_tree_test_common.cc
@@ -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());
diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h
index b0f277b..962764a 100644
--- a/cc/test/layer_tree_test_common.h
+++ b/cc/test/layer_tree_test_common.h
@@ -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;
};
diff --git a/cc/test/run_all_unittests.cc b/cc/test/run_all_unittests.cc
index 4ea8697..d0fddbc 100644
--- a/cc/test/run_all_unittests.cc
+++ b/cc/test/run_all_unittests.cc
@@ -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;
}
+
diff --git a/cc/texture_layer_unittest.cc b/cc/texture_layer_unittest.cc
index e55a683..67ba102 100644
--- a/cc/texture_layer_unittest.cc
+++ b/cc/texture_layer_unittest.cc
@@ -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)
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index 4ea4220..ac58216 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -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.
diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h
index 5ccedc1..1249687 100644
--- a/cc/thread_proxy.h
+++ b/cc/thread_proxy.h
@@ -5,7 +5,6 @@
#ifndef CCThreadProxy_h
#define CCThreadProxy_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 {
diff --git a/cc/tiled_layer_impl_unittest.cc b/cc/tiled_layer_impl_unittest.cc
index 0db0aca..35c4962 100644
--- a/cc/tiled_layer_impl_unittest.cc
+++ b/cc/tiled_layer_impl_unittest.cc
@@ -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;
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index 2dd253d..681e423 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -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
diff --git a/cc/tree_synchronizer_unittest.cc b/cc/tree_synchronizer_unittest.cc
index a061dff..88654df 100644
--- a/cc/tree_synchronizer_unittest.cc
+++ b/cc/tree_synchronizer_unittest.cc
@@ -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();
diff --git a/cc/video_layer_impl.cc b/cc/video_layer_impl.cc
index f958ccf..45f6ed6 100644
--- a/cc/video_layer_impl.cc
+++ b/cc/video_layer_impl.cc
@@ -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)