| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 m_objects.removeAll(objectsToRemove); | 92 m_objects.removeAll(objectsToRemove); |
| 93 | 93 |
| 94 updateImageResourcesWithLoadPriority(); | 94 updateImageResourcesWithLoadPriority(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ResourceLoadPriorityOptimizer::updateImageResourcesWithLoadPriority() | 97 void ResourceLoadPriorityOptimizer::updateImageResourcesWithLoadPriority() |
| 98 { | 98 { |
| 99 for (ImageResourceMap::iterator it = m_imageResources.begin(); it != m_image
Resources.end(); ++it) { | 99 for (ImageResourceMap::iterator it = m_imageResources.begin(); it != m_image
Resources.end(); ++it) { |
| 100 ResourceLoadPriority priority = it->value->status == Visible ? | 100 ResourceLoadPriority priority = it->value->status == Visible ? |
| 101 ResourceLoadPriorityLow : ResourceLoadPriorityVeryLow; | 101 ResourceLoadPriorityMedium : ResourceLoadPriorityVeryLow; |
| 102 | 102 |
| 103 if (priority != it->value->imageResource->resourceRequest().priority())
{ | 103 if (priority != it->value->imageResource->resourceRequest().priority())
{ |
| 104 it->value->imageResource->mutableResourceRequest().setPriority(prior
ity, it->value->screenArea); | 104 it->value->imageResource->mutableResourceRequest().setPriority(prior
ity, it->value->screenArea); |
| 105 it->value->imageResource->didChangePriority(priority, it->value->scr
eenArea); | 105 it->value->imageResource->didChangePriority(priority, it->value->scr
eenArea); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 m_imageResources.clear(); | 108 m_imageResources.clear(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void ResourceLoadPriorityOptimizer::notifyImageResourceVisibility(ImageResource*
img, VisibilityStatus status, const LayoutRect& screenRect) | 111 void ResourceLoadPriorityOptimizer::notifyImageResourceVisibility(ImageResource*
img, VisibilityStatus status, const LayoutRect& screenRect) |
| 112 { | 112 { |
| 113 if (!img || img->isLoaded()) | 113 if (!img || img->isLoaded()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 int screenArea = 0; | 116 int screenArea = 0; |
| 117 if (!screenRect.isEmpty() && status == Visible) | 117 if (!screenRect.isEmpty() && status == Visible) |
| 118 screenArea += static_cast<uint32_t>(screenRect.width() * screenRect.heig
ht()); | 118 screenArea += static_cast<uint32_t>(screenRect.width() * screenRect.heig
ht()); |
| 119 | 119 |
| 120 ImageResourceMap::AddResult result = m_imageResources.add(img->identifier(),
adoptPtr(new ResourceAndVisibility(img, status, screenArea))); | 120 ImageResourceMap::AddResult result = m_imageResources.add(img->identifier(),
adoptPtr(new ResourceAndVisibility(img, status, screenArea))); |
| 121 if (!result.isNewEntry && status == Visible) { | 121 if (!result.isNewEntry && status == Visible) { |
| 122 result.storedValue->value->status = status; | 122 result.storedValue->value->status = status; |
| 123 result.storedValue->value->screenArea = status; | 123 result.storedValue->value->screenArea = status; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 } | 127 } |
| OLD | NEW |