Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/core/style/FillLayer.cpp

Issue 1787733003: Consolidate background fill layer opaqueness into one method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows build Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/style/FillLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 * 19 *
20 */ 20 */
21 21
22 #include "core/style/FillLayer.h" 22 #include "core/style/FillLayer.h"
23 23
24 #include "core/layout/LayoutObject.h"
24 #include "core/style/DataEquivalency.h" 25 #include "core/style/DataEquivalency.h"
25 26
26 namespace blink { 27 namespace blink {
27 28
28 struct SameSizeAsFillLayer { 29 struct SameSizeAsFillLayer {
29 FillLayer* m_next; 30 FillLayer* m_next;
30 31
31 RefPtrWillBePersistent<StyleImage> m_image; 32 RefPtrWillBePersistent<StyleImage> m_image;
32 33
33 Length m_xPosition; 34 Length m_xPosition;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 { 364 {
364 const FillLayer* curr; 365 const FillLayer* curr;
365 for (curr = this; curr; curr = curr->next()) { 366 for (curr = this; curr; curr = curr->next()) {
366 if (curr->m_image && !curr->m_image->isLoaded()) 367 if (curr->m_image && !curr->m_image->isLoaded())
367 return false; 368 return false;
368 } 369 }
369 370
370 return true; 371 return true;
371 } 372 }
372 373
373 bool FillLayer::hasOpaqueImage(const LayoutObject* layoutObject) const 374 bool FillLayer::imageIsOpaque(const LayoutObject& layoutObject) const
374 { 375 {
375 if (!m_image) 376 // Returns true if we have an image that will cover the content below it whe n
377 // m_composite == CompositeSourceOver && m_blendMode == WebBlendModeNormal.
378 // Otherwise false.
379 return m_image->knownToBeOpaque(layoutObject)
380 && !m_image->imageSize(layoutObject, layoutObject.style()->effectiveZoom (), LayoutSize()).isEmpty();
381 }
382
383 bool FillLayer::imageTilesLayer() const
384 {
385 // Returns true if an image will be tiled such that it covers any sized rect angle.
386 // TODO(schenney) We could relax the repeat mode requirement if we also knew the rect we
387 // had to fill, and the portion of the image we need to use, and know that t he latter
388 // covers the former
389 return (m_repeatX == RepeatFill || m_repeatX == RoundFill)
390 && (m_repeatY == RepeatFill || m_repeatY == RoundFill);
391
392 }
393
394 bool FillLayer::imageOccludesNextLayers(const LayoutObject& layoutObject) const
395 {
396 // We can't cover without an image, regardless of other parameters
397 if (!m_image || !m_image->canRender())
376 return false; 398 return false;
377 399
378 // TODO(trchen): Should check blend mode before composite mode. 400 switch (m_composite) {
379 if (m_composite == CompositeClear || m_composite == CompositeCopy) 401 case CompositeClear:
380 return true; 402 case CompositeCopy:
381 403 return imageTilesLayer();
382 if (m_blendMode != WebBlendModeNormal) 404 case CompositeSourceOver:
383 return false; 405 return (m_blendMode == WebBlendModeNormal) && imageTilesLayer() && image IsOpaque(layoutObject);
384 406 default: { }
385 if (m_composite == CompositeSourceOver) 407 }
386 return m_image->knownToBeOpaque(*layoutObject);
387 408
388 return false; 409 return false;
389 } 410 }
390 411
391 bool FillLayer::hasRepeatXY() const
392 {
393 return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
394 }
395
396 static inline bool layerImagesIdentical(const FillLayer& layer1, const FillLayer & layer2) 412 static inline bool layerImagesIdentical(const FillLayer& layer1, const FillLayer & layer2)
397 { 413 {
398 // We just care about pointer equivalency. 414 // We just care about pointer equivalency.
399 return layer1.image() == layer2.image(); 415 return layer1.image() == layer2.image();
400 } 416 }
401 417
402 bool FillLayer::imagesIdentical(const FillLayer* layer1, const FillLayer* layer2 ) 418 bool FillLayer::imagesIdentical(const FillLayer* layer1, const FillLayer* layer2 )
403 { 419 {
404 for (; layer1 && layer2; layer1 = layer1->next(), layer2 = layer2->next()) { 420 for (; layer1 && layer2; layer1 = layer1->next(), layer2 = layer2->next()) {
405 if (!layerImagesIdentical(*layer1, *layer2)) 421 if (!layerImagesIdentical(*layer1, *layer2))
406 return false; 422 return false;
407 } 423 }
408 424
409 return !layer1 && !layer2; 425 return !layer1 && !layer2;
410 } 426 }
411 427
412 } // namespace blink 428 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/FillLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698