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

Unified Diff: sky/engine/core/painting/CanvasImage.cpp

Issue 1151753009: Add Sky framework support for drawing images (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Run git cl format once more Created 5 years, 7 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 | « sky/engine/core/painting/CanvasImage.h ('k') | sky/engine/core/painting/Image.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/painting/CanvasImage.cpp
diff --git a/sky/engine/core/painting/CanvasImage.cpp b/sky/engine/core/painting/CanvasImage.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9bed98dc15f82e33836b8cda0f7e0ab203ccc4b
--- /dev/null
+++ b/sky/engine/core/painting/CanvasImage.cpp
@@ -0,0 +1,39 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/engine/config.h"
+#include "sky/engine/core/painting/CanvasImage.h"
+
+namespace blink {
+
+CanvasImage::CanvasImage() : imageLoader_(adoptPtr(new NewImageLoader(this))) {
+}
+
+CanvasImage::~CanvasImage() {
+}
+
+int CanvasImage::width() const {
+ return bitmap_.width();
+}
+
+int CanvasImage::height() const {
+ return bitmap_.height();
+}
+
+void CanvasImage::setSrc(const String& url) {
+ // TODO(jackson): Figure out how to determine the proper base URL here
+ KURL newSrcURL = KURL(KURL(), url);
+ if (srcURL_ != newSrcURL) {
+ srcURL_ = newSrcURL;
+ imageLoader_->Load(srcURL_);
+ }
+}
+
+void CanvasImage::OnLoadFinished(const SkBitmap& result) {
+ // TODO(jackson): We'll eventually need a notification pathway for
+ // when the image load is complete so that we know to repaint, etc.
+ bitmap_ = result;
+}
+
+} // namespace blink
« no previous file with comments | « sky/engine/core/painting/CanvasImage.h ('k') | sky/engine/core/painting/Image.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698