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

Unified Diff: cc/resources/resource.h

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Android build break. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/raster/tile_task_worker_pool_unittest.cc ('k') | cc/resources/resource_format.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource.h
diff --git a/cc/resources/resource.h b/cc/resources/resource.h
index f9138fbb876ef405c8afada390cf4031f92f4b92..549a314d48eb601fc7eba5fc438378d0eb039c7b 100644
--- a/cc/resources/resource.h
+++ b/cc/resources/resource.h
@@ -5,9 +5,9 @@
#ifndef CC_RESOURCES_RESOURCE_H_
#define CC_RESOURCES_RESOURCE_H_
-#include "base/numerics/safe_math.h"
#include "cc/base/cc_export.h"
#include "cc/resources/resource_provider.h"
+#include "cc/resources/resource_util.h"
#include "ui/gfx/geometry/size.h"
namespace cc {
@@ -24,37 +24,6 @@ class CC_EXPORT Resource {
gfx::Size size() const { return size_; }
ResourceFormat format() const { return format_; }
- // Return true if the call to UncheckedMemorySizeBytes would return a value
- // that fits in a size_t.
- static bool VerifySizeInBytes(const gfx::Size& size, ResourceFormat format) {
- base::CheckedNumeric<size_t> checked_value = BitsPerPixel(format);
- checked_value *= size.width();
- checked_value *= size.height();
- if (!checked_value.IsValid())
- return false;
- size_t value = checked_value.ValueOrDie();
- if ((value % 8) != 0)
- return false;
- return true;
- }
-
- static size_t CheckedMemorySizeBytes(const gfx::Size& size,
- ResourceFormat format) {
- DCHECK(VerifySizeInBytes(size, format));
- base::CheckedNumeric<size_t> checked_value = BitsPerPixel(format);
- checked_value *= size.width();
- checked_value *= size.height();
- checked_value /= 8;
- return checked_value.ValueOrDie();
- }
-
- inline static size_t UncheckedMemorySizeBytes(const gfx::Size& size,
- ResourceFormat format) {
- DCHECK(VerifySizeInBytes(size, format));
- return static_cast<size_t>(BitsPerPixel(format)) * size.width() *
- size.height() / 8;
- }
-
protected:
void set_id(ResourceId id) { id_ = id; }
void set_dimensions(const gfx::Size& size, ResourceFormat format) {
« no previous file with comments | « cc/raster/tile_task_worker_pool_unittest.cc ('k') | cc/resources/resource_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698