1*25ea7f45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*25ea7f45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*25ea7f45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*25ea7f45SAndrew Rist * distributed with this work for additional information 6*25ea7f45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*25ea7f45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*25ea7f45SAndrew Rist * "License"); you may not use this file except in compliance 9*25ea7f45SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*25ea7f45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*25ea7f45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*25ea7f45SAndrew Rist * software distributed under the License is distributed on an 15*25ea7f45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*25ea7f45SAndrew Rist * KIND, either express or implied. See the License for the 17*25ea7f45SAndrew Rist * specific language governing permissions and limitations 18*25ea7f45SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*25ea7f45SAndrew Rist *************************************************************/ 21*25ea7f45SAndrew Rist 22*25ea7f45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_canvas.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <canvas/debug.hxx> 28cdf0e10cSrcweir #include <tools/diagnose_ex.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "cachedbitmap.hxx" 31cdf0e10cSrcweir #include "repainttarget.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <com/sun/star/rendering/RepaintResult.hpp> 34cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 37cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace ::com::sun::star; 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace vclcanvas 43cdf0e10cSrcweir { CachedBitmap(const GraphicObjectSharedPtr & rGraphicObject,const::Point & rPoint,const::Size & rSize,const GraphicAttr & rAttr,const rendering::ViewState & rUsedViewState,const rendering::RenderState & rUsedRenderState,const uno::Reference<rendering::XCanvas> & rTarget)44cdf0e10cSrcweir CachedBitmap::CachedBitmap( const GraphicObjectSharedPtr& rGraphicObject, 45cdf0e10cSrcweir const ::Point& rPoint, 46cdf0e10cSrcweir const ::Size& rSize, 47cdf0e10cSrcweir const GraphicAttr& rAttr, 48cdf0e10cSrcweir const rendering::ViewState& rUsedViewState, 49cdf0e10cSrcweir const rendering::RenderState& rUsedRenderState, 50cdf0e10cSrcweir const uno::Reference< rendering::XCanvas >& rTarget ) : 51cdf0e10cSrcweir CachedPrimitiveBase( rUsedViewState, rTarget, true ), 52cdf0e10cSrcweir mpGraphicObject( rGraphicObject ), 53cdf0e10cSrcweir maRenderState(rUsedRenderState), 54cdf0e10cSrcweir maPoint( rPoint ), 55cdf0e10cSrcweir maSize( rSize ), 56cdf0e10cSrcweir maAttributes( rAttr ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir } 59cdf0e10cSrcweir disposing()60cdf0e10cSrcweir void SAL_CALL CachedBitmap::disposing() 61cdf0e10cSrcweir { 62cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 63cdf0e10cSrcweir 64cdf0e10cSrcweir mpGraphicObject.reset(); 65cdf0e10cSrcweir 66cdf0e10cSrcweir CachedPrimitiveBase::disposing(); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir doRedraw(const rendering::ViewState & rNewState,const rendering::ViewState & rOldState,const uno::Reference<rendering::XCanvas> & rTargetCanvas,bool bSameViewTransform)69cdf0e10cSrcweir ::sal_Int8 CachedBitmap::doRedraw( const rendering::ViewState& rNewState, 70cdf0e10cSrcweir const rendering::ViewState& rOldState, 71cdf0e10cSrcweir const uno::Reference< rendering::XCanvas >& rTargetCanvas, 72cdf0e10cSrcweir bool bSameViewTransform ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ENSURE_OR_THROW( bSameViewTransform, 75cdf0e10cSrcweir "CachedBitmap::doRedraw(): base called with changed view transform " 76cdf0e10cSrcweir "(told otherwise during construction)" ); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // TODO(P1): Could adapt to modified clips as well 79cdf0e10cSrcweir if( rNewState.Clip != rOldState.Clip ) 80cdf0e10cSrcweir return rendering::RepaintResult::FAILED; 81cdf0e10cSrcweir 82cdf0e10cSrcweir RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get()); 83cdf0e10cSrcweir 84cdf0e10cSrcweir ENSURE_OR_THROW( pTarget, 85cdf0e10cSrcweir "CachedBitmap::redraw(): cannot cast target to RepaintTarget" ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir if( !pTarget->repaint( mpGraphicObject, 88cdf0e10cSrcweir rNewState, 89cdf0e10cSrcweir maRenderState, 90cdf0e10cSrcweir maPoint, 91cdf0e10cSrcweir maSize, 92cdf0e10cSrcweir maAttributes ) ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir // target failed to repaint 95cdf0e10cSrcweir return rendering::RepaintResult::FAILED; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir return rendering::RepaintResult::REDRAWN; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir } 101