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

Unified Diff: experimental/SkiaExamples/HelloSkiaExample.cpp

Issue 890873003: update example (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove multiple example cruft Created 5 years, 11 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 | « no previous file | experimental/SkiaExamples/SkExample.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/SkiaExamples/HelloSkiaExample.cpp
diff --git a/experimental/SkiaExamples/HelloSkiaExample.cpp b/experimental/SkiaExamples/HelloSkiaExample.cpp
deleted file mode 100644
index 6fd2624c18b0e5e97f9f3ff69b5abfe716f6cbce..0000000000000000000000000000000000000000
--- a/experimental/SkiaExamples/HelloSkiaExample.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- */
-
-#include "SkExample.h"
-
-#include "SkApplication.h"
-#include "SkDraw.h"
-#include "SkGradientShader.h"
-#include "SkGraphics.h"
-
-class HelloSkia : public SkExample {
-public:
- HelloSkia(SkExampleWindow* window) : SkExample(window) {
- fName = "HelloSkia";
- fBGColor = SK_ColorWHITE;
- fRotationAngle = SkIntToScalar(0);
-
- fWindow->setupBackend(SkExampleWindow::kGPU_DeviceType);
- // Another option is software rendering:
- // fWindow->setupBackend(SkExampleWindow::kRaster_DeviceType);
- }
-
-protected:
- void draw(SkCanvas* canvas) {
- // Clear background
- canvas->drawColor(fBGColor);
-
- SkPaint paint;
- paint.setColor(SK_ColorRED);
-
- // Draw a rectangle with blue paint
- SkRect rect = {
- SkIntToScalar(10), SkIntToScalar(10),
- SkIntToScalar(128), SkIntToScalar(128)
- };
- canvas->drawRect(rect, paint);
-
- // Set up a linear gradient and draw a circle
- {
- SkPoint linearPoints[] = {
- {SkIntToScalar(0), SkIntToScalar(0)},
- {SkIntToScalar(300), SkIntToScalar(300)}
- };
- SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK};
-
- SkShader* shader = SkGradientShader::CreateLinear(
- linearPoints, linearColors, NULL, 2,
- SkShader::kMirror_TileMode);
- SkAutoUnref shader_deleter(shader);
-
- paint.setShader(shader);
- paint.setFlags(SkPaint::kAntiAlias_Flag);
-
- canvas->drawCircle(SkIntToScalar(200), SkIntToScalar(200),
- SkIntToScalar(64), paint);
-
- // Detach shader
- paint.setShader(NULL);
- }
-
- // Draw a message with a nice black paint.
- paint.setFlags(
- SkPaint::kAntiAlias_Flag |
- SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotating.
- SkPaint::kUnderlineText_Flag);
- paint.setColor(SK_ColorBLACK);
- paint.setTextSize(SkIntToScalar(20));
-
- canvas->save();
-
- static const char message[] = "Hello Skia!!!";
-
- // Translate and rotate
- canvas->translate(SkIntToScalar(300), SkIntToScalar(300));
- fRotationAngle += SkDoubleToScalar(0.2);
- if (fRotationAngle > SkDoubleToScalar(360.0)) {
- fRotationAngle -= SkDoubleToScalar(360.0);
- }
- canvas->rotate(fRotationAngle);
-
- // Draw the text:
- canvas->drawText(message, strlen(message), SkIntToScalar(0), SkIntToScalar(0), paint);
-
- canvas->restore();
-
- // Invalidate the window to force a redraw. Poor man's animation mechanism.
- this->fWindow->inval(NULL);
- }
-
-private:
- SkScalar fRotationAngle;
- SkColor fBGColor;
-};
-
-static SkExample* MyFactory(SkExampleWindow* window) {
- return new HelloSkia(window);
-}
-
-// Register this class as a Skia Example.
-SkExample::Registry registry(MyFactory);
« no previous file with comments | « no previous file | experimental/SkiaExamples/SkExample.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698