| /* |
| * Copyright (C) 2010 Google Inc. All rights reserved. |
| * Copyright (C) 2009 Apple Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are |
| * met: |
| * |
| * * Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * * Redistributions in binary form must reproduce the above |
| * copyright notice, this list of conditions and the following disclaimer |
| * in the documentation and/or other materials provided with the |
| * distribution. |
| * * Neither the name of Google Inc. nor the names of its |
| * contributors may be used to endorse or promote products derived from |
| * this software without specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| |
| /** FIXME |
| * This file borrows code heavily from platform/graphics/win/GraphicsLayerCACF.cpp |
| * (and hence it includes both copyrights) |
| * Ideally the common code (mostly the code that keeps track of the layer hierarchy) |
| * should be kept separate and shared between platforms. It would be a well worthwhile |
| * effort once the Windows implementation (binaries and headers) of CoreAnimation is |
| * checked in to the WebKit repository. Until then only Apple can make this happen. |
| */ |
| |
| #include "config.h" |
| |
| #include "core/platform/graphics/chromium/GraphicsLayerChromium.h" |
| |
| #include "core/platform/ScrollableArea.h" |
| #include "core/platform/graphics/GraphicsContext.h" |
| #include "core/platform/graphics/GraphicsLayerFactory.h" |
| #include <public/Platform.h> |
| #include <public/WebAnimation.h> |
| #include <public/WebCompositorSupport.h> |
| #include <public/WebContentLayer.h> |
| #include <public/WebFilterOperation.h> |
| #include <public/WebFilterOperations.h> |
| #include <public/WebFloatPoint.h> |
| #include <public/WebFloatRect.h> |
| #include <public/WebImageLayer.h> |
| #include <public/WebSize.h> |
| #include <public/WebSolidColorLayer.h> |
| #include <wtf/CurrentTime.h> |
| #include <wtf/HashSet.h> |
| #include <wtf/MemoryInstrumentationHashMap.h> |
| #include <wtf/StringExtras.h> |
| #include <wtf/text/CString.h> |
| #include <wtf/text/StringHash.h> |
| #include <wtf/text/WTFString.h> |
| |
| using namespace std; |
| using namespace WebKit; |
| |
| namespace WebCore { |
| |
| PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client) |
| { |
| return factory->createGraphicsLayer(client); |
| } |
| |
| PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client) |
| { |
| ASSERT_NOT_REACHED(); |
| return nullptr; |
| } |
| |
| GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client) |
| : GraphicsLayer(client) |
| { |
| m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this)); |
| m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLayer(m_opaqueRectTrackingContentLayerDelegate.get())); |
| m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
| m_layer->layer()->setScrollClient(this); |
| m_layer->setAutomaticallyComputeRasterScale(true); |
| } |
| |
| GraphicsLayerChromium::~GraphicsLayerChromium() |
| { |
| willBeDestroyed(); |
| } |
| |
| void GraphicsLayerChromium::paint(GraphicsContext& context, const IntRect& clip) |
| { |
| paintGraphicsLayerContents(context, clip); |
| } |
| |
| void GraphicsLayerChromium::notifyAnimationStarted(double startTime) |
| { |
| if (m_client) |
| m_client->notifyAnimationStarted(this, startTime); |
| } |
| |
| void GraphicsLayerChromium::notifyAnimationFinished(double) |
| { |
| // Do nothing. |
| } |
| |
| void GraphicsLayerChromium::didScroll() |
| { |
| if (m_scrollableArea) |
| m_scrollableArea->scrollToOffsetWithoutAnimation(m_scrollableArea->minimumScrollPosition() + toIntSize(m_layer->layer()->scrollPosition())); |
| } |
| |
| void GraphicsLayerChromium::setAnimationDelegateForLayer(WebKit::WebLayer* layer) |
| { |
| layer->setAnimationDelegate(this); |
| } |
| |
| } // namespace WebCore |