aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-02-27 19:41:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-27 19:41:54 -0800
commitfa82348a39a9cc348a0d4c627d3048b34bf716d4 (patch)
treeec749762f56d957fac6152efe75f16e417dec283
parentf3fb5d3fb8d6367f604ebb53161532cf8c32e56b (diff)
remove unused view helpers
-rw-r--r--gyp/views.gyp5
-rw-r--r--include/views/SkBGViewArtist.h33
-rw-r--r--include/views/SkParsePaint.h26
-rw-r--r--include/views/SkViewInflate.h71
-rw-r--r--src/views/SkBGViewArtist.cpp30
-rw-r--r--src/views/SkParsePaint.cpp109
-rw-r--r--src/views/SkViewInflate.cpp145
7 files changed, 0 insertions, 419 deletions
diff --git a/gyp/views.gyp b/gyp/views.gyp
index b9bba4832a..3db7e40fa4 100644
--- a/gyp/views.gyp
+++ b/gyp/views.gyp
@@ -28,7 +28,6 @@
],
'sources': [
'../include/views/SkApplication.h',
- '../include/views/SkBGViewArtist.h',
'../include/views/SkEvent.h',
'../include/views/SkEventSink.h',
'../include/views/SkKey.h',
@@ -40,19 +39,15 @@
'../include/views/SkSystemEventTypes.h',
'../include/views/SkTouchGesture.h',
'../include/views/SkView.h',
- '../include/views/SkViewInflate.h',
'../include/views/SkWindow.h',
- '../src/views/SkBGViewArtist.cpp',
'../src/views/SkEvent.cpp',
'../src/views/SkEventSink.cpp',
'../src/views/SkOSMenu.cpp',
- '../src/views/SkParsePaint.cpp',
'../src/views/SkTagList.cpp',
'../src/views/SkTagList.h',
'../src/views/SkTouchGesture.cpp',
'../src/views/SkView.cpp',
- '../src/views/SkViewInflate.cpp',
'../src/views/SkViewPriv.cpp',
'../src/views/SkViewPriv.h',
'../src/views/SkWindow.cpp',
diff --git a/include/views/SkBGViewArtist.h b/include/views/SkBGViewArtist.h
deleted file mode 100644
index 33054c8038..0000000000
--- a/include/views/SkBGViewArtist.h
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkBGViewArtist_DEFINED
-#define SkBGViewArtist_DEFINED
-
-#include "SkView.h"
-#include "SkPaint.h"
-
-class SkBGViewArtist : public SkView::Artist {
-public:
- SkBGViewArtist(SkColor c = SK_ColorWHITE);
- virtual ~SkBGViewArtist();
-
- const SkPaint& paint() const { return fPaint; }
- SkPaint& paint() { return fPaint; }
-
-protected:
- // overrides
- virtual void onDraw(SkView*, SkCanvas*);
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-
-private:
- SkPaint fPaint;
-};
-
-#endif
diff --git a/include/views/SkParsePaint.h b/include/views/SkParsePaint.h
deleted file mode 100644
index 066292f9c7..0000000000
--- a/include/views/SkParsePaint.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkParsePaint_DEFINED
-#define SkParsePaint_DEFINED
-
-#include "SkPaint.h"
-#include "SkDOM.h"
-
-/** "color" color
- "opacity" scalar [0..1]
- "stroke-width" scalar (0...inf)
- "text-size" scalar (0..inf)
- "is-stroke" bool
- "is-antialias" bool
- "is-lineartext" bool
-*/
-void SkPaint_Inflate(SkPaint*, const SkDOM&, const SkDOM::Node*);
-
-#endif
diff --git a/include/views/SkViewInflate.h b/include/views/SkViewInflate.h
deleted file mode 100644
index 4ec36a67df..0000000000
--- a/include/views/SkViewInflate.h
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkViewInflate_DEFINED
-#define SkViewInflate_DEFINED
-
-#include "SkDOM.h"
-#include "../private/SkTDict.h"
-#include "SkEvent.h"
-
-class SkView;
-
-class SkViewInflate {
-public:
- SkViewInflate();
- virtual ~SkViewInflate();
-
- /** Return the tree of inflated views. If root is null, create the root element
- as a view, otherwise assume root is that view, and just "inflate" it.
-
- Returns null if the tree cannot be built.
- */
- SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NULL);
- SkView* inflate(const char xml[], size_t len, SkView* root = NULL);
-
- /** Given an id attribute value, return the corresponding view, or null
- if no match is found.
- */
- SkView* findViewByID(const char id[]) const;
-
- SkDEBUGCODE(void dump() const;)
-
-protected:
- /* Override this in your subclass to handle instantiating views
- Call the inherited version for nodes you don't recognize.
-
- Do not call "inflate" on the view, just return it. This will
- get called automatically after createView returns.
- */
- virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
- /** Base implementation calls view->inflate(dom, node). Subclasses may override this
- to perform additional initializations to view, either before or after calling
- the inherited version.
- */
- virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- enum {
- kMinIDStrAlloc = 64
- };
- SkTDict<SkView*> fIDs;
-
- struct IDStr {
- SkView* fView;
- char* fStr;
- };
- SkTDArray<IDStr> fListenTo, fBroadcastTo;
- SkChunkAlloc fStrings;
-
- void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
-
- void rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
-};
-
-#endif
diff --git a/src/views/SkBGViewArtist.cpp b/src/views/SkBGViewArtist.cpp
deleted file mode 100644
index c10fe3eb78..0000000000
--- a/src/views/SkBGViewArtist.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkBGViewArtist.h"
-#include "SkCanvas.h"
-#include "SkParsePaint.h"
-
-SkBGViewArtist::SkBGViewArtist(SkColor c)
-{
- fPaint.setColor(c);
-}
-
-SkBGViewArtist::~SkBGViewArtist()
-{
-}
-
-void SkBGViewArtist::onDraw(SkView*, SkCanvas* canvas)
-{
- // only works for views that are clipped their bounds.
- canvas->drawPaint(fPaint);
-}
-
-void SkBGViewArtist::onInflate(const SkDOM& dom, const SkDOM::Node* node)
-{
- SkPaint_Inflate(&fPaint, dom, node);
-}
diff --git a/src/views/SkParsePaint.cpp b/src/views/SkParsePaint.cpp
deleted file mode 100644
index 1a1b7067ba..0000000000
--- a/src/views/SkParsePaint.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkParsePaint.h"
-#include "SkTSearch.h"
-#include "SkParse.h"
-#include "SkImageDecoder.h"
-#include "SkGradientShader.h"
-
-static SkShader* inflate_shader(const SkDOM& dom, const SkDOM::Node* node)
-{
- if ((node = dom.getFirstChild(node, "shader")) == nullptr)
- return nullptr;
-
- const char* str;
-
- if (dom.hasAttr(node, "type", "linear-gradient"))
- {
- SkColor colors[2];
- SkPoint pts[2];
-
- colors[0] = colors[1] = SK_ColorBLACK; // need to initialized the alpha to opaque, since FindColor doesn't set it
- if ((str = dom.findAttr(node, "c0")) != nullptr &&
- SkParse::FindColor(str, &colors[0]) &&
- (str = dom.findAttr(node, "c1")) != nullptr &&
- SkParse::FindColor(str, &colors[1]) &&
- dom.findScalars(node, "p0", &pts[0].fX, 2) &&
- dom.findScalars(node, "p1", &pts[1].fX, 2))
- {
- SkShader::TileMode mode = SkShader::kClamp_TileMode;
- int index;
-
- if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
- mode = (SkShader::TileMode)index;
- return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, mode);
- }
- }
- else if (dom.hasAttr(node, "type", "bitmap"))
- {
- if ((str = dom.findAttr(node, "src")) == nullptr)
- return nullptr;
-
- SkBitmap bm;
-
- if (SkImageDecoder::DecodeFile(str, &bm))
- {
- SkShader::TileMode mode = SkShader::kRepeat_TileMode;
- int index;
-
- if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
- mode = (SkShader::TileMode)index;
-
- return SkShader::CreateBitmapShader(bm, mode, mode);
- }
- }
- return nullptr;
-}
-
-void SkPaint_Inflate(SkPaint* paint, const SkDOM& dom, const SkDOM::Node* node)
-{
- SkASSERT(paint);
- SkASSERT(&dom);
- SkASSERT(node);
-
- SkScalar x;
-
- if (dom.findScalar(node, "stroke-width", &x))
- paint->setStrokeWidth(x);
- if (dom.findScalar(node, "text-size", &x))
- paint->setTextSize(x);
-
- bool b;
-
- SkASSERT("legacy: use is-stroke" && !dom.findBool(node, "is-frame", &b));
-
- if (dom.findBool(node, "is-stroke", &b))
- paint->setStyle(b ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
- if (dom.findBool(node, "is-antialias", &b))
- paint->setAntiAlias(b);
- if (dom.findBool(node, "is-lineartext", &b))
- paint->setLinearText(b);
-
- const char* str = dom.findAttr(node, "color");
- if (str)
- {
- SkColor c = paint->getColor();
- if (SkParse::FindColor(str, &c))
- paint->setColor(c);
- }
-
- // do this AFTER parsing for the color
- if (dom.findScalar(node, "opacity", &x))
- {
- x = SkMaxScalar(0, SkMinScalar(x, SK_Scalar1));
- paint->setAlpha(SkScalarRoundToInt(x * 255));
- }
-
- int index = dom.findList(node, "text-anchor", "left,center,right");
- if (index >= 0)
- paint->setTextAlign((SkPaint::Align)index);
-
- SkShader* shader = inflate_shader(dom, node);
- if (shader)
- paint->setShader(shader)->unref();
-}
diff --git a/src/views/SkViewInflate.cpp b/src/views/SkViewInflate.cpp
deleted file mode 100644
index 8418fb0e72..0000000000
--- a/src/views/SkViewInflate.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkViewInflate.h"
-#include "SkView.h"
-#include <stdio.h>
-
-SkViewInflate::SkViewInflate() : fIDs(kMinIDStrAlloc), fStrings(kMinIDStrAlloc)
-{
-}
-
-SkViewInflate::~SkViewInflate()
-{
-}
-
-void SkViewInflate::rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent)
-{
- const char* str = dom.findAttr(node, "id");
- if (str)
- fIDs.set(str, parent);
-
- const SkDOM::Node* child = dom.getFirstChild(node);
- while (child)
- {
- SkView* view = this->createView(dom, child);
- if (view)
- {
- this->rInflate(dom, child, view);
- parent->attachChildToFront(view)->unref();
- }
- else
- {
- const char* name = dom.getName(child);
- const char* target;
-
- if (!strcmp(name, "listenTo") && (target = dom.findAttr(child, "target")) != nullptr)
- this->addIDStr(&fListenTo, parent, target);
-
- if (!strcmp(name, "broadcastTo") && (target = dom.findAttr(child, "target")) != nullptr)
- this->addIDStr(&fBroadcastTo, parent, target);
- }
- child = dom.getNextSibling(child);
- }
-
- parent->setVisibleP(true);
- this->inflateView(parent, dom, node);
-}
-
-void SkViewInflate::inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node)
-{
- // called after all of view's children have been instantiated.
- // this may be overridden by a subclass, to load in layout or other helpers
- // they should call through to us (INHERITED) before or after their patch
- view->inflate(dom, node);
-}
-
-SkView* SkViewInflate::inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root)
-{
- fIDs.reset();
-
- if (root == nullptr)
- {
- root = this->createView(dom, node);
- if (root == nullptr)
- {
- printf("createView returned nullptr on <%s>\n", dom.getName(node));
- return nullptr;
- }
- }
- this->rInflate(dom, node, root);
-
- // resolve listeners and broadcasters
- {
- SkView* target;
- const IDStr* iter = fListenTo.begin();
- const IDStr* stop = fListenTo.end();
- for (; iter < stop; iter++)
- {
- if (fIDs.find(iter->fStr, &target))
- target->addListenerID(iter->fView->getSinkID());
- }
-
- iter = fBroadcastTo.begin();
- stop = fBroadcastTo.end();
- for (; iter < stop; iter++)
- {
- if (fIDs.find(iter->fStr, &target))
- iter->fView->addListenerID(target->getSinkID());
- }
- }
-
- // now that the tree is built, give everyone a shot at the ID dict
- root->postInflate(fIDs);
- return root;
-}
-
-SkView* SkViewInflate::inflate(const char xml[], size_t len, SkView* root)
-{
- SkDOM dom;
- const SkDOM::Node* node = dom.build(xml, len);
-
- return node ? this->inflate(dom, node, root) : nullptr;
-}
-
-SkView* SkViewInflate::findViewByID(const char id[]) const
-{
- SkASSERT(id);
- SkView* view;
- return fIDs.find(id, &view) ? view : nullptr;
-}
-
-SkView* SkViewInflate::createView(const SkDOM& dom, const SkDOM::Node* node)
-{
- if (!strcmp(dom.getName(node), "view"))
- return new SkView;
- return nullptr;
-}
-
-void SkViewInflate::addIDStr(SkTDArray<IDStr>* list, SkView* view, const char* str)
-{
- size_t len = strlen(str) + 1;
- IDStr* pair = list->append();
- pair->fView = view;
- pair->fStr = (char*)fStrings.alloc(len, SkChunkAlloc::kThrow_AllocFailType);
- memcpy(pair->fStr, str, len);
-}
-
-#ifdef SK_DEBUG
-void SkViewInflate::dump() const
-{
- const IDStr* iter = fListenTo.begin();
- const IDStr* stop = fListenTo.end();
- for (; iter < stop; iter++)
- SkDebugf("inflate: listenTo(\"%s\")\n", iter->fStr);
-
- iter = fBroadcastTo.begin();
- stop = fBroadcastTo.end();
- for (; iter < stop; iter++)
- SkDebugf("inflate: broadcastFrom(\"%s\")\n", iter->fStr);
-}
-#endif