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

Issue 1873463004: gfx::Image: Made Image objects shallow-copy their representations. (Closed)

Created:
4 years, 8 months ago by Matt Giuca
Modified:
3 years, 5 months ago
Reviewers:
CC:
chromium-reviews, rsesek+watch_chromium.org, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

gfx::Image: Made Image objects shallow-copy their representations. Previously, Images kept a reference-counted map. Now they just clone the entire map. All of the objects inside are reference-counted, so this is slightly more expensive but not by much, and avoids some thread safety issues. PROOF OF CONCEPT / DO NOT SUBMIT Problems with this approach: - Breaks ToImageSkia(); the returned pointer now points into storage owned by the immediate Image object it was called on (previously it pointed at memory shared by all of the Image objects). Lots of client code relies on this and it is non-trivial to clean it up. - Efficiency issues: This weakens the effects of caching because each individual image object has its own copy of the cache (e.g., imagine an Image with an ImageRepPNG is copied, then AsImageSkia() is called, then the copy is deleted; the original Image will not have an ImageSkia rep). BUG=600237

Patch Set 1 #

Patch Set 2 : Rebase. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+68 lines, -21 lines) Patch
M ui/gfx/image/image.h View 1 1 chunk +1 line, -1 line 0 comments Download
M ui/gfx/image/image.cc View 1 14 chunks +67 lines, -20 lines 0 comments Download

Messages

Total messages: 1 (1 generated)
Matt Giuca
4 years, 8 months ago (2016-04-08 03:58:37 UTC) #1
Description was changed from

==========
gfx::Image: Made Image objects shallow-copy their representations.

Previously, Images kept a reference-counted map. Now they just clone the
entire map. All of the objects inside are reference-counted, so this is
slightly more expensive but not by much, and avoids some thread safety
issues.

PROOF OF CONCEPT / DO NOT SUBMIT

Problems with this approach:
- NSImage and UIImage are not refcounted (maybe they are internally, but
  here they are just raw pointers).
- Breaks ToImageSkia(); the returned pointer now points into storage
  owned by the immediate Image object it was called on (previously it
  pointed at memory shared by all of the Image objects). Lots of client
  code relies on this and it is non-trivial to clean it up.
- Efficiency issues: This weakens the effects of caching because each
  individual image object has its own copy of the cache (e.g., imagine
  an Image with an ImageRepPNG is copied, then AsImageSkia() is called,
  then the copy is deleted; the original Image will not have an
  ImageSkia rep).

BUG=600237
==========

to

==========
gfx::Image: Made Image objects shallow-copy their representations.

Previously, Images kept a reference-counted map. Now they just clone the
entire map. All of the objects inside are reference-counted, so this is
slightly more expensive but not by much, and avoids some thread safety
issues.

PROOF OF CONCEPT / DO NOT SUBMIT

Problems with this approach:
- Breaks ToImageSkia(); the returned pointer now points into storage
  owned by the immediate Image object it was called on (previously it
  pointed at memory shared by all of the Image objects). Lots of client
  code relies on this and it is non-trivial to clean it up.
- Efficiency issues: This weakens the effects of caching because each
  individual image object has its own copy of the cache (e.g., imagine
  an Image with an ImageRepPNG is copied, then AsImageSkia() is called,
  then the copy is deleted; the original Image will not have an
  ImageSkia rep).

BUG=600237
==========

Powered by Google App Engine
This is Rietveld 408576698