remove remaining parts of SkExample

R=reed@google.com

Review URL: https://codereview.chromium.org/895103002
This commit is contained in:
caryclark 2015-02-03 11:16:05 -08:00 committed by Commit bot
parent c9fed24993
commit da5bcab059
7 changed files with 0 additions and 4115 deletions

View File

@ -1,193 +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 "gl/GrGLInterface.h"
#include "SkApplication.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkGr.h"
void application_init() {
SkGraphics::Init();
SkEvent::Init();
}
void application_term() {
SkEvent::Term();
SkGraphics::Term();
}
SkExampleWindow::SkExampleWindow(void* hwnd)
: INHERITED(hwnd) {
fType = SkExampleWindow::kGPU_DeviceType;
fRenderTarget = NULL;
fRotationAngle = 0;
this->setTitle();
this->setUpBackend();
}
SkExampleWindow::~SkExampleWindow() {
tearDownBackend();
}
void SkExampleWindow::tearDownBackend() {
SkSafeUnref(fContext);
fContext = NULL;
SkSafeUnref(fInterface);
fInterface = NULL;
SkSafeUnref(fRenderTarget);
fRenderTarget = NULL;
INHERITED::detach();
}
void SkExampleWindow::setTitle() {
SkString title("SkiaExample ");
title.appendf(fType == kRaster_DeviceType ? "raster" : "opengl");
INHERITED::setTitle(title.c_str());
}
bool SkExampleWindow::setUpBackend() {
this->setColorType(kRGBA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
bool result = attach(kNativeGL_BackEndType, 0 /*msaa*/, &fAttachmentInfo);
if (false == result) {
SkDebugf("Not possible to create backend.\n");
detach();
return false;
}
fInterface = GrGLCreateNativeInterface();
SkASSERT(NULL != fInterface);
fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInterface);
SkASSERT(NULL != fContext);
this->setUpRenderTarget();
return true;
}
void SkExampleWindow::setUpRenderTarget() {
SkSafeUnref(fRenderTarget);
fRenderTarget = this->renderTarget(fAttachmentInfo, fInterface, fContext);
}
void SkExampleWindow::drawContents(SkCanvas* canvas) {
// Clear background
canvas->drawColor(SK_ColorWHITE);
SkPaint paint;
paint.setColor(SK_ColorRED);
// Draw a rectangle with red paint
SkRect rect = {
10, 10,
128, 128
};
canvas->drawRect(rect, paint);
// Set up a linear gradient and draw a circle
{
SkPoint linearPoints[] = {
{0, 0},
{300, 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(200, 200, 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(20);
canvas->save();
static const char message[] = "Hello Skia!!!";
// Translate and rotate
canvas->translate(300, 300);
fRotationAngle += 0.2f;
if (fRotationAngle > 360) {
fRotationAngle -= 360;
}
canvas->rotate(fRotationAngle);
// Draw the text:
canvas->drawText(message, strlen(message), 0, 0, paint);
canvas->restore();
}
void SkExampleWindow::draw(SkCanvas* canvas) {
drawContents(canvas);
// in case we have queued drawing calls
fContext->flush();
// Invalidate the window to force a redraw. Poor man's animation mechanism.
this->inval(NULL);
if (kRaster_DeviceType == fType) {
// need to send the raster bits to the (gpu) window
SkImage* snap = fSurface->newImageSnapshot();
size_t rowBytes;
SkImageInfo info;
const void* pixels = snap->peekPixels(&info, &rowBytes);
fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
SkImageInfo2GrPixelConfig(info.colorType(),
info.alphaType(),
info.profileType()),
pixels,
rowBytes,
GrContext::kFlushWrites_PixelOp);
SkSafeUnref(snap);
}
INHERITED::present();
}
void SkExampleWindow::onSizeChange() {
setUpRenderTarget();
}
bool SkExampleWindow::onHandleChar(SkUnichar unichar) {
if (' ' == unichar) {
fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceType;
tearDownBackend();
setUpBackend();
this->setTitle();
this->inval(NULL);
}
return true;
}
SkOSWindow* create_sk_window(void* hwnd, int , char** ) {
return new SkExampleWindow(hwnd);
}

View File

@ -1,92 +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.
*
*/
#ifndef SkExample_DEFINED
#define SkExample_DEFINED
#include "SkSurface.h"
#include "SkWindow.h"
#include "SkTRegistry.h"
class GrContext;
struct GrGLInterface;
class GrRenderTarget;
class SkCanvas;
class SkExampleWindow;
class SkExample : SkNoncopyable {
public:
SkExample(SkExampleWindow* window) : fWindow(window) {}
virtual ~SkExample() {}
// Your class should override this method to do its thing.
virtual void draw(SkCanvas* canvas) = 0;
SkString getName() { return fName; };
// Use this public registry to tell the world about your sample.
typedef SkTRegistry<SkExample*(*)(SkExampleWindow*)> Registry;
protected:
SkExampleWindow* fWindow;
SkString fName;
};
class SkExampleWindow : public SkOSWindow {
public:
enum DeviceType {
kRaster_DeviceType,
kGPU_DeviceType,
};
SkExampleWindow(void* hwnd);
virtual ~SkExampleWindow() SK_OVERRIDE;
// Changes the device type of the object.
bool setUpBackend();
DeviceType getDeviceType() const { return fType; }
protected:
SkSurface* createSurface() SK_OVERRIDE {
if (kGPU_DeviceType == fType) {
SkSurfaceProps props(INHERITED::getSurfaceProps());
return SkSurface::NewRenderTargetDirect(fRenderTarget, &props);
}
static const SkImageInfo info = SkImageInfo::MakeN32Premul(
SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()));
return fSurface = SkSurface::NewRaster(info);
}
void draw(SkCanvas* canvas) SK_OVERRIDE;
void drawContents(SkCanvas* canvas);
void onSizeChange() SK_OVERRIDE;
private:
bool findNextMatch(); // Set example to the first one that matches FLAGS_match.
void setTitle();
void setUpRenderTarget();
bool onHandleChar(SkUnichar unichar) SK_OVERRIDE;
void tearDownBackend();
// draw contents
SkScalar fRotationAngle;
// support framework
DeviceType fType;
SkSurface* fSurface;
GrContext* fContext;
GrRenderTarget* fRenderTarget;
AttachmentInfo fAttachmentInfo;
const GrGLInterface* fInterface;
typedef SkOSWindow INHERITED;
};
#endif

View File

@ -1,13 +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.
*/
#import "SkNSView.h"
@interface SkExampleNSView : SkNSView
@end

View File

@ -1,28 +0,0 @@
//
// SkExampleNSView.m
// SkiaExamples
//
// Created by Sergio González on 6/11/13.
//
//
#import "SkExampleNSView.h"
#include "SkApplication.h"
#include <crt_externs.h>
@implementation SkExampleNSView
- (id)initWithDefaults {
if ((self = [super initWithDefaults])) {
fWind = create_sk_window(self, *_NSGetArgc(), *_NSGetArgv());
}
return self;
}
- (void)dealloc {
delete fWind;
[super dealloc];
}
@end

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.googlecode.skia.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>SkiaExamples</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

File diff suppressed because it is too large Load Diff

View File

@ -19,60 +19,6 @@
],
},
},
{
'target_name': 'SkiaExamples',
'type': 'executable',
'mac_bundle' : 1,
'sources': [
'../experimental/SkiaExamples/SkExample.h',
'../experimental/SkiaExamples/SkExample.cpp',
],
'dependencies': [
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
'views.gyp:views',
],
'conditions' : [
[ 'skia_gpu == 1', {
'include_dirs' : [
'../include/gpu',
],
}],
[ 'skia_os == "win"', {
'sources' : [
'../src/views/win/SkOSWindow_Win.cpp',
'../src/views/win/skia_win.cpp',
],
}],
[ 'skia_os == "mac"', {
'sources': [
'../experimental/SkiaExamples/SkiaExamples-Info.plist',
'../experimental/SkiaExamples/SkExampleNSView.h',
'../experimental/SkiaExamples/SkExampleNSView.mm',
'../src/views/mac/SampleAppDelegate.h',
'../src/views/mac/SampleAppDelegate.mm',
'../src/views/mac/SkEventNotifier.mm',
'../src/views/mac/skia_mac.mm',
'../src/views/mac/SkNSView.h',
'../src/views/mac/SkNSView.mm',
'../src/views/mac/SkOptionsTableView.h',
'../src/views/mac/SkOptionsTableView.mm',
'../src/views/mac/SkOSWindow_Mac.mm',
'../src/views/mac/SkTextFieldCell.h',
'../src/views/mac/SkTextFieldCell.m',
],
'include_dirs' : [
'../src/views/mac/'
],
'xcode_settings' : {
'INFOPLIST_FILE' : '../experimental/SkiaExamples/SkiaExamples-Info.plist',
},
'mac_bundle_resources' : [
'../experimental/SkiaExamples/SkiaExamples.xib'
],
}],
],
},
{
'target_name': 'multipage_pdf_profiler',
'type': 'executable',