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

Side by Side Diff: Source/core/platform/graphics/Canvas2DImageBufferSurface.h

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fixes for win+mac Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef HTMLSrcsetParser_h 31 #ifndef Canvas2DImageBufferSurface_h
32 #define HTMLSrcsetParser_h 32 #define Canvas2DImageBufferSurface_h
33 33
34 #include "wtf/text/WTFString.h" 34 #include "core/platform/graphics/Canvas2DLayerBridge.h"
35 #include "platform/graphics/ImageBufferSurface.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 class ImageCandidate { 39 // This shim necessary because ImageBufferSurfaces are not allowed to be RefCoun ted
40 class Canvas2DImageBufferSurface : public ImageBufferSurface {
39 public: 41 public:
40 ImageCandidate() 42 Canvas2DImageBufferSurface(const IntSize& size, OpacityMode opacityMode, flo at resolutionScale, int msaaSampleCount)
41 : m_scaleFactor(1.0) 43 : ImageBufferSurface(size, opacityMode, resolutionScale)
44 , m_layerBridge(Canvas2DLayerBridge::create(size, opacityMode, msaaSampl eCount))
42 { 45 {
46 clear();
43 } 47 }
44 48
45 ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor) 49 virtual ~Canvas2DImageBufferSurface() { m_layerBridge->destroy(); }
46 : m_string(source.createView(start, length))
47 , m_scaleFactor(scaleFactor)
48 {
49 }
50 50
51 String toString() const 51 // ImageBufferSurface implementation
52 { 52 virtual void aboutToUse() OVERRIDE { m_layerBridge->aboutToUse(); }
53 return m_string.toString(); 53 virtual SkCanvas* canvas() const OVERRIDE { return m_layerBridge->canvas(); }
54 } 54 virtual bool isValid() const OVERRIDE { return m_layerBridge && m_layerBridg e->isValid(); }
55 55 virtual blink::WebLayer* layer() const OVERRIDE { return m_layerBridge->laye r(); }
56 inline float scaleFactor() const 56 virtual Platform3DObject getBackingTexture() const OVERRIDE { return m_layer Bridge->getBackingTexture(); }
57 { 57 virtual bool isAccelerated() const { return m_layerBridge->isAccelerated(); }
58 return m_scaleFactor;
59 }
60
61 inline bool isEmpty() const
62 {
63 return m_string.isEmpty();
64 }
65 58
66 private: 59 private:
67 StringView m_string; 60 RefPtr<Canvas2DLayerBridge> m_layerBridge;
68 float m_scaleFactor;
69 }; 61 };
70 62
71 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const St ring& srcsetAttribute);
72
73 ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, const St ring& srcAttribute, const String& srcsetAttribute);
74
75 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, ImageCandidate& srcsetImageCandidate);
76
77 } 63 }
78 64
79 #endif 65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698