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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/Canvas2DImageBufferSurface.h
diff --git a/Source/core/html/parser/HTMLSrcsetParser.h b/Source/core/platform/graphics/Canvas2DImageBufferSurface.h
similarity index 55%
copy from Source/core/html/parser/HTMLSrcsetParser.h
copy to Source/core/platform/graphics/Canvas2DImageBufferSurface.h
index 8964ffbcd5f61ee309ab67d2e4fe83855e89c736..406ba591d1f83431a6e0e9c24bff378e05812494 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.h
+++ b/Source/core/platform/graphics/Canvas2DImageBufferSurface.h
@@ -28,52 +28,38 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HTMLSrcsetParser_h
-#define HTMLSrcsetParser_h
+#ifndef Canvas2DImageBufferSurface_h
+#define Canvas2DImageBufferSurface_h
-#include "wtf/text/WTFString.h"
+#include "core/platform/graphics/Canvas2DLayerBridge.h"
+#include "platform/graphics/ImageBufferSurface.h"
namespace WebCore {
-class ImageCandidate {
+// This shim necessary because ImageBufferSurfaces are not allowed to be RefCounted
+class Canvas2DImageBufferSurface : public ImageBufferSurface {
public:
- ImageCandidate()
- : m_scaleFactor(1.0)
+ Canvas2DImageBufferSurface(const IntSize& size, OpacityMode opacityMode, float resolutionScale, int msaaSampleCount)
+ : ImageBufferSurface(size, opacityMode, resolutionScale)
+ , m_layerBridge(Canvas2DLayerBridge::create(size, opacityMode, msaaSampleCount))
{
+ clear();
}
- ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor)
- : m_string(source.createView(start, length))
- , m_scaleFactor(scaleFactor)
- {
- }
+ virtual ~Canvas2DImageBufferSurface() { m_layerBridge->destroy(); }
- String toString() const
- {
- return m_string.toString();
- }
-
- inline float scaleFactor() const
- {
- return m_scaleFactor;
- }
-
- inline bool isEmpty() const
- {
- return m_string.isEmpty();
- }
+ // ImageBufferSurface implementation
+ virtual void aboutToUse() OVERRIDE { m_layerBridge->aboutToUse(); }
+ virtual SkCanvas* canvas() const OVERRIDE { return m_layerBridge->canvas(); }
+ virtual bool isValid() const OVERRIDE { return m_layerBridge && m_layerBridge->isValid(); }
+ virtual blink::WebLayer* layer() const OVERRIDE { return m_layerBridge->layer(); }
+ virtual Platform3DObject getBackingTexture() const OVERRIDE { return m_layerBridge->getBackingTexture(); }
+ virtual bool isAccelerated() const { return m_layerBridge->isAccelerated(); }
private:
- StringView m_string;
- float m_scaleFactor;
+ RefPtr<Canvas2DLayerBridge> m_layerBridge;
};
-ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const String& srcsetAttribute);
-
-ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, const String& srcsetAttribute);
-
-String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, ImageCandidate& srcsetImageCandidate);
-
}
#endif

Powered by Google App Engine
This is Rietveld 408576698